#region License Information (GPL v3) /* ShareX - A program that allows you to take screenshots and share any file type Copyright (c) 2007-2023 ShareX Team This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Optionally you can also view the license at . */ #endregion License Information (GPL v3) using System; using System.Drawing; using System.Runtime.InteropServices; using System.Text; namespace ShareX.HelpersLib { #region Delegates public delegate bool EnumWindowsProc(IntPtr hWnd, IntPtr lParam); public delegate IntPtr HookProc(int nCode, IntPtr wParam, IntPtr lParam); #endregion Delegates public static partial class NativeMethods { #region user32.dll [DllImport("user32.dll")] public static extern bool AnimateWindow(IntPtr hwnd, int time, AnimateWindowFlags flags); [DllImport("user32.dll")] public static extern bool BringWindowToTop(IntPtr hWnd); [DllImport("user32.dll")] public static extern IntPtr CopyIcon(IntPtr hIcon); [DllImport("user32.dll")] public static extern IntPtr DefWindowProc(IntPtr hWnd, uint uMsg, UIntPtr wParam, IntPtr lParam); [DllImport("user32.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool DestroyIcon(IntPtr hIcon); [DllImport("user32.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool EnumWindows(EnumWindowsProc lpEnumFunc, IntPtr lParam); [DllImport("user32.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool EnumChildWindows(IntPtr hwndParent, EnumWindowsProc lpEnumFunc, IntPtr lParam); [DllImport("user32.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool EnumThreadWindows(uint dwThreadId, EnumWindowsProc lpfn, IntPtr lParam); [DllImport("user32.dll", CharSet = CharSet.Auto)] public static extern int GetClassName(IntPtr hWnd, StringBuilder lpClassName, int nMaxCount); [DllImport("user32.dll")] public static extern bool ClientToScreen(IntPtr hWnd, ref Point lpPoint); [DllImport("user32.dll")] public static extern bool DrawIcon(IntPtr hDC, int X, int Y, IntPtr hIcon); [DllImport("user32.dll")] public static extern bool DrawIconEx(IntPtr hdc, int xLeft, int yTop, IntPtr hIcon, int cxWidth, int cyHeight, int istepIfAniCur, IntPtr hbrFlickerFreeDraw, int diFlags); [DllImport("user32.dll")] public static extern IntPtr FindWindow(string lpClassName, string lpWindowName); [DllImport("user32.dll")] public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow); [DllImport("user32.dll")] public static extern IntPtr FindWindowEx(IntPtr parentHwnd, IntPtr childAfterHwnd, IntPtr className, string windowText); [DllImport("user32.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool FlashWindowEx(ref FLASHWINFO pwfi); [DllImport("user32.dll")] public static extern IntPtr GetActiveWindow(); [DllImport("user32.dll")] public static extern uint GetClassLong(IntPtr hWnd, int nIndex); [DllImport("user32.dll")] public static extern IntPtr GetClassLongPtr(IntPtr hWnd, int nIndex); [DllImport("user32.dll")] public static extern bool GetClientRect(IntPtr hWnd, out RECT lpRect); [DllImport("user32.dll")] public static extern bool GetCursorInfo(out CursorInfo pci); [DllImport("user32.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool GetCursorPos(out POINT lpPoint); [DllImport("user32.dll")] public static extern IntPtr GetDC(IntPtr hWnd); [DllImport("user32.dll")] public static extern IntPtr GetDesktopWindow(); [DllImport("user32.dll")] public static extern IntPtr GetForegroundWindow(); [DllImport("user32.dll")] public static extern bool GetIconInfo(IntPtr hIcon, out IconInfo piconinfo); [DllImport("user32.dll")] public static extern IntPtr CreateIconIndirect([In] ref IconInfo piconinfo); [DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true, CallingConvention = CallingConvention.Winapi)] public static extern short GetKeyState(int keyCode); [DllImport("user32.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool GetWindowPlacement(IntPtr hWnd, ref WINDOWPLACEMENT lpwndpl); /// /// The GetNextWindow function retrieves a handle to the next or previous window in the Z-Order. /// The next window is below the specified window; the previous window is above. /// If the specified window is a topmost window, the function retrieves a handle to the next (or previous) topmost window. /// If the specified window is a top-level window, the function retrieves a handle to the next (or previous) top-level window. /// If the specified window is a child window, the function searches for a handle to the next (or previous) child window. /// [DllImport("user32.dll")] public static extern IntPtr GetWindow(IntPtr hWnd, GetWindowConstants wCmd); [DllImport("user32.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool GetScrollInfo(IntPtr hwnd, int fnBar, ref SCROLLINFO lpsi); [DllImport("user32.dll")] public static extern int GetSystemMetrics(int smIndex); [DllImport("user32.dll")] public static extern int GetSystemMetrics(SystemMetric smIndex); [DllImport("user32.dll")] public static extern IntPtr GetWindowDC(IntPtr hWnd); [DllImport("user32.dll", CharSet = CharSet.Auto, EntryPoint = "GetWindowLong")] public static extern IntPtr GetWindowLong32(IntPtr hWnd, int nIndex); [DllImport("user32.dll", CharSet = CharSet.Auto, EntryPoint = "GetWindowLongPtr")] public static extern IntPtr GetWindowLongPtr64(IntPtr hWnd, int nIndex); [DllImport("user32.dll", CharSet = CharSet.Auto, EntryPoint = "SetWindowLong")] public static extern IntPtr SetWindowLongPtr32(IntPtr hWnd, int nIndex, IntPtr dwNewLong); [DllImport("user32.dll", CharSet = CharSet.Auto, EntryPoint = "SetWindowLongPtr")] public static extern IntPtr SetWindowLongPtr64(IntPtr hWnd, int nIndex, IntPtr dwNewLong); [DllImport("user32.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool GetWindowRect(IntPtr hWnd, out RECT lpRect); [DllImport("user32.dll")] public static extern int GetWindowRgn(IntPtr hWnd, IntPtr hRgn); [DllImport("user32.dll", CharSet = CharSet.Auto)] public static extern int GetWindowText(IntPtr hWnd, [Out] StringBuilder lpString, int nMaxCount); [DllImport("user32.dll", CharSet = CharSet.Auto)] public static extern int GetWindowTextLength(IntPtr hWnd); [DllImport("user32.dll")] public static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId); /// Determines the visibility state of the specified window. [DllImport("user32.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool IsWindowVisible(IntPtr hWnd); /// Determines whether the specified window is minimized (iconic). [DllImport("user32.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool IsIconic(IntPtr hWnd); /// Determines whether a window is maximized. [DllImport("user32.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool IsZoomed(IntPtr hWnd); [DllImport("user32.dll")] public static extern IntPtr LoadCursor(IntPtr hInstance, int iconId); [DllImport("user32.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool PrintWindow(IntPtr hwnd, IntPtr hDC, uint nFlags); [DllImport("user32.dll")] public static extern bool ReleaseCapture(); [DllImport("user32.dll")] public static extern bool ReleaseCapture(IntPtr hwnd); [DllImport("user32.dll")] public static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC); [DllImport("user32.dll")] public static extern uint SendInput(uint nInputs, ref INPUT pInputs, int cbSize); [DllImport("user32.dll")] public static extern uint SendInput(uint nInputs, [MarshalAs(UnmanagedType.LPArray), In] INPUT[] pInputs, int cbSize); [DllImport("user32.dll", CharSet = CharSet.Auto)] public static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam); [DllImport("user32.dll", CharSet = CharSet.Auto)] public static extern IntPtr SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam); [DllImport("user32.dll")] public static extern IntPtr SendMessage(IntPtr hWnd, int Msg, int wParam, [MarshalAs(UnmanagedType.LPWStr)] string lParam); [DllImport("user32.dll", CharSet = CharSet.Auto)] public static extern IntPtr SendMessageTimeout(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam, SendMessageTimeoutFlags fuFlags, uint uTimeout, out UIntPtr lpdwResult); [DllImport("user32.dll", CharSet = CharSet.Auto)] public static extern IntPtr SendMessageTimeout(IntPtr hWnd, int Msg, int wParam, int lParam, SendMessageTimeoutFlags fuFlags, uint uTimeout, out IntPtr lpdwResult); [DllImport("user32.dll")] public static extern IntPtr SetActiveWindow(IntPtr hWnd); [DllImport("user32.dll")] public static extern bool SetCursorPos(int x, int y); [DllImport("user32.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SetForegroundWindow(IntPtr hWnd); [DllImport("user32.dll")] public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, SetWindowPosFlags uFlags); [DllImport("user32.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SetWindowPlacement(IntPtr hWnd, [In] ref WINDOWPLACEMENT lpwndpl); [DllImport("user32.dll")] public static extern bool ShowWindow(IntPtr hWnd, int nCmdShow); [DllImport("user32.dll", ExactSpelling = true)] public static extern bool UpdateLayeredWindow(IntPtr hwnd, IntPtr hdcDst, ref POINT pptDst, ref SIZE psize, IntPtr hdcSrc, ref POINT pptSrc, uint crKey, [In] ref BLENDFUNCTION pblend, uint dwFlags); /// The RegisterHotKey function defines a system-wide hot key /// Handle to the window that will receive WM_HOTKEY messages generated by the hot key. /// Specifies the identifier of the hot key. /// Specifies keys that must be pressed in combination with the key /// specified by the 'vk' parameter in order to generate the WM_HOTKEY message. /// Specifies the virtual-key code of the hot key /// true if the function succeeds, otherwise false /// [DllImport("user32.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool RegisterHotKey(IntPtr hWnd, int id, uint fsModifiers, uint vk); [DllImport("user32.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool UnregisterHotKey(IntPtr hWnd, int id); [DllImport("user32.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool GetWindowInfo(IntPtr hwnd, ref WINDOWINFO pwi); [DllImport("user32.dll")] public static extern IntPtr SetWindowsHookEx(int idHook, HookProc lpfn, IntPtr hMod, uint dwThreadId); [DllImport("user32.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool UnhookWindowsHookEx(IntPtr hhk); [DllImport("user32.dll")] public static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode, IntPtr wParam, IntPtr lParam); #endregion user32.dll #region kernel32.dll [DllImport("kernel32.dll", CharSet = CharSet.Auto)] public static extern bool CreateProcess(string lpApplicationName, string lpCommandLine, ref SECURITY_ATTRIBUTES lpProcessAttributes, ref SECURITY_ATTRIBUTES lpThreadAttributes, bool bInheritHandles, uint dwCreationFlags, IntPtr lpEnvironment, string lpCurrentDirectory, [In] ref STARTUPINFO lpStartupInfo, out PROCESS_INFORMATION lpProcessInformation); [DllImport("kernel32.dll")] public static extern int ResumeThread(IntPtr hThread); [DllImport("kernel32.dll")] public static extern int SuspendThread(IntPtr hThread); [DllImport("kernel32.dll")] public static extern IntPtr OpenThread(ThreadAccess dwDesiredAccess, bool bInheritHandle, uint dwThreadId); [DllImport("kernel32.dll", CharSet = CharSet.Auto)] public static extern bool SetProcessWorkingSetSize(IntPtr handle, IntPtr min, IntPtr max); [DllImport("kernel32.dll", CharSet = CharSet.Auto)] public static extern ushort GlobalAddAtom(string lpString); [DllImport("kernel32.dll", CharSet = CharSet.Auto)] public static extern ushort GlobalDeleteAtom(ushort nAtom); [DllImport("kernel32.dll")] public static extern IntPtr GetModuleHandle(string lpModuleName); [DllImport("kernel32.dll", CallingConvention = CallingConvention.Winapi)] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool IsWow64Process([In] IntPtr hProcess, [Out] out bool lpSystemInfo); [DllImport("kernel32.dll", PreserveSig = false)] public static extern void RegisterApplicationRestart(string pwzCommandline, RegisterApplicationRestartFlags dwFlags); #endregion kernel32.dll #region gdi32.dll [DllImport("gdi32.dll")] public static extern bool BitBlt(IntPtr hdc, int nXDest, int nYDest, int nWidth, int nHeight, IntPtr hdcSrc, int nXSrc, int nYSrc, CopyPixelOperation dwRop); [DllImport("gdi32.dll")] public static extern IntPtr CreateCompatibleBitmap(IntPtr hdc, int nWidth, int nHeight); [DllImport("gdi32.dll")] public static extern IntPtr CreateCompatibleDC(IntPtr hdc); [DllImport("gdi32.dll")] public static extern IntPtr CreateDC(string lpszDriver, string lpszDevice, string lpszOutput, IntPtr lpInitData); [DllImport("gdi32.dll")] public static extern IntPtr CreateRectRgn(int nLeftRect, int nTopRect, int nReghtRect, int nBottomRect); [DllImport("gdi32.dll")] public static extern IntPtr CreateRoundRectRgn(int nLeftRect, int nTopRect, int nReghtRect, int nBottomRect, int nWidthEllipse, int nHeightEllipse); [DllImport("gdi32.dll")] public static extern bool DeleteDC(IntPtr hDC); [DllImport("gdi32.dll")] public static extern bool DeleteObject(IntPtr hObject); [DllImport("gdi32.dll")] public static extern IntPtr SelectObject(IntPtr hdc, IntPtr hgdiobj); [DllImport("gdi32.dll")] public static extern IntPtr CreateDIBSection(IntPtr hdc, [In] ref BITMAPINFOHEADER pbmi, uint pila, out IntPtr ppvBits, IntPtr hSection, uint dwOffset); [DllImport("gdi32.dll")] public static extern int GetDeviceCaps(IntPtr hdc, int nIndex); [DllImport("gdi32.dll")] public static extern uint GetPixel(IntPtr hdc, int nXPos, int nYPos); #endregion gdi32.dll #region gdiplus.dll [DllImport("gdiplus.dll", CharSet = CharSet.Unicode, ExactSpelling = true)] public static extern int GdipGetImageType(HandleRef image, out int type); [DllImport("gdiplus.dll", CharSet = CharSet.Unicode, ExactSpelling = true)] public static extern int GdipImageForceValidation(HandleRef image); [DllImport("gdiplus.dll", CharSet = CharSet.Unicode, ExactSpelling = true)] public static extern int GdipLoadImageFromFile(string filename, out IntPtr image); [DllImport("gdiplus.dll", CharSet = CharSet.Unicode, ExactSpelling = true)] public static extern int GdipDisposeImage(HandleRef image); [DllImport("gdiplus.dll")] public static extern int GdipWindingModeOutline(HandleRef path, IntPtr matrix, float flatness); #endregion gdiplus.dll #region shell32.dll [DllImport("shell32.dll")] public static extern IntPtr SHAppBarMessage(uint dwMessage, [In] ref APPBARDATA pData); [DllImport("shell32.dll", EntryPoint = "#727")] public extern static int SHGetImageList(int iImageList, ref Guid riid, ref IImageList ppv); [DllImport("shell32.dll", CharSet = CharSet.Auto)] public static extern IntPtr SHGetFileInfo(string pszPath, uint dwFileAttributes, ref SHFILEINFO psfi, uint cbFileInfo, uint uFlags); [DllImport("shell32.dll")] public static extern int SHOpenFolderAndSelectItems(IntPtr pidlFolder, int cild, IntPtr apidl, int dwFlags); [DllImport("shell32.dll")] public static extern void SHChangeNotify(HChangeNotifyEventID wEventId, HChangeNotifyFlags uFlags, IntPtr dwItem1, IntPtr dwItem2); [DllImport("shell32.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ILCreateFromPathW(string pszPath); [DllImport("shell32.dll")] public static extern void ILFree(IntPtr pidl); #endregion shell32.dll #region dwmapi.dll [DllImport("dwmapi.dll")] public static extern int DwmGetWindowAttribute(IntPtr hwnd, int dwAttribute, out RECT pvAttribute, int cbAttribute); [DllImport("dwmapi.dll")] public static extern int DwmGetWindowAttribute(IntPtr hwnd, int dwAttribute, out bool pvAttribute, int cbAttribute); [DllImport("dwmapi.dll")] public static extern int DwmGetWindowAttribute(IntPtr hwnd, int dwAttribute, out int pvAttribute, int cbAttribute); [DllImport("dwmapi.dll")] public static extern void DwmEnableBlurBehindWindow(IntPtr hwnd, ref DWM_BLURBEHIND blurBehind); [DllImport("dwmapi.dll", PreserveSig = false)] public static extern void DwmEnableComposition(CompositionAction uCompositionAction); [DllImport("dwmapi.dll")] public static extern int DwmExtendFrameIntoClientArea(IntPtr hwnd, ref MARGINS margins); [DllImport("dwmapi.dll", PreserveSig = false)] public static extern bool DwmIsCompositionEnabled(); [DllImport("dwmapi.dll")] public static extern int DwmSetWindowAttribute(IntPtr hwnd, int attr, ref int attrValue, int attrSize); [DllImport("dwmapi.dll")] public static extern int DwmQueryThumbnailSourceSize(IntPtr thumb, out SIZE size); [DllImport("dwmapi.dll")] public static extern int DwmRegisterThumbnail(IntPtr dest, IntPtr src, out IntPtr thumb); [DllImport("dwmapi.dll")] public static extern int DwmSetDxFrameDuration(IntPtr hwnd, uint cRefreshes); [DllImport("dwmapi.dll")] public static extern int DwmUnregisterThumbnail(IntPtr thumb); [DllImport("dwmapi.dll")] public static extern int DwmUpdateThumbnailProperties(IntPtr hThumb, ref DWM_THUMBNAIL_PROPERTIES props); #endregion dwmapi.dll #region winmm.dll [DllImport("winmm.dll", EntryPoint = "timeBeginPeriod")] public static extern uint TimeBeginPeriod(uint uMilliseconds); [DllImport("winmm.dll", EntryPoint = "timeEndPeriod")] public static extern uint TimeEndPeriod(uint uMilliseconds); [DllImport("winmm.dll", EntryPoint = "timeGetDevCaps")] public static extern uint TimeGetDevCaps(ref TimeCaps timeCaps, uint sizeTimeCaps); #endregion #region Other dll /// /// Copy a block of memory. /// /// /// Destination pointer. /// Source pointer. /// Memory block's length to copy. /// /// Return's the value of dst - pointer to destination. [DllImport("ntdll.dll", CallingConvention = CallingConvention.Cdecl)] public static extern int memcpy(int dst, int src, int count); /// /// Initialize the AVIFile library. /// [DllImport("avifil32.dll")] public static extern void AVIFileInit(); /// /// Exit the AVIFile library. /// [DllImport("avifil32.dll")] public static extern void AVIFileExit(); /// /// Open an AVI file. /// /// /// Opened AVI file interface. /// AVI file name. /// Opening mode (see ). /// Handler to use (null to use default). /// /// Returns zero on success or error code otherwise. [DllImport("avifil32.dll", CharSet = CharSet.Unicode)] public static extern int AVIFileOpen(out IntPtr aviHandler, string fileName, OpenFileMode mode, IntPtr handler); /// /// Release an open AVI stream. /// /// /// Open AVI file interface. /// /// Returns the reference count of the file. [DllImport("avifil32.dll")] public static extern int AVIFileRelease(IntPtr aviHandler); /// /// Get stream interface that is associated with a specified AVI file /// /// /// Handler to an open AVI file. /// Stream interface. /// Stream type to open. /// Count of the stream type. Identifies which occurrence of the specified stream type to access. /// /// [DllImport("avifil32.dll")] public static extern int AVIFileGetStream(IntPtr aviHandler, out IntPtr streamHandler, int streamType, int streamNumner); /// /// Create a new stream in an existing file and creates an interface to the new stream. /// /// /// Handler to an open AVI file. /// Stream interface. /// Pointer to a structure containing information about the new stream. /// /// Returns zero if successful or an error otherwise. [DllImport("avifil32.dll")] public static extern int AVIFileCreateStream(IntPtr aviHandler, out IntPtr streamHandler, ref AVISTREAMINFO streamInfo); /// /// Release an open AVI stream. /// /// /// Handle to an open stream. /// /// Returns the current reference count of the stream. [DllImport("avifil32.dll")] public static extern int AVIStreamRelease(IntPtr streamHandler); /// /// Set the format of a stream at the specified position. /// /// /// Handle to an open stream. /// Position in the stream to receive the format. /// Pointer to a structure containing the new format. /// Size, in bytes, of the block of memory referenced by format. /// /// Returns zero if successful or an error otherwise. [DllImport("avifil32.dll")] public static extern int AVIStreamSetFormat(IntPtr streamHandler, int position, ref BITMAPINFOHEADER format, int formatSize); /// /// Get the starting sample number for the stream. /// /// /// Handle to an open stream. /// /// Returns the number if successful or – 1 otherwise. [DllImport("avifil32.dll")] public static extern int AVIStreamStart(IntPtr streamHandler); /// /// Get the length of the stream. /// /// /// Handle to an open stream. /// /// Returns the stream's length, in samples, if successful or -1 otherwise. [DllImport("avifil32.dll")] public static extern int AVIStreamLength(IntPtr streamHandler); /// /// Obtain stream header information. /// /// /// Handle to an open stream. /// Pointer to a structure to contain the stream information. /// Size, in bytes, of the structure used for streamInfo. /// /// Returns zero if successful or an error otherwise. [DllImport("avifil32.dll", CharSet = CharSet.Unicode)] public static extern int AVIStreamInfo(IntPtr streamHandler, ref AVISTREAMINFO streamInfo, int infoSize); /// /// Prepare to decompress video frames from the specified video stream /// /// /// Pointer to the video stream used as the video source. /// Pointer to a structure that defines the desired video format. Specify NULL to use a default format. /// /// Returns an object that can be used with the function. [DllImport("avifil32.dll")] public static extern IntPtr AVIStreamGetFrameOpen(IntPtr streamHandler, ref BITMAPINFOHEADER wantedFormat); /// /// Prepare to decompress video frames from the specified video stream. /// /// /// Pointer to the video stream used as the video source. /// Pointer to a structure that defines the desired video format. Specify NULL to use a default format. /// /// Returns a GetFrame object that can be used with the function. [DllImport("avifil32.dll")] public static extern IntPtr AVIStreamGetFrameOpen(IntPtr streamHandler, int wantedFormat); /// /// Releases resources used to decompress video frames. /// /// /// Handle returned from the function. /// /// Returns zero if successful or an error otherwise. [DllImport("avifil32.dll")] public static extern int AVIStreamGetFrameClose(IntPtr getFrameObject); /// /// Return the address of a decompressed video frame. /// /// /// Pointer to a GetFrame object. /// Position, in samples, within the stream of the desired frame. /// /// Returns a pointer to the frame data if successful or NULL otherwise. [DllImport("avifil32.dll")] public static extern IntPtr AVIStreamGetFrame(IntPtr getFrameObject, int position); /// /// Write data to a stream. /// /// /// Handle to an open stream. /// First sample to write. /// Number of samples to write. /// Pointer to a buffer containing the data to write. /// Size of the buffer referenced by buffer. /// Flag associated with this data. /// Pointer to a buffer that receives the number of samples written. This can be set to NULL. /// Pointer to a buffer that receives the number of bytes written. This can be set to NULL. /// /// Returns zero if successful or an error otherwise. [DllImport("avifil32.dll")] public static extern int AVIStreamWrite(IntPtr streamHandler, int start, int samples, IntPtr buffer, int bufferSize, int flags, IntPtr samplesWritten, IntPtr bytesWritten); /// /// Retrieve the save options for a file and returns them in a buffer. /// /// /// Handle to the parent window for the Compression Options dialog box. /// Flags for displaying the Compression Options dialog box. /// Number of streams that have their options set by the dialog box. /// Pointer to an array of stream interface pointers. /// Pointer to an array of pointers to AVICOMPRESSOPTIONS structures. /// /// Returns TRUE if the user pressed OK, FALSE for CANCEL, or an error otherwise. [DllImport("avifil32.dll")] public static extern int AVISaveOptions(IntPtr window, int flags, int streams, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] IntPtr[] streamInterfaces, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] IntPtr[] options); /// /// Free the resources allocated by the AVISaveOptions function. /// /// /// Count of the AVICOMPRESSOPTIONS structures referenced in options. /// Pointer to an array of pointers to AVICOMPRESSOPTIONS structures. /// /// Returns 0. [DllImport("avifil32.dll")] public static extern int AVISaveOptionsFree(int streams, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] IntPtr[] options); /// /// Create a compressed stream from an uncompressed stream and a /// compression filter, and returns the address of a pointer to /// the compressed stream. /// /// /// Pointer to a buffer that receives the compressed stream pointer. /// Pointer to the stream to be compressed. /// Pointer to a structure that identifies the type of compression to use and the options to apply. /// Pointer to a class identifier used to create the stream. /// /// Returns 0 if successful or an error otherwise. [DllImport("avifil32.dll")] public static extern int AVIMakeCompressedStream(out IntPtr compressedStream, IntPtr sourceStream, ref AVICOMPRESSOPTIONS options, IntPtr clsidHandler); [DllImport("dnsapi.dll")] public static extern uint DnsFlushResolverCache(); #endregion Other dll } }