DllCall no return any value

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Archimede
Posts: 503
Joined: 25 Nov 2021, 09:49
Location: Switzerland / Italy

DllCall no return any value

07 May 2023, 08:46

Hallo.
I have this DllCall:

DllCall( "CoInitialize", UInt, 0 )

it seem to work, but if I put

iTest := DllCall( "CoInitialize", UInt, 0 )

it no return any value, the iTest var is == "" (no any value).
Can anyone tell me why?
The Microsoft site tell it must return a^numeric value.
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: DllCall no return any value

07 May 2023, 08:53

u dont need to call this function per se because autohotkey has already called it internally once as part of OleInitialize

anyway, u can read the DllCall docs to figure out why the call is failing. check ErrorLevel, then reread in the docs what implications passing just a plain function name to call has
Archimede
Posts: 503
Joined: 25 Nov 2021, 09:49
Location: Switzerland / Italy

Re: DllCall no return any value

07 May 2023, 09:20

It is very interesting.
After that function I need to call
DllCall( "SetWinEventHook", UInt, iEvent, UInt, iEvent, UInt, 0, UInt, RegisterCallback( sFunctionName ), UInt, iPID, UInt, 0, UInt, iFlags )

is it no necessary to call
DllCall( "CoInitialize", UInt, 0 )
before that?

I controlled the ErrorLevel value: it is
-4 The specified function could not be found inside the DLL:
DllCall( "CoInitialize", UInt, 0 )

I found the right dll library, and now the CoInitialize call works.
The CoInitialize is on the ole32.dll library, SetWinEventHook is on the user32.dll library.
CoInitialize is on a different libray than SetWinEventHook: is it right?
The returned value is 1 that means "The COM library is already initialized on this thread": than it seem the call is no necessary: is it right?

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 188 guests