Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
devwiki:winapi [2017/09/18 03:27]
ying
devwiki:winapi [2017/09/18 04:39] (current)
ying [window related API]
Line 5: Line 5:
 ===== file related API ===== ===== file related API =====
  
 +  * SHFileOperation (shell32.dll) Alias "​SHFileOperationA":​ uses the dialog box prompts of the shell on copies, moves, renames, or deletes an object in the file system
   * CopyFile (kernel32.dll);​ Alias "​CopyFileA"​ <​code>​   * CopyFile (kernel32.dll);​ Alias "​CopyFileA"​ <​code>​
 ByVal lpExistingFileName As String: "​d:​\tmp\src.txt"​ ByVal lpExistingFileName As String: "​d:​\tmp\src.txt"​
Line 11: Line 12:
 return As Long : 1 or 0 return As Long : 1 or 0
 </​code>​ </​code>​
 +  * MoveFile (kernel32.dll);​ Alias MoveFileA <​code>​result = MoveFile("​d:​\tmp\src.txt",​ "​d:​\tmp\tgt.txt"​)</​code>​
 +  * CreateFile (kernel32.dll);​ Alias "​CreateFileA":​ creates or opens a console, communications resource, directory (can only open), disk devices, files, mailslots, and pipes
 +  * CreateDirectory (kernel32.dll);​ Alias "​CreateDirectoryA"​ <​code>​
 +ByVal lpPathName As String: "​d:​\tmp\newFolder"​
 +lpSecurityAttributes As SECURITY_ATTRIBUTES As Long:
 +return : 0 for fail
 +</​code>​
 +  * RemoveDirectory (kernel32.dll) <​code>​retval = RemoveDirectory("​d:​\tmp\newFolder"​) </​code>​
 +  * SHGetFileInfo (shell32.dll) Alias "​SHGetFileInfoA"​: retrieves information about a file system object in the shell.
 +  * SHGetFolderLocation (shell32.dll) Alias "​SHGetFolderLocationA":​ creates a pointer to an ITEMIDLIST structure refering to a special folder on the computer
 +  * SHGetFolderPath (shell32.dll) Alias "​SHGetFolderPathA":​ retrieves the name of the path of a special folder on the system
 +  * SHGetPathFromIDList (shell32.dll) Alias "​SHGetPathFromIDListA":​ determines the path of the folder refered to by a pointer to an ITEMIDLIST structure
 +  * GetFileInformationByHandle (kernel32.dll):​ get file dates, size, links <​code>​
 +ByVal hFile As Long: handle
 +lpFileInformation As BY_HANDLE_FILE_INFORMATION) As Long: pointer
 +return: 0 for fail
  
 +hfile = CreateFileNS("​C:​\MyProgram\datafile.txt",​ GENERIC_READ,​ FILE_SHARE_READ,​ 0, OPEN_EXISTING,​ FILE_ATTRIBUTE_ARCHIVE,​ 0)
 +retval = GetFileInformationByHandle(hfile,​ fileinfo)
 +</​code>​
 +  * GetFileAttributes (kernel32.dll):​ get attributes of a file or a directory, like read-only, archive, hidden <​code>​input:​ "​d:​\tmp\src.txt"</​code>​
 +  * GetFileSize (kernel32.dll):​ get file size <​code>​
 +ByVal hFile As Long
 +lpFileSizeHigh As Long
 +return As Long
 +</​code>​
 +  * GetFullPathName (kernel32.dll) Alias "​GetFullPathNameA":​ combine path and file name
 +
 +===== window related API =====
 +  * MessageBox (user32.dll) Alias "​MessageBoxA":​ alert box from a handler <​code>​
 +ByVal hWnd As Long
 +ByVal lpText As String
 +ByVal lpCaption As String
 +ByVal uType As Long
 +return As Long</​code>​
 +  * SHBrowseForFolder (shell32.dll) Alias "​SHBrowseForFolderA":​ folder select dialog
 +  * ShellExecute (shell32.dll) Alias "​ShellExecuteA":​ opens, prints, or executes a file using the Windows shell, and return a handle
 +  * ShellExecuteEx (shell32.dll) Alias "​ShellExecuteExA:​ opens, prints, or executes a file using the Windows shell
 +  * IsWindow (user32.dll):​ check hwnd handle is a window
 +  * ShowWindow (user32.dll):​ shows/hides a window in a certain manner.
 +  * MoveWindow (user32.dll):​ move window x,y,w,h and refresh <​code>​result = MoveWindow(hwnd,​ 200, 150, 175, 300, 1)</​code>​
 +  * SetWindowPos (user32.dll) : moves a window to a new location on the screen.<​code>​
 +ByVal hwnd As Long
 +ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long
 +ByVal wFlags As Long
 +return As Long</​code>​
 +  * GetWindowRect (user32.dll):​ from handle to return r.top, r.left, r.bottom, r.right
 +  * SetRect (user32.dll): sets the position and size of a rectangle. The two coordinates specified are the upper-left and lower-right corners of the rectangle <​code>​
 +lpRect As RECT
 +ByVal X1 As Long
 +ByVal Y1 As Long
 +ByVal X2 As Long
 +ByVal Y2 As Long
 +return As Long</​code>​
 +  * GetWindowTextLength (user32.dll) Alias "​GetWindowTextLengthA":​ return a window title length
 +  * GetWindowText (user32.dll) Alias "​GetWindowTextA":​ get title bar text <​code>​
 +ByVal hWnd As Long
 +ByVal lpString As String
 +ByVal nMaxCount As Long
 +return 0 if fail</​code>​
 +  * SetWindowText (user32.dll) Alias SetWindowTextA
 +  * GetForegroundWindow (user32.dll):​ the top window of the Z-order, return hwnd
 +  * SetForegroundWindow (user32.dll):​ makes the specified window the current foreground window and gives it the focus
 +  * GetDesktopWindow (user32.dll):​ get handle for desktop <​code>​
 +no input
 +return: 0 for fail, or hwnd as long
 +</​code>​
 +
 +  * GetTopWindow (user32.dll):​ get handle to the currently active child window of a window
 +  * SetActiveWindow (user32.dll): ​ makes a given window the active window for the program, giving it the focus
 +  * GetCapture (user32.dll):​ get which windows of a application has the mouse in focus <​code>​
 +no input
 +return: 0 for fail, or hwnd as long
 +</​code>​
 +  * SetFocusAPI (user32.dll) Alias SetFocus: gives a window the input focus
 +  * GetWindowRgn (user32.dll):​ shape of window
 +  * InsertMenuItem (user32.dll):​ adds a menu item to a menu that already exists.
 +  * RemoveMenu (user32.dll)
 +  * LoadCursor (user32.dll)
 +  * LoadCursorFromFile (user32.dll) <​code>​LoadCursorFromFile("​d:​\test\custom.ani"​)</​code>​
 +  * SetCursor (user32.dll)
 +  * SetSystemCursor (user32.dll):​ changes one of the cursors that Windows provides
 +  * ShowCursor (user32.dll):​ show hide cursor
 +  * SendMessage (user32.dll) Alias "​SendMessageA":​ send a msg to a window
  
 +===== System related =====
  
 +  * RestartDialog (shell32.dll) Alias "#​59":​ prompts the user with a yes-or-no dialog box asking to either reboot, shut down, or log off the system<​code>​
 +ByVal hwndOwner As Long
 +ByVal lpstrReason As String
 +ByVal uFlags As Long
 +return As Long</​code>​
 +  * SHEmptyRecycleBin (shell32.dll) Alias "​SHEmptyRecycleBinA":​ empty the Recycle Bin of a particular drive or all
 +  * socket (wsock32.dll):​ creates a new socket used for network communications,​ like with TCP/IP protocol
 +  * send (wsock32.dll):​ sends data to a network host via a connected socket. The socket must have already been connected to another computer via connect. <​code>​
 +ByVal s As Long
 +buf As Any
 +ByVal length As Long
 +ByVal flags As Long
 +return As Long</​code>​
 +  * SendInput (user32.dll):​ send a mouse, keyboard input to input stream, not interspersed with others <​code>​
 +ByVal nInputs As Long
 +pInputs As INPUT_TYPE
 +ByVal cbSize As Long
 +return As Long</​code>​
 +  * TextOut (gdi32.dll) Alias "​TextOutA":​ displays a line of text on a device
 +  * Sleep (kernel32.dll):​ pauses program execution for a certain amount of time in ms
 +  * SetVolumeLabel (kernel32.dll) Alias "​SetVolumeLabelA"​ <​code>​result = SetVolumeLabel("​D:​\",​ "​date_drive"​)</​code>​
 +  * StartDoc (gdi32.dll) Alias "​StartDocA":​ initiates a job for a printer