O
one2001boy
Hello,
I can use call a function with any arugment from LoadLibrary(),
but not a function with argument of "FILE*.
For example, I can build a .DLL dynamically loaded library with
option /DDD in VC++ in command link.exe.
This dynamically loaded library can then be loaded by
function LoadLibrary(). The address of a function say
func1(int) inside .DLL file can be exported and accessed by function
GetProcAddress(). I can then invokde the function inside
..DLL through a pointer to function. Also, the argument
can be passed from the main program to the function as shown below.
void *dll;
dll = LoadLibrary("mydll.dll");
void (*fp1)(int);
fp1 = (void (*)(int))GetProcAddress(dll, "func1");
fp1(10);
However, if the argument of a function say, func2() is
FILE *. Then, the program will crash as shown below.
FILE* s;
s = fopen("test")
void (*fp2)(FILE*);
fp2 = (void (*)(int))GetProcAddress(dll, "func2");
fp2(stdout); // or fp2(s) will crash.
It appears that the mydll.dll has separate FILE streams
and they are overlap with the application program with file
extension .exe. How can it be resloved?
Does anyone know how to handle this passing FILE* to
a function inside a .DLL loaded by LoadLibrary()?
Thank you in advance for your help.
I can use call a function with any arugment from LoadLibrary(),
but not a function with argument of "FILE*.
For example, I can build a .DLL dynamically loaded library with
option /DDD in VC++ in command link.exe.
This dynamically loaded library can then be loaded by
function LoadLibrary(). The address of a function say
func1(int) inside .DLL file can be exported and accessed by function
GetProcAddress(). I can then invokde the function inside
..DLL through a pointer to function. Also, the argument
can be passed from the main program to the function as shown below.
void *dll;
dll = LoadLibrary("mydll.dll");
void (*fp1)(int);
fp1 = (void (*)(int))GetProcAddress(dll, "func1");
fp1(10);
However, if the argument of a function say, func2() is
FILE *. Then, the program will crash as shown below.
FILE* s;
s = fopen("test")
void (*fp2)(FILE*);
fp2 = (void (*)(int))GetProcAddress(dll, "func2");
fp2(stdout); // or fp2(s) will crash.
It appears that the mydll.dll has separate FILE streams
and they are overlap with the application program with file
extension .exe. How can it be resloved?
Does anyone know how to handle this passing FILE* to
a function inside a .DLL loaded by LoadLibrary()?
Thank you in advance for your help.