How to PInvoke the MAKEINTRESOURCE macro

D

dev15

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?
 
P

Peter Foot [MVP]

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top