all groups > dotnet compact framework > july 2007 >
You're in the

dotnet compact framework

group:

How to PInvoke the MAKEINTRESOURCE macro


How to PInvoke the MAKEINTRESOURCE macro dev15
7/30/2007 12:00:00 AM
dotnet compact framework:
Hi, I need to pass the result of the MAKEINTRESOURCE macro
to the FindResource function whihc i have PInvoked in my VB.NET CF
code. How do i do invoke MAKEINTRESOURCE in VB.NET CF code?

Re: How to PInvoke the MAKEINTRESOURCE macro Peter Foot [MVP]
7/30/2007 12:26:24 PM
You can't P/Invoke a macro as by definition it isn't a true function. What
you need to do is find the definition and implement in managed code e.g.
#define MAKEINTRESOURCEW(i) (LPWSTR)((DWORD)((WORD)(i)))

All that is happening is the integer is being cast to a string type.
Therefore you can add a P/Invoke for FindResource which takes an int instead
of a string e.g.

[DllImport("coredll")]
private static extern IntPtr FindResource(IntPtr hModule, int lpName, int
type);

Peter

--
Peter Foot
Microsoft Device Application Development MVP
www.peterfoot.net | www.inthehand.com
In The Hand Ltd - .NET Solutions for Mobility

[quoted text, click to view]
AddThis Social Bookmark Button