Type a page name and press Enter. You'll jump to the page if it exists, or you can create it if it doesn't.
To create a page in a module other than Structures, prefix the name with the module name and a period.
IsValidDevmodeA (Structures)
.
Summary
Special NOTE: My understanding from MSDN, it will validate public structure only, not private. Also, it will attempt to repair.
C# Definition:
using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
[DllImport("winspool.Drv", EntryPoint = "IsValidDevmodeA", SetLastError = true,
ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
static extern bool IsValidDevmodeA(IntPtr pDevmode, int DevmodeSize);
public static bool CheckIsValidDevmodeA(IntPtr ptrDevModeA, int totalByteSize)
{
try
{
// Calls extern IsValidDevmodeA.
// totalByteSize could be made optional.
if (IsValidDevmodeA(ptrDevModeA, totalByteSize))
{
return true;
}
else
{
throw new Win32Exception(Marshal.GetLastWin32Error());
}
}
catch (Exception e)
{
throw e;
}
}
}
VB Definition:
Structure IsValidDevmodeA
Public TODO
End Structure
User-Defined Field Types:
C++
BOOL IsValidDevmodeA(
[in, optional] PDEVMODEA pDevmode,
size_t DevmodeSize
);
None.
Notes:
My code is from VS 2022 and using .NET Framework 4.8.1 (newer framework shouldn't change much if at all.)
Documentation
https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/winspool/nf-winspool-isvaliddevmodea
Note
DevmodeSize can be optional, my code does not show that.
Note
pass in the pointer to the created devMode, I accidentally used the pointer to allocated memory and that failed.
IsValidDevmodeA function - The print spooler's IsValidDevmode function verifies that the contents of a DEVMODE structure are valid.
2/1/2023 1:33:08 PM - shtolliver-47.227.243.115
Please edit this page!
Do you have...
helpful tips?
corrections to the existing content?
alternate definitions?
additional languages you want to include?
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing any supporting types needed.