Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

Search Results for "set" in [All]

msdrm

.

    SetLastError=true),

.

    CharSet = CharSet.Auto,

.

[DllImport("msdrm.dll", SetLastError = true)]

imm32

.

[DllImport("imm32.dll", SetLastError=true)]

.

[DllImport("imm32.dll", CharSet=CharSet.Unicode)]

.

[DllImport("imm32.dll", CharSet=CharSet.Unicode)]

.

[DllImport("Imm32.dll", SetLastError=true)]

.

    public static extern bool ImmSetOpenStatus(IntPtr himc, bool b);

.

[DllImport("Imm32.dll", SetLastError=true)]

.

    public int  dwOffset;

.

            int os = list.dwOffset;

ntdll

.

[DllImport("ntdll.dll", ExactSpelling=true, SetLastError=false)]

.

  <DllImport("ntdll.dll", ExactSpelling:=True, SetLastError:=False)> _

.

[DllImport("ntdll.dll", ExactSpelling = true, SetLastError = true)]

.

[DllImport("ntdll.dll", ExactSpelling = true, SetLastError = true)]

.

[DllImport("ntdll.dll", SetLastError=true)]

.

[DllImport("ntdll.dll", SetLastError=true)] static extern IntPtr NtQueryInformationFile(IntPtr fileHandle, ref IO_STATUS_BLOCK IoStatusBlock, IntPtr pInfoBlock, uint length, FILE_INFORMATION_CLASS fileInformation);

.

        FileMailslotSetInformation

.

        FileMailslotSetInformation,       // 27

.

        FileMailslotSetInformation,        // 27

.

        [FieldOffset(0)]

.

        [FieldOffset(8)]

.

        [FieldOffset(16)]

.

        [FieldOffset(24)]

.

        [FieldOffset(32)]

.

    [DllImport("ntdll.dll", SetLastError = true)]

.

        File.SetAttributes(path2file, FileAttributes.Normal);

.

[DllImport("ntdll.dll", SetLastError=true)]

.

[DllImport("NTDLL.DLL", SetLastError=true)]

.

[DllImport("ntdll.dll", SetLastError=true)]

.

[DllImport("ntdll.dll", SetLastError=true)]

.

[DllImport("ntdll.dll", SetLastError=true)]

.

[DllImport("ntdll.dll", SetLastError = true)]

.

  <DllImport("ntdll.dll", SetLastError:=True)> _

.

static extern UInt32 NtSetSystemInformation(NtSystemInformation.SYSTEM_INFORMATION_CLASS InfoClass, IntPtr Info, UInt32 Length);

.

Declare Function NtSetSystemInformation Lib "ntdll.dll" (TODO) As TODO

.

public static void SetSystemInformation(NtSystemInformation.SYSTEM_INFORMATION_CLASS InfoClass, IntPtr Info, UInt32 Length)

.

        result = NtSetSystemInformationKernel(InfoClass, Info, Length);

.
Documentation
[NtSetSystemInformation] on MSDN
.
Summary
Sets the resolution of the system Timer in the calling process context.
.

[DllImport("ntdll.dll", SetLastError=true)]

.

static extern int NtSetTimerResolution(int DesiredResolution, bool SetResolution, out int CurrentResolution );

.

Declare Function NtSetTimerResolution Lib "ntdll.dll" (ByVal DesiredResolution as UInteger, ByVal SetResolution as Boolean, ByRef CurrentResolution as UInteger)

.

NtSetTimerResolution(0.5, True, 0)

.
Documentation
[NtSetTimerResolution] on MSDN
.

[DllImport("ntdll.dll", SetLastError = false)]

.

  <DllImport("ntdll.dll", SetLastError:=False)> _

.

[DllImport("ntdll.dll", SetLastError=true)]

.

    ProcessWorkingSetWatch, // q: PROCESS_WS_WATCH_INFORMATION[]; s: void

.

    ProcessWorkingSetWatchEx, // q: PROCESS_WS_WATCH_INFORMATION_EX[]

.

    [DllImport("ntdll.dll", SetLastError = true)]

.

[DllImport("ntdll", CharSet = CharSet.Auto, ExactSpelling = true, SetLastError = true)]

.
Summary
Tells NtQuerySystemInformation and NtSetSystemInformation what you would like to read/change.
.

    public UInt32 ZeroPageCount; // Size=4 Offset=0

