delphi - Error : Constant or type identifier expected -


i trying use external dll function in delphi 7 program. have example in c in dll file called.

in c defined this

#define sernumaddress 0x1080  hinstance hdll430;                          // handle of dll static farproc pmspganginitcom  = null; // pointer dll function 

and in delphi write

unit msp430d;  interface uses windows, event, paras;  const  sernumaddress = $1080  ; pmspganginitcom:farproc = nil;  type hdll430 = hinstance;  implementation  end. 

but getting constant or type identifier expected error.

the problem use of hinstance.

in system unit there global variable named hinstance represents module handle contains code being executed. trying use hinstance type. because of variable hinstance, type named hinstance clash. instead type translated hinst in windows unit.

so, following code compile:

type   hdll430 = hinst; 

however, in view, more normal use hmodule these days. see what difference between hinstance , hmodule?

consider comment in c code says:

hinstance hdll430; // handle of dll 

well, if @ declarations of loadlibrary , getprocaddress, you'll see dll module handle represented hmodule. translate code as:

type   hdll430 = hmodule; 

furthermore, rather using farproc opt declare function pointer contained parameters, return value , calling convention allow compiler enforce type safety.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -