home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / pascal / 7639 < prev    next >
Encoding:
Internet Message Format  |  1992-12-22  |  2.1 KB

  1. Path: sparky!uunet!spool.mu.edu!agate!plutonium.CChem.Berkeley.EDU!matte
  2. From: matte@plutonium.CChem.Berkeley.EDU (Matt Rose)
  3. Newsgroups: comp.lang.pascal
  4. Subject: Calling DLL Procs via pointer.
  5. Date: 23 Dec 1992 00:58:02 GMT
  6. Organization: University of California, Berkeley
  7. Lines: 41
  8. Distribution: usa
  9. Message-ID: <1h8diqINN64q@agate.berkeley.edu>
  10. NNTP-Posting-Host: plutonium.cchem.berkeley.edu
  11. Keywords: Pascal DLL Assembly
  12.  
  13.  
  14. I've been using MS-Windows for awhile now, via BC++, and BP, and
  15. I'm getting used to it, and even liking it sometimes.  But I seem 
  16. to have come across what I would consider a shortcoming of Pascal.
  17.  
  18. I want an Object that will call procedures from a DLL that is specified
  19. during run time.  The code in C would look something like this:
  20.  
  21. hLibrary = LoadLibrary('Library_Name');
  22. pDLLFunc = GetProcAddress(hLibrary, 'FuncName');
  23.  
  24. Then later on I excecute by calling:
  25.  
  26.   (*pDLLFunc)(paramList);
  27.  
  28. Borland C requires type checking on the parameter list that is achieved
  29. by forcing you to declare a pointer to function that returns TYPE, and
  30. takes paramters of TYPE and TYPE.  The strict type checking follows in
  31. the way of Pascal.
  32.  
  33. Except that the BP manuals tell me there is no provision for making a
  34. call to a procedure that I have a pointer to.  It appears that I have
  35. to go to assembly language! If this is the case I can do it, but I
  36. have to spend my valuble (ha ha) time learning assembly, and how to pop
  37. and push stacks and the like.  Geez, I'm an engineer not a programmer! :)
  38.  
  39. I find the LoadLibrary very useful for defining drivers and the like
  40. for equipment, and not forcing me to decide on the equipment until I'm
  41. running the programs.
  42.  
  43. Questions:
  44. Why does Borland Pascal not include a provision for making a function call
  45. from a pointer to the function?
  46. When will they provide this feature?
  47. Is there any other way I can call procedures from a library that won't
  48. be written until after the main program is finished?
  49. Has anyone coded an object in C, and then declared an instance of said
  50. Almost liking MS Windows, despite my dislike for a man who would make
  51. $Billions off DOS.
  52.  
  53. -matt
  54.