| 确定Windows和windows系统目录 有两个SDK函数可以完成该功能。GetWindowsDirectory和GetSystemDirectory,下例说明了如何使用这两个函数: TCHAR szDir [MAX_PATH]; //Get the full path of the windows directory. :: GetWindowsDirectory (szDir, MAX_PATH); TRACE ("Windows directory %s\n", szDir); //Get the full path of the windows system directory. :: GetSystemDirectory (szDir, MAX_PATH); TRACE ("Windows system directory %s\n", szDir); ********************************************************************************** 让程序从CTRL+ATL+DEL消失 使用Win32 API函数RegisterServiceProcess这里我们使用了汇编。 #include <windows.h> HINSTANCE hLibrary; void *regproc; void CADInit(void); void HideApp(void); void ShowApp(void); void CADClean(void); int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { CADInit(); //加载 DLL 并创建一指向它指针 HideApp(); //隐藏程序 //ShowApp(); //显示程序 //其他处理或调用 CADClean(); //卸载 DLL return 0; //retrun 0 因为没有进入消息循环 } void CADInit(void) { //加载 kernel32.dll hLibrary = LoadLibrary("kernel32.dll"); //获取函数RegisterServiceProcess的地址 regproc = GetProcAddress(hLibrary, "RegisterServiceProcess"); } void HideApp(void) { //实现程序的隐藏 __asm { push 1 push 0 call regproc } return; } void ShowApp(void) { //恢复状态 __asm { push 0 push 0 call regproc } return; } void CADClean(void) { //卸载 DLL FreeLibrary(hLibrary); return; } 本程序在W2K和Win9x测试通过。 *********************************************************************************************
程序自杀(进程自己结束自己) HMODULE module = GetModuleHandle(0); CHAR buf[MAX_PATH]; GetModuleFileName(module, buf, sizeof buf); CloseHandle(HANDLE(4)); _ [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] ... 下一页 >>
|