WinAPI LowLevel Keyboard Hooks

Mike Parker aldacron at gmail.com
Thu Jul 19 18:34:40 PDT 2012


On 7/20/2012 5:17 AM, DLimited wrote:
> On Thursday, 19 July 2012 at 20:06:55 UTC, dnewbie wrote:
>> On Thursday, 19 July 2012 at 19:51:31 UTC, DLimited wrote:
>>> Yes, I did. Are the newlines important?
>>>
>>> And you really get a MessageBox per keystroke? I start as admin,
>>> disabled my AV but still, no success.
>>
>> Yes, I get 2 "WHOA" messages. One from the WM-KEYDOWN and the other
>> from WM-KEYUP.
>> Sorry I don't know what is wrong.
>
> THANK YOU for your help! It works now!
>
> I didn't call Runtime.initialize; in my exported function because I
> thought the runtime would already be initialized in the DllMain - seems
> like that is not the case. Wouldn't have thought of it if I hadn't had
> your sample code, though!
>
> Thanks a ton!

The runtime is initialzed automatically in an executable because it has 
its own C 'main' entry point. That gets called first, the runtime does 
all its initialization, then it calls your D main function.

In a DLL, the entry point is DllMain, not 'main'. So the runtime is not 
initialized at startup and you have to do it manually. The same holds 
true if you create an application with a WinMain entry point instead of 
main.


More information about the Digitalmars-d-learn mailing list