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 / Managed C++ / October 2007

Tip: Looking for answers? Try searching our database.

'HANDLE *' Error

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
bhumithakker@gmail.com - 15 Oct 2007 20:00 GMT
I am using a DLL function (complied in VC7), which takes a parameter
of 'HANDLE *' datatype.
The DLL developers recommend passing a HANDLE object using the
following syntax:

HANDLE obj =NULL;
func(&obj);

On successful execution of the code 'obj' is initialised to some
value.

This code works if used within VC++ MFC Application using VS2005.
But the same doesnt work in VC++ Windows Form Application using
VS2005.

In a VC++ Windows Form Application using VS2005, the compiler expects
the following syntax:

HANDLE obj =NULL;
func((HANDLE *)obj);

This compiles but gives a runtime error, and fails to initialise
'obj'.

What am I doing wrong? And how can I use the DLL function in a  VC++
Windows Form Application using VS2005.

Thanks,
Bhumi
Sheng Jiang[MVP] - 15 Oct 2007 21:00 GMT
You are passing a null address to the function, and the function expects a
valida address to write to. You can use new to allocate memory on the native
heap, pass it to the dll to retrieve the new handle, and copy the handle
value to the managed heap.

Signature

Sheng Jiang
Microsoft MVP in VC++

> I am using a DLL function (complied in VC7), which takes a parameter
> of 'HANDLE *' datatype.
[quoted text clipped - 25 lines]
> Thanks,
> Bhumi
Bhumi - 16 Oct 2007 08:43 GMT
On Oct 16, 1:00 am, "Sheng Jiang[MVP]"
<sheng_ji...@hotmail.com.discuss> wrote:
> You are passing a null address to the function, and the function expects a
> valida address to write to. You can use new to allocate memory on the native
[quoted text clipped - 38 lines]
>
> - Show quoted text -

Thanks Sheng. Got it to work now.

Thanks,
Bhumi
Ben Voigt [C++ MVP] - 16 Oct 2007 17:36 GMT
>I am using a DLL function (complied in VC7), which takes a parameter
> of 'HANDLE *' datatype.
[quoted text clipped - 10 lines]
> But the same doesnt work in VC++ Windows Form Application using
> VS2005.

It should, because that is the correct version.

> In a VC++ Windows Form Application using VS2005, the compiler expects
> the following syntax:
[quoted text clipped - 10 lines]
> Thanks,
> Bhumi

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.