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
ginaaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TigerZhaoCommented:
No time to Program, I think your parameter's type Must be BSTR
0
pellepCommented:
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...
0
ginaaAuthor Commented:
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
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

pellepCommented:
Ok. Don't declare as BSTR. It should work if you declare the variable in your c-dll as LPSTR (or char* if your using win95/98/nt).
But in VB you must Declare the the string variable ByVal in the header if the imported function i.e.

Declare Function MyFunc lib "MyLib.dll" (ByVal sMyStringValue as String) as long

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
twardCommented:
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
0
ginaaAuthor Commented:
It's OK now,   LPSTR still undeclared identifier.
But char* is OK.

Thanks
Ginaa
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.