.

    public UInt32 FreePageCount; // Size=4 Offset=4

.

    public UInt32 ModifiedPageCount; // Size=4 Offset=8

.

    public UInt32 ModifiedNoWritePageCount; // Size=4 Offset=12

.

    public UInt32 BadPageCount; // Size=4 Offset=16

.

    public UInt32[] PageCountByPriority; // Size=32 Offset=20

.

    public UInt32[] RepurposedPagesByPriority; // Size=32 Offset=52

.

    public UInt32 ModifiedPageCountPageFile; // Size=4 Offset=84

winspool

.

[DllImport("winspool.drv", SetLastError = true)]

.

[DllImport("winspool.drv", SetLastError = true, CharSet = CharSet.Auto)]

.

    [DllImport("winspool.drv", CharSet = CharSet.Auto, SetLastError = true)]

.

[DllImport("winspool.drv", SetLastError=true)]

.

SetLastError:=True, _

.

As always, only do SetLastError=true if you actually intend to call GetLastError.

.

[DllImport("winspool.drv", SetLastError = true, CharSet = CharSet.Auto)]

.

[DllImport("winspool.drv", CharSet = CharSet.Ansi, SetLastError = true)]

.

[DllImport("winspool.Drv", EntryPoint = "DocumentPropertiesW", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]

.

[DllImport("winspool.drv", CharSet = CharSet.Unicode, SetLastError = true)]

.

  <DllImport("winspool.Drv", EntryPoint:="DocumentPropertiesW", SetLastError:=True, ExactSpelling:=True, CallingConvention:=CallingConvention.StdCall)> _

.

"DocumentProperties(this.Handle, IntPtr.Zero, printerSettings.PrinterName, pDevMode, pDevMode, 0);" returns -1 and error code 183 under x64 however i dnt knw y!

.

in order to get it working use "DocumentProperties(this.Handle, IntPtr.Zero, printerSettings.PrinterName, IntPtr.Zero, pDevMode, 0);"

.

    private void OpenPrinterPropertiesDialog(PrinterSettings printerSettings)

.

        IntPtr hDevMode = printerSettings.GetHdevmode(printerSettings.DefaultPageSettings);

.

        int sizeNeeded = DocumentProperties(this.Handle, IntPtr.Zero, printerSettings.PrinterName, pDevMode, pDevMode, 0);

.

        DocumentProperties(this.Handle, IntPtr.Zero, printerSettings.PrinterName, devModeData, pDevMode, 14);

.

        printerSettings.SetHdevmode(devModeData);

.

        printerSettings.DefaultPageSettings.SetHdevmode(devModeData);

.

    private void OpenPrinterPropertiesDialog(PrinterSettings printerSettings)

.

        IntPtr hDevMode = printerSettings.GetHdevmode(printerSettings.DefaultPageSettings);

.

        int sizeNeeded = DocumentProperties(this.Handle, IntPtr.Zero, printerSettings.PrinterName, pDevMode, pDevMode, 0);

.

        DocumentProperties(this.Handle, IntPtr.Zero, printerSettings.PrinterName, IntPtr.Zero, pDevMode, 14);

.

        printerSettings.SetHdevmode(devModeData);

.

        printerSettings.DefaultPageSettings.SetHdevmode(devModeData);

.

    private void OpenPrinterPropertiesDialog(PrinterSettings printerSettings)

.

        IntPtr hDevMode = printerSettings.GetHdevmode(printerSettings.DefaultPageSettings);

.

        int sizeNeeded = DocumentProperties(this.Handle, IntPtr.Zero, printerSettings.PrinterName, IntPtr.Zero, pDevMode, 0);

.

        DocumentProperties(this.Handle, IntPtr.Zero, printerSettings.PrinterName, IntPtr.Zero, pDevMode, 14);

.

        printerSettings.SetHdevmode(devModeData);

.

        printerSettings.DefaultPageSettings.SetHdevmode(devModeData);

.

I had to fixed Matthias solution, because it doesn't work well for me. Exception is no more occurs, but when some setting is changed in printer properties it isn't used by printer. I've changed second call of DocumentProperties method. The third-from-last paramter MUST be in this case devModeData.

.

    private void OpenPrinterPropertiesDialog(PrinterSettings printerSettings)

.

        IntPtr hDevMode = printerSettings.GetHdevmode(printerSettings.DefaultPageSettings);

.

        int sizeNeeded = DocumentProperties(this.Handle, IntPtr.Zero, printerSettings.PrinterName, IntPtr.Zero, pDevMode, 0);

.

        DocumentProperties(this.Handle, IntPtr.Zero, printerSettings.PrinterName, devModeData, pDevMode, 14);

.

        printerSettings.SetHdevmode(devModeData);

.

        printerSettings.DefaultPageSettings.SetHdevmode(devModeData);

.

I believe the issue(s) discussed re:x64 is actually an odd idiosyncracy under Windows Server 2008 R2 x64, but is not a x86/x64 problem per se. At least testing this under Win7 x64, I have no issues. However, under W2K8 x64, the OutBuffer and InBuffer must NOT be the same (in Win7 x64 this works OK). ALSO, the call to set doc properties with fMode = 14 (Prompt | In | Out) and OutBuffer = IntPtr.Zero CANNOT possibly correct, as in this case there is no place to put the resulting Devmode. Good code shouldn't use "magic numbers" anyway. The following values from WinSpool.h should be used instead of "14" or "0" for the last parameter in this call:

.

[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]

.

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]

