CFILER.C
资源名称:MSDN_VC98.zip [点击查看]
上传用户:bangxh
上传日期:2007-01-31
资源大小:42235k
文件大小:41k
源码类别:
Windows编程
开发平台:
Visual C++
- /******************************************************************************
- * This is a part of the Microsoft Source Code Samples.
- * Copyright 1996-1997 Microsoft Corporation.
- * All rights reserved.
- * This source code is only intended as a supplement to
- * Microsoft Development Tools and/or WinHelp documentation.
- * See these sources for detailed information regarding the
- * Microsoft samples programs.
- ******************************************************************************/
- // CFILER.C
- #include "cfiler.h"
- #include "time.h"
- HANDLE ghModule;
- HANDLE ghDrvThread = NULL;
- HWND ghwndMain = NULL;
- HWND ghwndDrives;
- HWND ghwndDrv;
- HWND ghFocusWnd;
- HFONT ghFont;
- HMENU ghMenu;
- BOOL gfDrvWndOrient = SIDE_BY_SIDE,
- gfKeepCommandWin = FALSE;
- DRVCHILDINFO gDrvChildInfo;
- LPDINFO glpDrives = (LPDINFO)0;
- CRITICAL_SECTION gDrvCS;
- extern LPTSTR lpDriveStrings;
- extern ALG_ID AlgidEncrypt;
- extern ALG_ID AlgidSign;
- extern CHAR sPass[BUF_SIZE];
- extern TCHAR szPassName[BUF_SIZE];
- int WINAPI WinMain(HINSTANCE hInstance,
- HINSTANCE hPrevInstance,
- LPSTR lpCmdLine,
- INT nCmdShow) {
- MSG msg;
- HANDLE hAccel;
- ghModule = hInstance;
- if (!InitializeApp()) {
- ErrorMsg(TEXT("WinMain: InitializeApp failed."));
- return 0;
- }
- ShowWindow(ghwndMain, nCmdShow);
- if (!(hAccel = LoadAccelerators (ghModule, MAKEINTRESOURCE(ACCEL_ID))))
- ErrorMsg(TEXT("WinMain: LoadAccelerators failed."));
- while (GetMessage(&msg, NULL, 0, 0)) {
- if( !TranslateAccelerator(ghwndMain, hAccel, &msg) ) {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- }
- return 1;
- UNREFERENCED_PARAMETER(lpCmdLine);
- UNREFERENCED_PARAMETER(hPrevInstance);
- }
- BOOL InitializeApp(void)
- {
- WNDCLASS wc;
- HWND FirsthWnd, FirstChildhWnd;
- if (FirsthWnd = FindWindow("CRYPTFILERClass", NULL))
- {
- // Found another running application with the same class name.
- // Therefore, one instance is already running.
- FirstChildhWnd = GetLastActivePopup(FirsthWnd);
- BringWindowToTop(FirsthWnd); // bring main window to top
- if (FirsthWnd != FirstChildhWnd)
- BringWindowToTop(FirstChildhWnd); // a pop-up window is active
- // bring it to the top too
- return FALSE; // do not run second instance
- }
- srand(time(0));
- lstrcpy(szPassName, TEXT("