I wrote a simple DLL named "prova.dll" with this function exported:
char* RetNextName(int flag)
I use this DLL in another C program and it works perfectly.
In my ROBOT Script I wrote:
Declare Function RetNextName Lib "prova" ( ByVal flag As Integer) As String
Function Prova1 As String
Dim Result As String
Result = RetNextName(1)
Prova1 = Result
IT DOESN'T WORK .. THE STRING I GET IS WRONG (Robot also crashes, sometimes...)
Does anybody know what I did wrong ??
( [img]images/icons/rolleyes.gif[/img] I'm beginner as a Robot-user)
I'm not a C programmer, but I think that the Char* means that you're returning a pointer to your string, no?
Anyway I believe that Robot can only retrieve data by value, not by reference.
Try to write a function that returns a char array instead.
I used to do it this way: if I want to return string from DLL, then I fill output parameter. For example:
extern "C" __declspec(dllexport) int MyFunction (LPSTR szItem)
TCHAR g_szPath[MAX_PATH] = "\0";
In Robot script I do this:
Declare Function MyFunction Lib "MyLib" ( ByVal
szItem As String) As Integer
Dim value as string
value = Space(255)
Result = MyFunction(value)
If you want to give somebody a fish, you'll do better if you teach him how to catch it.