Windows API


[kernel32.dll]
DWORD
GetPrivateProfileString(
LPCTSTR lpAppName,
LPCTSTR lpKeyName,
LPCTSTR lpDefault,
LPTSTR lpReturnedString,
DWORD nSize,
LPCTSTR lpFileName
);

int WideCharToMultiByte(
UINT
CodePage, // code page
DWORD dwFlags, // performance and mapping flags
LPCWSTR lpWideCharStr, // wide-character string
int cchWideChar, // number of chars in string.
LPSTR lpMultiByteStr, // buffer for new string
int cbMultiByte, // size of buffer
LPCSTR lpDefaultChar, // default for unmappable chars
LPBOOL lpUsedDefaultChar // set when default char used
);

int MultiByteToWideChar(
UINT
CodePage, // code page
DWORD dwFlags, // character-type options
LPCSTR lpMultiByteStr, // string to map
int cbMultiByte, // number of bytes in string
LPWSTR lpWideCharStr, // wide-character buffer
int cchWideChar // size of buffer
);

BOOL QueryPerformanceFrequency( // us级, High-Resolution Timer
LARGE_INTEGER lpFrequency
);
BOOL QueryPerformanceCounter(
LARGE_INTEGER
lpPerformanceCount
);
DWORD GetTickCount(void); // ms级

BOOL GetDiskFreeSpace(
LPCTSTR lpRootPathName,
LPDWORD lpSectorsPerCluster,
LPDWORD lpBytesPerSector,
LPDWORD lpNumberOfFreeClusters,
LPDWORD lpTotalNumberOfClusters
);
eg:GetDiskFreeSpace("C:\",&Sectors,&Bytes,&Free,&Total);


BOOL WINAPI AllocConsole(void);


[PSAPI.DLL]
BOOL EnumProcesses(
DWORD pProcessIds,
DWORD cb,
DWORD pBytesReturned
);

BOOL EnumProcessModules(
HANDLE hProcess,
HMODULE lphModule,
DWORD cb,
LPDWORD lpcbNeeded
);

DWORD GetModuleFileNameEx(
HANDLE hProcess,
HMODULE hModule,
LPTSTR lpFilename,
DWORD nSize
);


[Dbghelp.dll]
PVOID
ImageDirectoryEntryToDataEx(
PVOID Base,
BOOLEAN MappedAsImage,
USHORT DirectoryEntry,
PULONG Size,
PIMAGE_SECTION_HEADER FoundHeader
);



[user32.dll]
BOOL CClipboard::SetText(LPCTSTR lpszBuffer)
{
BOOL bSuccess = FALSE;

// First, open the clipboard. OpenClipboard() takes one
// parameter, the handle of the window that will temporarily
// be it’s owner. If NULL is passed, the current process
// is assumed. After opening, empty the clipboard so we
// can put our text on it.
if (::OpenClipboard(NULL))
{
::EmptyClipboard();

// Get the size of the string in the buffer that was
// passed into the function, so we know how much global
// memory to allocate for the string.
int nSize = (int)_tcslen(lpszBuffer);

// Allocate the memory for the string.
HGLOBAL hGlobal = ::GlobalAlloc(GMEM_ZEROINIT, (nSize+1)*sizeof(TCHAR));

// If we got any error during the memory allocation,
// we have been returned a NULL handle.
if (hGlobal)
{
// Now we have a global memory handle to the text
// stored on the clipboard. We have to lock this global
// handle so that we have access to it.
LPTSTR lpszData = (LPTSTR) ::GlobalLock(hGlobal);

if (lpszData)
{
// Now, copy the text from the buffer into the allocated
// global memory pointer
_tcscpy(lpszData, lpszBuffer);

// Now, simply unlock the global memory pointer,
// set the clipboard data type and pointer,
// and close the clipboard.
::GlobalUnlock(hGlobal);
#ifdef _UNICODE
::SetClipboardData(CF_UNICODETEXT, hGlobal);
#else
::SetClipboardData(CF_TEXT, hGlobal);
#endif
bSuccess = TRUE;
}
}
::CloseClipboard();
}

return bSuccess;
}

BOOL FlashWindow(
HWND hWnd,
BOOL bInvert
);

BOOL WINAPI ExitWindowsEx(
UINT uFlags, // EWX_LOGOFF、EWX_SHUTDOWN、EWX_REBOOT
DWORD dwReason
);

BOOL SetWindowPos(HWND hWnd,
HWND hWndInsertAfter, // HWND_BOTTOM、HWND_NOTOPMOST、HWND_TOP、HWND_TOPMOST
int X,
int Y,
int cx,
int cy,
UINT uFlags
);
uFlags:
  SWP_FRAMECHANGED 发送一条WM_NCCALCSIZE消息进入窗口,即使窗口的大小没有发生改变。如果不指定这个参数,消息WM_NCCALCSIZE只有在窗口大小发生改变时才发送
  SWP_HIDEWINDOW 隐藏窗口
  SWP_NOACTIVATE 不激活窗口
  SWP_NOCOPYBITS 屏蔽客户区域
  SWP_NOMOVE 保持当前位置(X和Y参数将被忽略)
  SWP_NOOWNERZORDER 不改变所有窗口的位置和排列顺序
  SWP_NOREDRAW 窗口不自动重画
  SWP_NOREPOSITION 与SWP_NOOWNERZORDER标记相同
  SWP_NOSENDCHANGING 防止这个窗口接受WM_WINDOWPOSCHANGING消息
  SWP_NOSIZE 保持当前大小(cx和cy会被忽略)
  SWP_NOZORDER 保持窗口在列表的当前位置(hWndInsertAfter将被忽略)
  SWP_SHOWWINDOW 显示窗口


[shell32.dll, shellapi.h]
HINSTANCE ShellExecute(HWND hwnd,
LPCTSTR lpOperation,
LPCTSTR lpFile,
LPCTSTR lpParameters,
LPCTSTR lpDirectory,
INT nShowCmd
);
eg:
ShellExecute(Handle,NULL,"http://fdlweb.myrice.com/",NULL,NULL,SW_SHOWNORMAL);
ShellExecute(Handle,NULL,"mailto:fdlweb@sina.com",NULL,NULL,SW_SHOWNORMAL);
ShellExecute(handle, NULL, <fully_qualified_path_to_folder>, NULL, NULL, SW_SHOWNORMAL);


[gdi32.dll]

BOOL BitBlt(
HDC hdcDest, // handle to destination DC
int nXDest, // x-coord of destination upper-left corner
int nYDest, // y-coord of destination upper-left corner
int nWidth, // width of destination rectangle
int nHeight, // height of destination rectangle
HDC hdcSrc, // handle to source DC
int nXSrc, // x-coordinate of source upper-left corner
int nYSrc, // y-coordinate of source upper-left corner
DWORD dwRop // raster operation code
);
eg: BitBlt(hdc,0,0,Screen->Width,Screen->Height,GetDC(0),0,0,SRCCOPY); //draw desktop screen