.

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]

.

    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]

.

    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]

.

    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]

.

        public string pszVendorSetup;

.

[DllImport("winspool.drv", SetLastError = true)]

.

[DllImport("winspool.drv", SetLastError = true)]

.
Summary
The EnumJobs function retrieves information about a specified set of print jobs for a specified printer.
.

[DllImport("Winspool.drv", SetLastError=true, EntryPoint="EnumJobsA")]

.

    <StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Auto)> Structure JOB_INFO_1

.

    <StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Auto)> Structure SYSTEMTIME

.

[DllImport("winspool.drv", CharSet = CharSet.Auto, SetLastError = true)]

.

    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]

.

[DllImport("winspool.drv",CharSet = CharSet.Auto, SetLastError = true)]

.

    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]

.

    [DllImport("winspool.drv",CharSet = CharSet.Auto, SetLastError = true)]

.

[DllImport("winspool.drv", CharSet = CharSet.Auto, SetLastError = true)]

.

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]

.

        'call EnumPrinterDrivers with cbBuffer set

.

        int offset = pAddr.ToInt32();

.

            printerInfo2[i] = (DRIVER_INFO_2)Marshal.PtrToStructure(new IntPtr(offset), type);

.

            offset += increment;

.

[DllImport("winspool.drv", CharSet = CharSet.Auto, SetLastError = true)]

.

        int offset = pAddr.ToInt32();

.

        printerInfo2[i] = (PRINTER_INFO_2)Marshal.PtrToStructure(new IntPtr(offset), type);

.

        offset += increment;

.

PrinterSettings.InstalledPrinters, but this only gives the name of the printers.

.

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]

.

    [DllImport("winspool.drv", CharSet = CharSet.Auto, SetLastError = true)]

.

            int offset = rawBuffer.ToInt32();

.

            dataTypesInfoArray[i] = (DataTypesInfo)Marshal.PtrToStructure(new IntPtr(offset), type);

.

            offset += increment;

.

      [DllImport("winspool.drv", CharSet = CharSet.Auto, SetLastError = true)]

.

           int offset = pAddr.ToInt32();

.

          printprocessorInfo1[i] = (PRINTPROCESSOR_INFO_1)Marshal.PtrToStructure(new IntPtr(offset), type);

.

          offset += increment;

.

    SetLastError = true,

.

    CharSet = CharSet.Auto,

.

[DllImport("winspool.Drv", EntryPoint="FlushPrinter", SetLastError=true, CharSet=CharSet.Ansi,ExactSpelling=true, CallingConvention=CallingConvention.StdCall)]

.

[DllImport("winspool.drv", CharSet = CharSet.Auto, SetLastError = true)]

.

[DllImport("winspool.drv", CharSet=CharSet.Auto, SetLastError=true)]

.

As always, only do SetLastError=true if you actually intend to call GetLastError.

.

[DllImport("winspool.drv", CharSet=CharSet.Auto, SetLastError=true)]

.

[DllImport("winspool.drv",SetLastError=true)]

.

