wavemill,
Two things. The first is that I would not specifically point to the
AddMonitorA function. The declaration I would use is this:
[DllImmport("winspool.drv", CharSet=CharSet.Auto)]
public static extern bool AddMonitor(string pName, int Level, ref
MONITOR_INFO_2 pMonitors);
The P/Invoke layer will call the right function
(AddMonitorA/AddMonitorW) based on the platform the code is being run on.
Additionally, you can declare the last parameter as the type you want to
pass. Since the parameter is just a pointer, you can pass any kind you
want. When you use ref, the marshaler considers it a pointer to a structure
and it marshals it appropriately.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"wavemill" <wa******@discussions.microsoft.com> wrote in message
news:5D**********************************@microsof t.com...
Hello,
this my problem:
I have a struc, but i would like to know how can i do to convert it in
byte.
This is my code:
[DllImport("winspool.drv", EntryPoint = "AddMonitor")]
public static extern int AddMonitorA(string pName, int Level, ref byte
pMonitors);
[StructLayout(LayoutKind.Sequential)]
public struct MONITOR_INFO_2
{
public string pName;
public string pEnvironment;
public string pDLLName;
}
AddMonitorA(null, 2,ref ???);
Thank you,
Best regards,
Wavemill