G
Guest
Are there any concise rules about when you need to marshal data to WinAPI
calls, and when you don't? It appears that most times you can call WinAPI
calls directly from .NET without any preparation. For example
Declare Function OpenPrinter Lib "winspool.drv" Alias "OpenPrinterA" (ByVal
pPrinterName As String, ByVal phPrinter As Integer,
<MarshalAs(UnmanagedType.Struct)> ByRef pDefault As PRINTER_DEFAULTS) As
Integer
Dim tmpHandle As Int32
Dim msDeviceName as String = "MyPrinter"
OpenPrinter(msDeviceName, tmpHandle, 0)
However, some functions appear to require all kinds of fancy manipulation
before you get to call them--particularly ones which require structures or
arrays. (See http://www.codeproject.com/vb/net/printwatchvbnet.asp). Why
isn't .NET smart enough to handle this "under the covers", the way that VB6
is?
calls, and when you don't? It appears that most times you can call WinAPI
calls directly from .NET without any preparation. For example
Declare Function OpenPrinter Lib "winspool.drv" Alias "OpenPrinterA" (ByVal
pPrinterName As String, ByVal phPrinter As Integer,
<MarshalAs(UnmanagedType.Struct)> ByRef pDefault As PRINTER_DEFAULTS) As
Integer
Dim tmpHandle As Int32
Dim msDeviceName as String = "MyPrinter"
OpenPrinter(msDeviceName, tmpHandle, 0)
However, some functions appear to require all kinds of fancy manipulation
before you get to call them--particularly ones which require structures or
arrays. (See http://www.codeproject.com/vb/net/printwatchvbnet.asp). Why
isn't .NET smart enough to handle this "under the covers", the way that VB6
is?