Link to home
Start Free TrialLog in
Avatar of ginaa
ginaa

asked on

pass char string from VB6 to VC6 dll?

Finally I can call VC6.0 dll function from VB6.0
I can send and get numerical data to dll.
But for char string data, it always fail.
Any one can give the samples for that?

Thank
ginaa
Avatar of TigerZhao
TigerZhao

No time to Program, I think your parameter's type Must be BSTR
Declare the String as BSTR in the exported function in VC++. In vb, when you define the function, string variables should be declared ByVal.
In your C++ funtion you should be able to explicitly type-cast the BSTR to LPCTSTR (or LPTSTR). From then on you should be OK...
Avatar of ginaa

ASKER

Sorry, I don't say clear enough.
1. I used VC environment but I just write C program, not use MFC.
2. I declare in dll function use (char *) and I write another C program link with this dll. The string transfer is OK.
3. I got compile error : undeclared identifier for BSTR, LPTSTR.....
So, I miss anything?
Can you answer me again

Regards
Ginaa
ASKER CERTIFIED SOLUTION
Avatar of pellep
pellep
Flag of Sweden image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of tward
DLL Created Function in Visual C/C++:

#define NOMANGLE

long NOMANGLE _stdcall OpenTIFF(HWND hWnd, char *FileName);

VB Version of the Function Call:

Declare Function OpenTIFF Lib "MSIHead" (ByVal hWnd As Long, ByVal TIFFFilename As String) As Long
Avatar of ginaa

ASKER

It's OK now,   LPSTR still undeclared identifier.
But char* is OK.

Thanks
Ginaa