Merrion
Well-known member
Im using the FindFirstPrinterChangeNotification API call declared thus:-
and the printer_notify _options thing is declared thus:-
but when the code gets to the call it throws an exception "System.TypeLoadException" trying to pass a structure as an LPStruct.
"Additional information: Can not marshal field pType of type PRINTER_NOTIFY_OPTIONS: Marshalling types to LPStruct is not supported on structure fields"
I gather that the line:-
is wrong - but how do I pass a pointer to a structure as a member of another structure to an API call?
Thanks in advance,
Duncan
Code:
<DllImport("winspool.drv", EntryPoint:="FindFirstPrinterChangeNotification", _
SetLastError:=True, CharSet:=CharSet.Ansi, _
ExactSpelling:=True, _
CallingConvention:=CallingConvention.StdCall)> _
Public Function FindFirstPrinterChangeNotification _
(ByVal mhPrinter As Int32, _
ByVal fwFlags As Int32, _
ByVal fwOptions As Int32, _
ByRef pPrintOptions As PRINTER_NOTIFY_OPTIONS ) As Int32
\\ No code here ....
End Function
Code:
<StructLayoiut(LayoutKind.Sequential> _
Public Structure PRINTER_NOTIFY_OPTIONS
Dim dwVersion As Int32
Dim dwFlags As Int32
Dim Count As Int32
<MarhalAs(UnmanagedType.LpStruct)> Dim pTypeJob As PRINTER_NOTIFY_OPTIONS_TYPE
End Structure
but when the code gets to the call it throws an exception "System.TypeLoadException" trying to pass a structure as an LPStruct.
"Additional information: Can not marshal field pType of type PRINTER_NOTIFY_OPTIONS: Marshalling types to LPStruct is not supported on structure fields"
I gather that the line:-
Code:
<MarhalAs(UnmanagedType.LpStruct)> Dim pTypeJob As PRINTER_NOTIFY_OPTIONS_TYPE
Thanks in advance,
Duncan