Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
DotNet
acad.assignment.mngr
academic
adonet
aspnet
aspnet.announcements
aspnet.build.controls
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
clr
compactframework
component_services
datatools
distributed_apps
drawing
faqs
framework
framework.wmi
general
internationalization
interop
languages.csharp
languages.jscript
languages.vb
languages.vb.controls
languages.vb.data
languages.vb.upgrade
languages.vc
languages.vc.libraries
myservices
odbcnet
performance
remoting
scripting
sdk
security
setup
vjsharp
vsa
webservi.enhancements
webservices
windowsforms
windowsforms.controls
winforms.databinding
winforms.designtime
xml
  
 
date: Fri, 29 Feb 2008 02:07:01 -0800,    group: microsoft.public.dotnet.languages.vc.libraries        back       


Calling freelibrary problem   
I use the MFC to develop the project and want to call the function from the 
DLL file. 
I write the header file to access the DLL function as below.

DLLInstance = LoadLibrary(CA2W(AVR309DLL)))

DoSetDataPortDirection = (IMPFUNC_U) GetProcAddress (DLLInstance, 
"DoSetDataPortDirection");

 I can call the function correctly by using loadlibrary() and 
getproaddress() command. But when I call freelibrary(), the system return the 
error message
"First-chance exception at 0x77fa167c in URC_App.exe: 0xC0000008: An invalid 
handle was specified."
I have tried to use afxloadlibrary and afxfreelibrary, but the problem still 
occurs.
Can anyone help me to solve it?

Thank you,

Ricky Chong
date: Fri, 29 Feb 2008 02:07:01 -0800   author:   Ricky Chong

Re: Calling freelibrary problem   
Hi Ricky,

> DLLInstance = LoadLibrary(CA2W(AVR309DLL)))
> 
> DoSetDataPortDirection = (IMPFUNC_U) GetProcAddress (DLLInstance,
> "DoSetDataPortDirection");
> 
> I can call the function correctly by using loadlibrary() and
> getproaddress() command. But when I call freelibrary(), the system
> return the error message
> "First-chance exception at 0x77fa167c in URC_App.exe: 0xC0000008: An
> invalid handle was specified."
> I have tried to use afxloadlibrary and afxfreelibrary, but the
> problem still occurs.

What happens when you call FreeLibrary directly without ever
calling DoSetDataPortDirection?

Are you sure that you use the correct calling convention and
parameters when you call that function? Did you get a header
from the dll manufacturer or do you build the dll yourself?

It might be a bug in the dll as well. When the last FreeLibrary
is called DllMain of that dll is called.

--
SvenC
date: Fri, 29 Feb 2008 14:32:26 +0100   author:   SvenC am

Re: Calling freelibrary problem   
SvenC,

I have called the freelibrary after loadlibrary, the system return the error 
message too.
I use the data conversion function CA2W(avr309dll) in the loadlibrary. I 'm 
not sure it's correct or not, but the function can be called. And after the 
function is finished, error will occurs. 
I find the header file from internet, the orginal source code doesn't 
include the header file. I have try it in visual basic, it's worked.
And I find that after I run the loadlibrary, the system windows in the 
bottom of the screen show the avr309.dll with the symbol "!". Does it mean 
that the dll is not loaded correctly? 

Thank you,

Ricky

"SvenC" wrote:

> Hi Ricky,
> 
> > DLLInstance = LoadLibrary(CA2W(AVR309DLL)))
> > 
> > DoSetDataPortDirection = (IMPFUNC_U) GetProcAddress (DLLInstance,
> > "DoSetDataPortDirection");
> > 
> > I can call the function correctly by using loadlibrary() and
> > getproaddress() command. But when I call freelibrary(), the system
> > return the error message
> > "First-chance exception at 0x77fa167c in URC_App.exe: 0xC0000008: An
> > invalid handle was specified."
> > I have tried to use afxloadlibrary and afxfreelibrary, but the
> > problem still occurs.
> 
> What happens when you call FreeLibrary directly without ever
> calling DoSetDataPortDirection?
> 
> Are you sure that you use the correct calling convention and
> parameters when you call that function? Did you get a header
> from the dll manufacturer or do you build the dll yourself?
> 
> It might be a bug in the dll as well. When the last FreeLibrary
> is called DllMain of that dll is called.
> 
> --
> SvenC
date: Fri, 29 Feb 2008 08:22:00 -0800   author:   Ricky Chong

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us