Having a heck of a time getting data back from a C++ DLL that uses UNICODE. I have used Dr Bobs head Convert program to convert the header and get the function address, and structure, that program is EXCELLENT.
The Delphi unit that is generated did not understand TCHAR in C++, neither do I ... I changed these to a number of things from WideChar to PWideChar and I cannot get anything back that resembles real data. I can make the calls ok but the results are a mess.
I have included a sample of the C++ header and the Delphi data definitions. If anybody has a clue I would be very appreciative..
C++ Structure
typedef struct _MyAppAppLogInfo {
BOOL bMsgDriven;
HWND hAppWnd;
LPCTSTR lpszProductID;
LPCTSTR lpszProductVer;
LPCTSTR lpszProductType;
TCHAR chAppLogAction[VM_BUFFSIZE_ACTION];
TCHAR chLogVMID[VM_BUFFSIZE_VMID];
} MyAppAppLogInfo, *PMyAppAppLogInfo;
Delphi Data Structure
_MyAppAppLogInfo = record
bMsgDriven: Bool;
hAppWnd: HWND;
lpszProductID: PWideChar;
lpszProductVer: PWideChar;
lpszProductType: PWideChar;
chAppLogAction: Array[0..VM_BUFFSIZE_ACTION-1] of PWideChar;
chLogVMID: Array[0..VM_BUFFSIZE_VMID-1] of PWideChar;
end {_MyAppAppLogInfo};
MyAppAppLogInfo = _MyAppAppLogInfo;
PMyAppAppLogInfo = ^_MyAppAppLogInfo;
test:=New(PMyAppAppLogInfo);
//C++ code
// AppLogInfo.lpszProductID = TEXT("pkcs11_apptest1"
// AppLogInfo
// AppLogInfo.lpszProductType = TEXT(""
// AppLogInfo.bMsgDriven = TRUE;
// AppLogInfo.hAppWnd = hWnd;
test.lpszProductID:= 'pkcs11_apptest1';
test.lpszProductVer:= 'version1.0';
test.lpszProductType:= '';
test.bMsgDriven:= TRUE;
test.hAppWnd:= Application.Handle;
x:= SizeOf(test);
y:= MyAppDmInit (test,x);
//Nothing readeable is displayed, tried all type of casting and var types but
//see nothing readeable.....
// tried using char and strings
ShowMessage(IntToStr(SizeOf(test.chAppLogAction)));
ShowMessage(IntToStr(SizeOf(test.chLogVMID)));
sTst:= strPas(test.chAppLogAction[0]);
Anybody have to do this and have a code snippet that I can play with?
THANKS
The Delphi unit that is generated did not understand TCHAR in C++, neither do I ... I changed these to a number of things from WideChar to PWideChar and I cannot get anything back that resembles real data. I can make the calls ok but the results are a mess.
I have included a sample of the C++ header and the Delphi data definitions. If anybody has a clue I would be very appreciative..
C++ Structure
typedef struct _MyAppAppLogInfo {
BOOL bMsgDriven;
HWND hAppWnd;
LPCTSTR lpszProductID;
LPCTSTR lpszProductVer;
LPCTSTR lpszProductType;
TCHAR chAppLogAction[VM_BUFFSIZE_ACTION];
TCHAR chLogVMID[VM_BUFFSIZE_VMID];
} MyAppAppLogInfo, *PMyAppAppLogInfo;
Delphi Data Structure
_MyAppAppLogInfo = record
bMsgDriven: Bool;
hAppWnd: HWND;
lpszProductID: PWideChar;
lpszProductVer: PWideChar;
lpszProductType: PWideChar;
chAppLogAction: Array[0..VM_BUFFSIZE_ACTION-1] of PWideChar;
chLogVMID: Array[0..VM_BUFFSIZE_VMID-1] of PWideChar;
end {_MyAppAppLogInfo};
MyAppAppLogInfo = _MyAppAppLogInfo;
PMyAppAppLogInfo = ^_MyAppAppLogInfo;
test:=New(PMyAppAppLogInfo);
//C++ code
// AppLogInfo.lpszProductID = TEXT("pkcs11_apptest1"
// AppLogInfo
// AppLogInfo.lpszProductType = TEXT(""
// AppLogInfo.bMsgDriven = TRUE;
// AppLogInfo.hAppWnd = hWnd;
test.lpszProductID:= 'pkcs11_apptest1';
test.lpszProductVer:= 'version1.0';
test.lpszProductType:= '';
test.bMsgDriven:= TRUE;
test.hAppWnd:= Application.Handle;
x:= SizeOf(test);
y:= MyAppDmInit (test,x);
//Nothing readeable is displayed, tried all type of casting and var types but
//see nothing readeable.....
// tried using char and strings
ShowMessage(IntToStr(SizeOf(test.chAppLogAction)));
ShowMessage(IntToStr(SizeOf(test.chLogVMID)));
sTst:= strPas(test.chAppLogAction[0]);
Anybody have to do this and have a code snippet that I can play with?
THANKS