@msdn=http://search.microsoft.com/search/results.aspx?qu=$$$ @pinvoke=http://pinvoke.net/$$$.htm Summary: IsValidDevmodeA function - The print spooler's IsValidDevmode function verifies that the contents of a DEVMODE structure are valid. 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: IsValidDevmodeA@msdn on MSDN 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.
Edit Structures.IsVali...
You do not have permission to change this page. If you feel this is in error, please send feedback with the contact link on the main page.