
- •Int pascal WinMain (hinstance hInst, hinstance hPreInst,
- •If(!hPreInst)
- •Int pascal WinMain (hinstance hInst, hinstance hPreInst,
- •If(!hPreInst)
- •ValidateRect(hWnd, null);
- •ValidateRect(hWnd, null);
- •ValidateRect(hWnd, null);
- •If(!hPreInst) {
- •If(!hPreInst){
- •ValidateRect(hWnd, null);
- •If(!hPreInst){
- •ValidateRect(hWnd, null);
- •If(!hPreInst){
- •If(!hPreInst){
- •ValidateRect(hWnd, null);
- •If(!hPreInst){
- •ValidateRect(hWnd, null);
- •If(!hPreInst){
- •ValidateRect(hWnd, null);
- •If(!hPreInst){
- •// Resource.H
- •If(!hPreInst)
If(!hPreInst){
///…
wcApp.lpszMenuName = MAKEINTRESOURCE(IDR_MENU1);
///…
if(!RegisterClass(&wcApp))
///…
}
hWnd = CreateWindow((LPCWSTR)szProgName, (LPCWSTR)_T("System Information"),
WS_OVERLAPPEDWINDOW, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT,(HWND)NULL,
(HMENU)NULL, (HINSTANCE)hInst,(LPSTR)NULL);
///…
while(GetMessage(&lpMsg, NULL, 0, 0)){
///…
}
///…
}
LRESULT CALLBACK WINAPI WndProc(HWND hWnd, UINT messg,
WPARAM wParam, LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
SYSTEMTIME st;
RECT rc;
WORD month, day, year, hrs, mins, secs, msec;
WORD wMainver, wFracver;
DWORD dVer;
unsigned long lpSectorsPerCluster,lpBytesPerSector,
lpNumberOfFreeClusters, lpTotalNumberOfClusters,
lTemp;
char lpszCurDir[MAX_PATH];
switch(messg){
case WM_COMMAND:
#ifdef _WIN32
switch(LOWORD(wParam)){
#else
switch(wParam){
#endif
case IDM_TDS:
GetDiskFreeSpace(NULL, &lpSectorsPerCluster,
&lpBytesPerSector, &lpNumberOfFreeClusters,
&lpTotalNumberOfClusters);
lTemp = lpSectorsPerCluster;
lTemp *= lpBytesPerSector;
lTemp *= lpTotalNumberOfClusters;
swprintf(szMessage,
L"Total С Drive Disk Space: %ld",
lTemp);
break;
case IDM_FDS:
GetDiskFreeSpace(NULL, &lpSectorsPerCluster,
&lpBytesPerSector, &lpNumberOfFreeClusters,
&lpTotalNumberOfClusters);
lTemp = lpSectorsPerCluster;
lTemp *= lpBytesPerSector;
lTemp *= lpNumberOfFreeClusters;
swprintf(szMessage,
L"Total С Drive Free Space: %ld",
lTemp);
break;
case IDM_DD:
GetCurrentDirectory(MAX_PATH, (LPWSTR)lpszCurDir);
swprintf(szMessage,
L"Current Directory: %s",
lpszCurDir);
break;
case IDM_WV:
dVer = GetVersion() ;
wFracver = (WORD)dVer >> 8;
wMainver = (WORD)dVer & 255;
swprintf(szMessage,
L"Windows Version Number: %d.%d",
wMainver, wFracver);
break;
case IDM_DATE:
GetSystemTime(&st);
year = st.wYear;
month = st.wMonth;
day = st.wDay;
swprintf(szMessage,
L"Current Date: %d/%d/%d",
month, day, year);
break;
case IDM_TIME:
GetSystemTime(&st); //Coordinated Universal Time
hrs = st.wHour;
mins = st.wMinute;
secs = st.wSecond;
msec = st.wMilliseconds;
swprintf(szMessage,
L"Current Time: %d:%d:%d:%d",
hrs, mins, secs, msec);
break;
default:
break;
}
InvalidateRect(hWnd, NULL, TRUE);
break;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
//-----Начало фрагмента пользователя-----
rc.left=10;
rc.top=10;
rc.right=1024;
rc.bottom=30;
DrawText(hdc, szMessage, wcslen(szMessage), &rc, DT_EXPANDTABS);
//-----Конец фрагмента пользователя-----
///…
break;
case WM_DESTROY:
///…
break;
default:
///…
}
return(0);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// menu4.cpp
// resource.h
///…
//
#define IDR_MENU1 101
#define IDM_AFILES 40001
#define IDM_BFILES 40002
#define IDM_CFILES 40003
#define IDM_DFILES 40004
// menu4.cpp
// menu4.rc
/////////////////////////////////////////////////////////////////////////////
//
// Menu
//
IDR_MENU1 MENU
BEGIN
POPUP "&Directory_Information"
BEGIN
MENUITEM "Directory A:", 40001
MENUITEM "Directory B:", 40002
MENUITEM "Directory C:", 40003
MENUITEM "Directory D:", 40004
END
END
// menu4.cpp
// menu4.cpp
// Использование меню для получения информации о содержимом
// каталогов дисков А, В, С или D.
//
///…
#include "resource.h"
#define SCROLLLINES 50
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
char szProgName[] = "ProgName";
char szApplName[] = "IDR_MENU1";
wchar_t szMessage[44];
WCHAR szMyfile[10] = L"";
int sLength;
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPreInst,
LPSTR lpszCmdLine,int nCmdShow)
{
///…