- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I used Help files in IVF, "Coding Requirements for Sharing Data in DLLs", "Exporting and Importing Common Block Data", where example of appropriate DLLEXPORT directive is included and described. When I create a dll and I put common blocks that I want to be linked to the same common block in my exe program, the common block information does not pass from the exe to the dll.
How can I declare common block in both the main exe and any dll and having the information passing?
The code source of the DLL is:
subroutine Seta
use user32
use kernel32
!DEC$ ATTRIBUTES STDCALL, REFERENCE,ALIAS :"Seta":: Seta
!DEC$ ATTRIBUTES DLLEXPORT:: Seta, /X/
implicit none
common /X/C,B,A
real C,B,A
A=A+1
B=B+1
return
end subroutine Seta
The subroutine in the main program that uses the DLL is:
subroutine test
use user32
use kernel32
implicit none
pointer (p_seta, seta)
integer(HANDLE) :: dll_handle
integer(BOOL) :: free_status
integer i
real AP
common /X/C,B,A
real C,B,A
Interface
subroutine Seta
!DEC$ ATTRIBUTES DLLIMPORT:: Seta, /X/
implicit none
common /X/C,B,A
real C,B,A
end subroutine Seta
end interface
!==========================================!
dll_handle = LoadLibrary ("DLL_a.dll"C)
! Check for errors
if (dll_handle == NULL) then
! Failure
stop
end if
p_seta = GetProcAddress (dll_handle, "Seta"C)
if (p_Seta == NULL) then
! Failure
stop
end if
! Now call the function
call seta ! the value of A in the DLL is 1
Ap=A ! the value of A in the subroutine test is 0 so Ap=0
free_status = freelibrary(p_seta)
end subroutine Test
If you have a solution, pelase send me a simple example.
thanks in advance
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page