Re: GetProcAddress() refused to return address

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance




Igor Tandetnik wrote:
Jo <JoJoTwilligo@xxxxxxxxxxx> wrote:
I'm still a little concerned about the declarations though. Before
I had:
typedef int (CALLBACK* _OpenFileType)(LPCTSTR);
according to all the tutorials, but then I got an error, which
suspected I had a declaration mismatch. So I took out the CALLBACK and
it worked fine. I want to be sure that I have it right. Exactly how
should I declare the function type if the above declaration was used
in implicit linking?

I recommend putting CALLBACK back in. CALLBACK is a macro that expands
to __stdcall. Without it, by default you would have __cdecl calling
convention. __cdecl is basically only supported by C and C++ compilers,
whereas __stdcall would allow your DLL to be used from pretty much any
language capable of targeting Windows (almost all functions in Win32 API
use __stdcall calling convetion, so it's a de facto standard).

I don't have that option. The DLL was written w/__cdecl functions,
so I can't use __stdcall.

.



Relevant Pages

  • Re: How to call this API callback function?
    ... I'm kinda moving off to another API declaration... ... Normally a callback is implemented in your app, ... LPARAM lParam, ...
    (microsoft.public.vb.winapi)
  • Re: GetProcAddress() refused to return address
    ... typedef int (CALLBACK* _OpenFileType); ... suspected I had a declaration mismatch. ... whereas __stdcall would allow your DLL to be used from pretty much any ... use __stdcall calling convetion, so it's a de facto standard). ...
    (microsoft.public.vc.language)
  • Re: GetProcAddress() refused to return address
    ... typedef int (CALLBACK* _OpenFileType); ... suspected I had a declaration mismatch. ... use __stdcall calling convetion, so it's a de facto standard). ... in a .DEF file. ...
    (microsoft.public.vc.language)
  • Re: GetProcAddress() refused to return address
    ... suspected I had a declaration mismatch. ... So I took out the CALLBACK ... functions in Win32 API use __stdcall calling convetion, ... The DLL was written w/__cdecl functions, ...
    (microsoft.public.vc.language)
  • Re: IntPtr and method P/Invoke
    ... what exactly is crash message or code? ... is not clear if it crashes because of wrong callback definition, ... the reason I don't want to change the P/Invoke declaration is that ... > AlexS wrote: ...
    (microsoft.public.dotnet.languages.csharp)