microsoft/TypeAgent

Public

mirrored fromhttps://github.com/microsoft/TypeAgentAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
6cc8936acc292a25ffffc08efeb06fe6cc3261c9

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

dotnet/autoShell/AutoShell_Win32.cs

67lines · modecode

1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4using System;
5using System.Collections.Generic;
6using System.Linq;
7using System.Runtime.InteropServices;
8using System.Text;
9using System.Threading.Tasks;
10
11namespace autoShell
12{
13 internal partial class AutoShell
14 {
15 private const int SPI_SETDESKWALLPAPER = 20;
16 private const int SPIF_UPDATEINIFILE = 0x01;
17 private const int SPIF_SENDCHANGE = 0x02;
18 private const uint LOAD_LIBRARY_AS_DATAFILE = 0x00000002;
19
20 // window rect structure
21 struct RECT
22 {
23 public int Left; // x position of upper-left corner
24 public int Top; // y position of upper-left corner
25 public int Right; // x position of lower-right corner
26 public int Bottom; // y position of lower-right corner
27 }
28
29 // import GetWindowRect
30 [DllImport("user32.dll")]
31 static extern bool GetWindowRect(IntPtr hWnd, ref RECT Rect);
32
33 // import GetShellWindow
34 [DllImport("user32.dll")]
35 static extern IntPtr GetShellWindow();
36
37 // import GetDesktopWindow
38 [DllImport("user32.dll")]
39 static extern IntPtr GetDesktopWindow();
40
41 // import SetForegroundWindow
42 [System.Runtime.InteropServices.DllImport("user32.dll")]
43 private static extern bool SetForegroundWindow(IntPtr hWnd);
44
45 [DllImport("user32.dll", EntryPoint = "SendMessage", SetLastError = true)]
46 static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, UInt32 wParam, IntPtr lParam);
47
48 // import SetWindowPos
49 [DllImport("user32.dll")]
50 static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
51 // import FindWindowEx
52 [DllImport("user32.dll")]
53 static extern IntPtr FindWindowEx(IntPtr hWndParent, IntPtr hWndChildAfter, string lpClassName, string lpWindowName);
54
55 [DllImport("user32.dll", CharSet = CharSet.Auto)]
56 private static extern int SystemParametersInfo(int uAction, int uParam, string lpvParam, int fuWinIni);
57
58 [System.Runtime.InteropServices.DllImport("kernel32.dll", SetLastError = true)]
59 private static extern IntPtr LoadLibraryEx(string lpFileName, IntPtr hFile, uint dwFlags);
60
61 [System.Runtime.InteropServices.DllImport("kernel32.dll", SetLastError = true)]
62 private static extern bool FreeLibrary(IntPtr hModule);
63
64 [System.Runtime.InteropServices.DllImport("user32.dll", CharSet = System.Runtime.InteropServices.CharSet.Auto)]
65 private static extern int LoadString(IntPtr hInstance, uint uID, StringBuilder lpBuffer, int nBufferMax);
66 }
67}
68