Both signatures will work fine, it is a matter of whether you need a higher level of access to the printer or not. For 'read' only access such as monitoring printer queues, you don't need to pass in a PRINTER_DEFAULTS instance for the last parameter, you can just pass zero (0) if you declare the extern function pDefault parameter as an int. You will need a PRINTER_DEFAULTS structure if you need to change any properties of the printer such as setting the duplex value of the printer.

.

[DllImport("winspool.Drv", EntryPoint = "OpenPrinterA", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]

.

[DllImport("winspool.drv", CharSet = CharSet.Unicode, SetLastError = true)]

.

   SetLastError:=True, CharSet:=CharSet.Ansi, _

.

   SetLastError:=True, CallingConvention:=CallingConvention.StdCall, _

.

   CharSet:=CharSet.Ansi)> _

.

   SetLastError:=True, CallingConvention:=CallingConvention.StdCall, _

.

   CharSet:=CharSet.Ansi)> _

.

   [<DllImport("winspool.drv", EntryPoint="OpenPrinterA", SetLastError=true, CharSet=CharSet.Ansi, ExactSpelling=true,  

.

As always, only do SetLastError=true if you actually intend to call GetLastError (This includes throwing a Win32Exception if the call fails)

.

SetJobA(pHandle, (int)jobID, 0, ref b, (int)Job_Control.Cancel);

52: print
.

   [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]

.

   [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]

.

    [DllImport("winspool.Drv", EntryPoint = "ReadPrinter", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]

.

[DllImport("winspool.Drv", EntryPoint="ResetPrinterA", SetLastError=true, CharSet=CharSet.Ansi,ExactSpelling=true, CallingConvention=CallingConvention.StdCall)]

.

private static extern bool ResetPrinter(IntPtr hPrinter,ref PRINTER_DEFAULTS pd);

.

Declare Function ResetPrinter Lib "winspool.drv" (TODO) As TODO

.
Documentation
[ResetPrinter] on MSDN
.
Summary
Sets the default printer for a user. Only supported for Windows 2000 and above.
.

    [DllImport("winspool.drv", CharSet=CharSet.Auto, SetLastError=true)]

.

    public static extern bool SetDefaultPrinter(string Name);

.

Declare Function SetDefaultPrinter Lib "winspool.drv" Alias "SetDefaultPrinterA" (ByVal pszPrinter As String) As Boolean

.

    pinvokeResult = SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, IntPtr.Zero,

.

    // Set default printer

.

    result = SetDefaultPrinter(defaultPrinterName);

.

        pinvokeResult = SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, IntPtr.Zero,

.

I tried this in a little test solution and now I have a magical method SetDefaultPrinter which you can use natively. There’s also methods for pretty much everything you can do to a Windows printer.

.
Documentation
[SetDefaultPrinter] on MSDN
57: SetJob
.

[DllImport("winspool.drv", EntryPoint="SetJobA")]

.

static extern int SetJobA(IntPtr hPrinter, int JobId,

.

Declare Function SetJob Lib "winspool.drv" Alias "SetJobA" (hPrinter As IntPtr, JobId As Integer,

.

SetJobA(pHandle, (int)jobID, 0, ref b, JOB_CONTROL_CANCEL);

.

dim Result as long = SetJob(handle, jobid, 0, Nothing, JOB_CONTROL_RESUME)

.
Documentation
[SetJob] on MSDN
.

[DllImport("winspool.drv", CharSet=CharSet.Auto)]

.

static extern uint SetPrinterData(IntPtr hPrinter, string pValueName, uint Type, byte[] pData, uint cbData);

.
Documentation
[SetPrinterData] on MSDN
.

[DllImport("winspool.drv", CharSet=CharSet.Auto)]

.

static extern uint SetPrinterData(IntPtr hPrinter, string pValueName, uint Type, byte[] pData, uint cbData);

.
Documentation
[SetPrinterData] on MSDN
.

[DllImport("winspool.drv", EntryPoint = "WritePrinter", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]

.

    <DllImport("winspool.Drv", EntryPoint:="WritePrinter", SetLastError:=True, CharSet:=CharSet.Unicode, ExactSpelling:=True, CallingConvention:=CallingConvention.StdCall)> _

Cut off search results after 60. Please refine your search.


 
Access PInvoke.net directly from VS: