在win32下與HMODULE是相同的東西,在Win32下還存在主要是因為win16
基本介紹
- 外文名:HINSTANCE
- 類型:“句柄型”數據類型
定義
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst, LPSTR lpszCmdLine, int nCmdShow){ //這裡放API主程式內容 if(!InitWindowsClass(hInstance)) return FALSE; if(!InitWindows(hInstance, nCmdShow)) return FALSE; ShowWindow(hWndMain, nCmdShow); ....}BOOL InitWindowsClass(HINSTANCE hInstance){ WNDCLAS Swndclass; .... wndclass.hIcon = LoadIcon(hInstance, "abcd.ico"); wndclass.hInstance = hInstance; .....}//子程式:BOOL InitWindows(HINSTANCEh Instance, int nCmdShow){ HWND hWnd; .... hWnd = CreateWindow("WindowsFill", str, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL); ....}區別
int LoadString(HINSTANCE hInstance,UINT uID,LPTSTR lpBuffer,int nBufferMax);
//second.cpp:定義應用程式的入口點。//////第2個例子//吳新2008/01/06#include"stdafx.h"#include"second.h"intAPIENTRY_tWinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPTSTR lpCmdLine,int nCmdShow){const int BUFSIZE=256;TCHAR wAppTitle[BUFSIZE];//初始化全局字元串LoadString(hInstance,IDS_APP_TITLE,wAppTitle,BUFSIZE);//獲取桌面句柄HWND hWnd=GetDesktopWindow();//將wAppTitle顯示在訊息視窗中MessageBox(hWnd,wAppTitle,_T("第2個例子"),MB_OK);return0;}
