Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to call a Windows program's DLL function

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi all,
I'm using PowerCobol 3.0 to call a function called WINHLLAPI from a DLL that belongs to a Windows program.
I've got even the .LIB file from the DLL.

The way I call it is the folowing:
CALL "WINHLLAPI" WITH C LINKAGE USING BY VALUE FUN-NUMBER BY REFERENCE FUN-STRING BY VALUE FUN-LENGTH BY VALUE FUN-RET
END-CALL

It compiles ok but I've got the following error during linking:

error LNK2001: unresolved external symbol _WINHLLAPI


I've tried the following but nothing works:
1) Write the name of the DLL in COBOL85.CBR
2) Add the .LIB to the project


Can you help me????
 
Are you sure WINHLLAPI is exported by the dll? You should have a .def file containing WINHLLAPI in the EXPORTS section when linking the dll. Does it have the right calling convention?
 
I'm using the same DLL with C and Visual Basic. So I'm sure the way the function is called is the rigth one.

Does anyone have an example of call to a DLL? (Not WindowsAPI please)?

Thanks
 
Hi Rolphen,

Did you ever resolve your dll issue? Im not a Cobol programmer but a team member who uses Cobol is trying to call a dll file that i wrote in c++. she cant get it to work but i can call the dll from c++ and from powerbuilder.

if you got it working could you tell me how?

thanks,
stacey
 
stacey,

I think I can help if you are more specific (and do use Fujitsu Cobol or some Micro Focus Cobol product): What is going wrong? (compiler error, link error, runtime-error, unexpected behaviour during runtime). It also would help if you post the definition of the C++ routine to be called as well as the Cobol CALL statement.

Marcel
 
Hi Marcel,

She is using AcuGT 5.1. She was wrapping the call to the dll function in an 'on exception' so i asked her to remove it and find out what it does. It can't find the function so im guessing she doesnt have the dll in the right place or her classpath is not set. she is on a unix box trying to call a win32 dll on a windows nt unit.

the only help i can offer her is: for me to call the dll without altering my classpath, i put the file in winnt/system32.

She is in Jackson and im in dallas so there is a little bit of a barrier...plus im clueless about cobol and she is clueless about dll calls. this should be interesting. ;)


thanks,
stacey
 
Let me re-phrase:
A Acu-cobol program on Unix box trying to call a HLLAPI function on a NT-box? Where does the terminal emulator run? On unix or on NT? From what kind of host are you scraping the data of the screen?

Do you expect the DLL (intel) code to run on unix? Hmmm.. I can only image Linux together with wine to do the job. Is that what you are running?

To solve the problem you need terminal-emulation on unix (e g. TN3270) with HLLAPI support. I found one here ( The HLLAPI api's can be called from cobol. All the documentation is based upon C programs, but it works in cobol. I've tested it on an AIX with Micro Focus Server Express.
 
OK I'm running into a similar situation. My DLL definitions don't have _ in front of them but Fujitsu COBOL 3.0 expects them. If I say: CALL "myproc" it complains about having unresolved symbol _myproc when the DLL function is named myproc.

I know this is an old thread, but I thought it might elaborate on the precise problem I'm running into in trying to call things from DLLs/LIBs.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top