Help with a DLL, please

A

alessandra_cabrini

Hi, I have a problem with a DLL I'm not able to solve.

I need to use this DLL to receive a file from a barcode (a little
terminal) reader.

The DLL only has 2 functions, one for receive and the other to transnit
a file.
The prototype function one the readme file are:

INT __stdcall B30XferRx(LPTSTR CommandStr)
INT __stdcall B30XferTx(LPTSTR CommandStr);

where CommandStr is a string of the kind "p=4,F=filename"

I tried in this way:


void main() {

HINSTANCE hLib=LoadLibrary("B31win32.DLL");


if(hLib==NULL) {

cout << "Unable to load library!" << endl;
getch();
return;
}

INT __stdcall B30XferRx(LPTSTR "p=4,F=mydata.txt");
}

I receive this error massage (my file is pDll.cpp):

C:\Borland\BCC55\Bin>bcc32 pDll.cpp
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
pDll.cpp:
Error E2108 pDll.cpp 21: Improper use of typedef 'LPTSTR' in function
main()
Error E2293 pDll.cpp 21: ) expected in function main()
Warning W8004 pDll.cpp 22: 'B30XferRx' is assigned a value that is
never used in
function main()
*** 2 errors in Compile ***

any idea?


Thank you very much

Sandra
 
Z

Zara

Hi, I have a problem with a DLL I'm not able to solve.

I need to use this DLL to receive a file from a barcode (a little
terminal) reader.

The DLL only has 2 functions, one for receive and the other to transnit
a file.
The prototype function one the readme file are:

INT __stdcall B30XferRx(LPTSTR CommandStr)
INT __stdcall B30XferTx(LPTSTR CommandStr);

where CommandStr is a string of the kind "p=4,F=filename"

I tried in this way:


void main() {

HINSTANCE hLib=LoadLibrary("B31win32.DLL");


if(hLib==NULL) {

cout << "Unable to load library!" << endl;
getch();
return;
}

INT __stdcall B30XferRx(LPTSTR "p=4,F=mydata.txt");

You are declaring a local variable of type INT __stdcall and name
B30XferRX, and with a wrong parameter list.

What you meant was only:
B30XferRx("p=4,F=mydata.txt");

Please, check some basic C++ text, or this list FAQ.

Best regards,

-- Zara
 
E

Ed

Hi. Once you have a valid handle via LoadLibrary you will need to call
GetProcAddress for each function you wish to call. You can create a
couple typedefs like so to accomplish what you were trying to do. Ed

typedef int (*B30XferRx)(LPTSTR CommandStr);
typedef int (*B30XferTx)(LPTSTR CommandStr);

int main(int, char**) {
HMODULE hModule = ::LoadLibrary("B31win32.DLL");
if (hModule != NULL) {
B30XferRx func1 =
reinterpret_cast<B30XferRx>:):GetProcAddress(hModule, "B30XferRx"));
if (func1 != NULL)
func1("some param data");

B30XferTx func2 =
reinterpret_cast<B30XferTx>:):GetProcAddress(hModule, "B30XferTx"));
if (func2 != NULL)
func2("some param data");

FreeLibrary(hModule);
}
return 0;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top