Saturday, May 19, 2007

C# -- organizing long specifiers, modifiers and attributes

Often you run into something like this:
[DllImport("winspool.drv", CharSet = CharSet.Auto, SetLastError=true)] public static extern bool ClosePrinter(IntPtr ptrPrinter);

I have discovered that it is easier to locate method names when the sources are formatted as:
[DllImport("winspool.drv", CharSet = CharSet.Auto, SetLastError=true)]
public static extern bool ClosePrinter(IntPtr ptrPrinter);

[DllImport("winspool.drv")] public static extern
int SetJobA(IntPtr hPrinter, UInt32 jobId, int Level, IntPtr pJob, int command);

[DllImport("winspool.drv", CharSet=CharSet.Auto, SetLastError=true)] public static extern
Boolean OpenPrinter(
[MarshalAs(UnmanagedType.LPTStr)] string strPrinterName,
out IntPtr ptrPrinter,
IntPtr ptrDefalut
);

No comments: