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 / .NET Framework / Interop / July 2003

Tip: Looking for answers? Try searching our database.

GetLastError with It Just Works

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Roy Chastain - 18 Jul 2003 13:45 GMT
I am using It Just Works to call many Win32APIs from managed C++.  I
have seen in one book that with PInvoke that you should NOT call
GetLastError via PInvoke but that you should call
Marshal::GetLastWin32Error.

What am I supposed to do when I am using the IJW interop interface?

Thanks
-------------------------------------------
Roy Chastain
KMSystems, Inc.
"Xin Huang" - 21 Jul 2003 06:30 GMT
The problem is, the interop code itself may call some API which sets the
last error code.

With PInvoke, we can set the SetLastError field of the DllImport attribute
to true, and call Marshal::GetLastWin32Error to retrieve the error value
cached by the interop layer.

There's no such mechanism in IJW, so I'm afraid you need to fall back to
PInvoke if you want to call GetLastError for that API call.

Hope this helps.

Regards,
Xin

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. (c) 2003 Microsoft Corporation. All
rights reserved.
Roy Chastain - 29 Jul 2003 19:31 GMT
Does this fact make IJW a little useless for a large majority of API
calls?

>The problem is, the interop code itself may call some API which sets the
>last error code.
[quoted text clipped - 14 lines]
>You assume all risk for your use. (c) 2003 Microsoft Corporation. All
>rights reserved.

-------------------------------------------
Roy Chastain
KMSystems, Inc.
"Xin Huang" - 30 Jul 2003 08:11 GMT
Yes, in cases if you want to get the last error value.

Regards,
Xin

This posting is provided "AS IS" with no warranties, and confers no rights.

Microsoft Security Announcement: Have you installed the patch for Microsoft
Security Bulletin MS03-026? If not Microsoft strongly advises you to review
the information at the following link regarding Microsoft Security Bulletin
MS03-026 http://www.microsoft.com/security/security_bulletins/ms03-026.asp 
and/or to visit Windows Update at http://windowsupdate.microsoft.com to
install the patch.  Running the SCAN program from the Windows Update site
will help to insure you are current with all security patches, not just
MS03-026.

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.