As there is at beginning :
using PInvoke;
Then you use the package PInvoke.User32
then if you add at beginning
using static PInvoke.User32;
it will add needed definitions as VS suggests
(I tested by just copy/pasting your code)
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi there, currently I need to dig up some Win32 code which is a part of my project, Actually, it's a part of my WPF application where access Win32 APIs using the traditional Pinvoke method.
But Currently I facing some error at lParam pointer structure.
Here is the piece of code where I face the problem :
MINMAXINFO mmi = (MINMAXINFO)Marshal.PtrToStructure(lParam, typeof(MINMAXINFO));
if (monitor != IntPtr.Zero)
{
MONITORINFO monitorInfo = new MONITORINFO();
GetMonitorInfo(monitor, monitorInfo);
I get red squiggly Line on MINMAXINFO and on MONITORINFO on my Visual Studio 2022.
I hope someone who frequently work with Win32 APIs will able to solve my problem.
Another important point is I already do the necessary DLL imports like
[DllImport("user32" )]
Hope someone able to figure out my problem. I also attached some images for better visualization and better understanding of the problem.
Here is my Full source Code : https://pastebin.com/Y7puGMsZ
I gave the Pastebin link here because posting full source Code may filter by the moderator and bots.
I hope this Microsoft Q & A site content moderation will improve in future, because now a days people facing a lot of problems when they posting any question here, their post will automatically get deleted and comments are filtered and deleted.
As there is at beginning :
using PInvoke;
Then you use the package PInvoke.User32
then if you add at beginning
using static PInvoke.User32;
it will add needed definitions as VS suggests
(I tested by just copy/pasting your code)
For example, from internal class Win32 for P/Invoke -
internal const int WM_GETMINMAXINFO = 0X0024;
[StructLayout(LayoutKind.Sequential)]
internal struct POINT
{
public int x;
public int y;
}
[StructLayout(LayoutKind.Sequential)]
internal struct MINMAXINFO
{
public POINT ptReserved;
public POINT ptMaxSize;
public POINT ptMaxPosition;
public POINT ptMinTrackSize;
public POINT ptMaxTrackSize;
}
//
Win32.MINMAXINFO mminfo = (Win32.MINMAXINFO )Marshal.PtrToStructure(m.LParam, typeof(Win32.MINMAXINFO));