dll function 
Author Message
 dll function

Hi alex,
    thanks for you help... This is the function definition in the dll.

void APIENTRY AsciiKey(char aAscii, BYTE aStateBits)

  // switch off caps lock if it is on, causes too much hassle otherwise
short
        //char aAscii = char(aAsciic);
  BYTE caps = ::GetKeyState(VK_CAPITAL);

  if(caps & 0x01)
  {
   VirtualKeystroke(VK_CAPITAL,0);
  }

        short code = ::VkKeyScan(aAscii);
        BYTE state = (code >> 8) | aStateBits;
        BYTE vk = code & 0xff;

        VirtualKeystroke(vk,state);

Quote:
}

if i hard code the values into the function, it works, the problem is just
geting values into this function from VB.


Tue, 18 Nov 2003 21:51:06 GMT  
 dll function
The problem is with your VB declare

Private Declare Sub AsciiKey Lib "c:\jerad\VirtualKey\Debug\VirtualKey.dll"
(aAscii As Byte, aState As Byte)

Should be:

Private Declare Sub AsciiKey Lib "c:\jerad\VirtualKey\Debug\VirtualKey.dll"
(ByVal aAscii As Byte, ByVal aState As Byte)

In C++ values are passed by value by default.  In VB there passed by
reference (equivalent to char&).  You need to overide this behaviour with
ByVal, or your just passing the address of a byte, not the byte.

Tom Shelton


Quote:
> Hi alex,
>     thanks for you help... This is the function definition in the dll.

> void APIENTRY AsciiKey(char aAscii, BYTE aStateBits)

>   // switch off caps lock if it is on, causes too much hassle otherwise
> short
>         file://char aAscii = char(aAsciic);
>   BYTE caps = ::GetKeyState(VK_CAPITAL);

>   if(caps & 0x01)
>   {
>    VirtualKeystroke(VK_CAPITAL,0);
>   }

>         short code = ::VkKeyScan(aAscii);
>         BYTE state = (code >> 8) | aStateBits;
>         BYTE vk = code & 0xff;

>         VirtualKeystroke(vk,state);
> }
> if i hard code the values into the function, it works, the problem is just
> geting values into this function from VB.



Tue, 18 Nov 2003 22:58:11 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. VB5 DLL function / Can't find DLL entry point

2. DLL function to unregister a DLL?

3. DLL handle & DLL Function handle

4. dll functions without declare statement (XLL for Access)?

5. Problems finding VBA322.dll functions from a copy of an MS Access database

6. Please Help - USER32.DLL function list.

7. Trouble calling custom dll functions from 2.0

8. dll function description

9. how to call a dll function in vba

10. User32.dll Function

11. Dll functions

12. .dll functions

 

 
Powered by phpBB® Forum Software