08-24-2005 08:15 AM
08-25-2005 08:18 AM
I think I kind of figured out the problem with with returning a string. I found a similar code to return a string that uses string handle, but the .c file includes "extcode.h" When I try to use it, I get a bunch of errors. Mainly I need:
TH_REENTRANT MgErr DSSetHandleSize(void *h, int32);
but I don't know what "TH_REENTRANT" means and I can't find the function on DSSetHandleSize(void *h, int32)
08-25-2005 08:43 AM
08-25-2005 09:50 AM
I used the example on passing strings in .dll but it still doesn't work.
_declspec(dllexport) int32 CRCMode(unsigned char *start_addr,unsigned char *end_addr)
{
DWORD iBytesWritten;
DWORD iBytesRead;
uChar ch;
uChar putin[15];
int32 i;
count0 = 0;
i = 0;
putin[0]='C';
putin[1]= ' ';
memcpy(&putin[2],start_addr,4);
putin[6]= ' ';
memcpy(&putin[7],end_addr,4);
putin[11]='\0';
putin[12]='\r';
WriteFile(hCom,putin,13,&iBytesWritten,NULL);
while(ch != '>'){
ReadFile(hCom,&ch,1,&iBytesRead,NULL);
sh[i] = ch;
i++;
count0++;
}
ReadFile(hCom,&ch,1,&iBytesRead,NULL);
sh[i] = ch;
sh[++i]= '\0';
return (count0+1);
}
_declspec(dllexport) int32 transfer(LStrHandle in_string,int32 size)
{
MgErr error;
int32 i;
// The first 32 bits are used for size information, and then the array comes after the size
error = DSSetHandleSize(in_string, sizeof(int32) + size*sizeof(uChar) );
if (error != mFullErr && error != mZoneErr)
{
(*in_string)->cnt=size;
for (i=0; i<size; i++)
(*in_string)->str[i]=sh[i];
return 0;
}
return -1;
}
08-25-2005 04:04 PM - edited 08-25-2005 04:04 PM
Message Edited by Newguy100 on 08-25-2005 04:05 PM
12-09-2005 07:00 AM
Newguy100,
Ref your "... Nvm, I figured it out. ..."
I'm new2... Could you tell me (us) WHAT it was ??
Thanks
12-09-2005 07:36 AM