VC notes

xiaoxiao2021-04-04  248

1. Open the environment variable of VS.NET2003 CMD window% COMSPEC% / K "C: / Program Files / Microsoft Visual Studio .NET 2003 / Common7 / Tools / vsvars32.bat" Cl-C Test.cpplink test.obj / OUT : test.exenmake: Compile the program according to Makefile

2. Directly declare compilation options in the source file #pragma Comment (lib, "gdiplus.lib") // Develop link library file #pragma Comment (Linker, "/ subsystem: windows") # Pragma Comment (Linker, "/ NodeFaultlib ") #pragma overce

3, setProcessWorkingsetSize (getCurrentProcess (), - 1, -1); minimize procedure occupied memory

4, the program hangs: SLEEP (Infinite);

5. Simple Win32 program, do not windows: #include __ stdcall WinMain (Hinstance Hinstance, Hinstance Hprevinstance, LPSTR LPCMDLINE, INT NCMDSHOW) {Sleep (Infinite); Return 0;}

6, minimum volume of WIN32 program: (do not compile the default library) #pragma Comment (Linker, "/ subsystem: windows") # Pragma Comment (Linker, "/ Nodefaultlib") Int WinMainCrtStartup () {return 0;}

7. Use Notepad to output debugging information, more convenient for debugging DLLs Const Char maintitle [] = "No title - Notepad"; lpctstr str = "test test test"; hwnd h = :: FindWindow (null, MAINTITE); :: Senddlgitemmessage (H, 0xF, EM_REPLACESEL, 0, LPARAM (STR));

8, only allowed to run an instance lpctstr myatom = "logcmd by Monklong"; atom atom = globalfindatom (myatom! = 0) Return 0; GlobalAddatom (Myatom); // main processGlobalDeleTom (Atom); // Program Exit Delete Atom, otherwise you can't clear the global Atom

9. In addition to the global sharing data: The main program is added: (Note must be initialized) #pragma data_seg ("my_data_seg") hHOOK hHOOK = NULL; hinstance hinstance = null; static char logbuf [size_buffer] = {0}; # Pragma data_seg () DEF file Add: SectionsMY_DATA_SEG READ WRITE SHARED

转载请注明原文地址:https://www.9cbs.com/read-131901.html

New Post(0)