Jump to content
Sign in to follow this  
sambuddy

How do i pass a string to a dll

Recommended Posts

sambuddy

Hello all,

I have created a dll which has a function in it called OCR. At the moment the function looks like this

OCR_DLL_API int OCR(void)

{

return 1000;

}

and when i call the function in the dll

$return=DllCall($dll,"int","OCR")

$return = 1000 which is what it should be

BUT if i now change the function to take a string as a parameter

OCR_DLL_API int OCR(LPCSTR name)

{

return 1000;

}

and i call the function using this

$return=DllCall($dll,"int","OCR","str","John")

autoit crashes

Can anyone tell me how i create the dll to accept a string as a parameter and pass it from autoit?

Thanks

Share this post


Link to post
Share on other sites
-Ultima-

Dunno. Try LPCTSTR instead? Chances are, it won't work (it's just a different #define), but that's the only difference I see between your function and functions I normally call with DllCall :\

Edited by -Ultima-

[ WinINet.au3 | Array.au3 (Optimized) | _UnixTimeParse() ]

Share this post


Link to post
Share on other sites
sambuddy

thanks for that. I have tried it but no luck ;)

Share this post


Link to post
Share on other sites
Richard Robertson

Have you tried using a straight up "char *" or "wchar_t *"?

Edited by Richard Robertson

Share this post


Link to post
Share on other sites
LarryDalooza

is this a cdecl or stdcall dll?

Lar.


f_mrcleansmalm_77ce002.jpgAutoIt has helped make me wealthy

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×