Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C++ Libraries / February 2008

Tip: Looking for answers? Try searching our database.

Calling freelibrary problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ricky Chong - 29 Feb 2008 10:07 GMT
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
SvenC - 29 Feb 2008 13:32 GMT
Hi Ricky,

> DLLInstance = LoadLibrary(CA2W(AVR309DLL)))
>
[quoted text clipped - 8 lines]
> 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
Ricky Chong - 29 Feb 2008 16:22 GMT
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

> Hi Ricky,
>
[quoted text clipped - 23 lines]
> --
> SvenC

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.