Click to See Complete Forum and Search --> : URGENT - How to pass a string to a DLL ??


M.Anand
January 29th, 1999, 06:31 AM
I have written a DLL using Win32 SDK . One of the exported functions in DLL takes LPCTSTR as parameter. How do I call this from VB ? If I pass a variable of type String , it gives a "Bad DLL Calling convention" error.


Help is very much appreciated


Thanks

Anand

hemant
January 29th, 1999, 12:03 PM
You have to pass the string to the dll ByVal So try this


Private Declare Function MyFunction_

Lib "MyDLL" Alias "MyDLLFunction" ( _

ByVal lpBuffer As String )


This should work.

M.Anand
January 29th, 1999, 10:29 PM
Hi Hemant


I had given the same way as you had mentioned. I didn't give an alias.

I have a function named ExecuteCommand1 in my Dll . I have given it like this


Public Declare Function ExecuteCommand1_

Lib "Path of the Dll" ( _

ByVal lpBuffer As String )


It gives the same error " Bad DLL calling convention"


Anand