- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
.
use kernel32
pointer (p,DefineProblem300)
! Declare an interface block to the routine to be called.
interface
Subroutine DefineProblem300(FName,IE,ErrorMsg)
!DEC$ ATTRIBUTES DLLIMPORT:: DefineProblem300
character(80) FName, ErrorMsg
integer(4) :: IE
end
p = loadlibrary("e:/test1/blm.dll")
if (p == 0) then
type *, "Error occurred opening blm.dll"
type *, "Program aborting"
goto 1000
endif
q1 = getprocaddress(p, "DefineProblem300")
if (q1 == 0) then
type *, "Error occurred finding DefineProblem300 in blm.dll"
type *, "Program aborting"
goto 1000
endif
!
strDir = "e:/test1/dll.dat"
call DefineProblem300(strDir,IE,ErrorMsg)
....
Message Edited by orangecccc on 04-05-200603:22 PM
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Also, do not use DLLIMPORT on the interface to a routine you access through LoadLibrary/GetProcAddress. You have not declared q1.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve,
Your suggestion was very helpful. Now the DLL was loaded.
But when I debugged the program, I've got an error 'Unhandled exception in test.exe (BLM.DLL): 0xC0000005:Access Violation' on the call statement (call DefineProblem300(strDir,IE,ErrorMsg)).' Do you have any idea for the error?
How can I declair q1?
The dll.dat is input data for the DLL. Do you think my program is O.K?
Thank you for your help again.
Message Edited by orangecccc on 04-06-200609:44 AM
Message Edited by orangecccc on 04-06-200609:47 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
pointer (p,DefineProblem300)
with:
pointer (q1,DefineProblem300)
integer(int_ptr_kind()) p
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve,
When I changed my code from your suggestion, I've got an compile error as follows:
Error: Multiple declaration of a DEC Fortran pointee.[DEFINEPROBLEM300]
pointer (q1,DefineProblem300)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you Steve.
Please advise me how to link(?) the DLL and input data (dll.dat). Please see my Fortran code in my previous message. I'm almost getting there. Thanks,
Message Edited by orangecccc on 04-06-200611:18 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Message Edited by orangecccc on 04-06-200604:05 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve,
Here is the dll file as an attached. Could you check what I have a problem?
When I debugged the code, the program was stopped the following line:
call DefineProblem300(strDir,IE,ErrorMsg)
This call is to read the input data file, *.dat. Many thanks,
Message Edited by orangecccc on 04-06-200604:14 PM
Message Edited by orangecccc on 04-07-200610:22 AM
![](/skins/images/45C6C2D737ED71F4C51F0145C8CB1E9C/responsive_peak/images/icon_anonymous_message.png)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page