char* szFileName = “C://EnochShen.exe”; DWORD dwSize = GetFileVersionInfoSize(szFileName,NULL); LPVOID pBlock = malloc(dwSize); GetFileVersionInfo(szFileName,0,dwSize,pBlock); char* pVerValue = NULL; UINT nSize = 0; VerQueryValue(pBlock,TEXT(“//VarFileInfo//Translation”), (LPVOID*)&pVerValue,&nSize); CString strSubBlock,strTranslation,strTemp; strTemp.Format(“0...
代码集锦阅读全文
HKEY hKey; char szFileName[256]; GetModuleFileName(NULL,szFileName,256); RegOpenKey(HKEY_LOCAL_MACHINE,”SOFTWARE//Microsoft//windows//currentversion//run”,&hKey); if(m_bAutoRun) { RegSetValueEx(hKey,”RunmeAtStartup”,0,REG_SZ,(BYTE *)szFileName,sizeof(szFileName)); } else { RegDeleteValue(hKey,”RunmeAtStartup”); } RegCloseKey(hKey);
代码集锦阅读全文
使用WH_CALLWNDPROC类型钩子,回调函数如下:
LRESULT CALLBACK MyProc(int code, WPARAM wParam, LPARAM lParam) { switch (((CWPSTRUCT*)lParam)->message) { case WM_QUERYENDSESSION: { switch( ((CWPSTRUCT*)lParam)->lParam ) { case ENDSESSION_LOGOFF: { FILE *pFile = NULL; ((CWPSTRUCT*)lParam)->message = 0; AfxMessageBox(TEXT(“log off”)); return 0; } b...
代码集锦阅读全文
int IsDirectoryOrFile(CString strFileName) { strFileName.TrimLeft(); strFileName.TrimRight(); WIN32_FIND_DATA fd; HANDLE hFind = ::FindFirstFile(strFileName,&fd); ::FindClose(hFind); //不存在同名的文件或文件夹 if (hFind == INVALID_HANDLE_VALUE) { return 0 ; } //判断是否为目录 else if (fd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) { return 2 ;...
代码集锦阅读全文
1.Windows API调用 int width = GetSystemMetrics ( SM_CXSCREEN ); int height= GetSystemMetrics ( SM_CYSCREEN ); 如果想动态自适应分辨率的变化,处理WM_DISPLAYCHANGE消息.
2.获得分辨率 BOOL EnumDisplaySettings( LPCTSTR lpszDeviceName, // display device DWORD iModeNum, // graphics mode LPDEVMODE lpDevMode // graphics mode settings );
改变分辨率 LONG ChangeDisplaySett...
UI界面, 代码集锦阅读全文
这段代码太好了,跟大家一起分享它。
//左上角到右下角画直线. // //caimouse 2007/02/11 // bool CSurface::LeftTopToRightBottom(int nXStart,int nYStart,int nDeltaX,int nDeltaY) { // int nDelta = CNOS_NS::Max(nDeltaX,nDeltaY);
//计算判断符号,除2. int nError = nDelta>>1;
// if (nDeltaX < nDeltaY) { for (int i = 0; i < nDelta; i++) { ...
代码集锦阅读全文