//第一种
MessageBox(NULL, TEXT("申请空间失败。"), NULL, MB_ICONINFORMATION | MB_YESNO);
MessageBox(NULL, dm.Ver(), TEXT("提示:"), NULL);
//第二种
MessageBox(_T("你好,世界!!!"), _T("提示:"), MB_OK);
//第三种 --来自MFC
AfxMessageBox(L"登陆成功!!!", 0, 0);
AfxMessageBox(L"登陆成功!!!");
//第一种
TRACE("F:%dn", 1);
//第二种
OutputDebugString(L"1n");
//第一种
m_btnQuit.EnableWindow(FALSE);//禁用按钮
//第二种
((CButton*)GetDlgItem(按钮ID))->EnableWindow(FALSE) //禁用按钮
#include <thread>
//例
std::thread ThreadGodShoot(&ClassName::FunName, this);
ThreadGodShoot.detach();
//如
void FunName(int i,int j);
//则
std::thread ThreadGodShoot(&ClassName::FunName, this,1,2);
ThreadGodShoot.detach();
//或
std::thread ThreadGodShoot(FunName);
ThreadGodShoot.detach();
右键【工程名称】选择【属性】->【配置属性】->【链接器】->【清单文件】->【UAC执行级别】
#include <tlhelp32.h>
//
DWORD findPidByName(wchar_t * pname)
{
HANDLE h;
PROCESSENTRY32 procSnapshot;
h = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
procSnapshot.dwSize = sizeof(PROCESSENTRY32);
do
{
if (!_wcsicmp(procSnapshot.szExeFile, pname))
{
//
DWORD pid = procSnapshot.th32ProcessID;
//
CloseHandle(h);
//
return pid;
}
} while (Process32Next(h, &procSnapshot));
CloseHandle(h);
return 0;
}
//
dwProcessId = findPidByName(L"XXX.exe");
//
if (dwProcessId == 0)
{
}
if ((GetKeyState(VK_RBUTTON) & 0x100) != 0)
{
}
//
LPCSTR filename="jojo";
//
CA2W(filename);
//例
screenCapturePart(900, 490, 120, 110, "this.bmp");
//
bool screenCapturePart(int x, int y, int w, int h, LPCSTR fname)
{
HDC hdcSource = GetDC(NULL);
HDC hdcMemory = CreateCompatibleDC(hdcSource);
int capX = GetDeviceCaps(hdcSource, HORZRES);
int capY = GetDeviceCaps(hdcSource, VERTRES);
HBITMAP hBitmap = CreateCompatibleBitmap(hdcSource, w, h);
HBITMAP hBitmapOld = (HBITMAP)SelectObject(hdcMemory, hBitmap);
BitBlt(hdcMemory, 0, 0, w, h, hdcSource, x, y, SRCCOPY);
hBitmap = (HBITMAP)SelectObject(hdcMemory, hBitmapOld);
DeleteDC(hdcSource);
DeleteDC(hdcMemory);
HPALETTE hpal = NULL;
if (saveBitmap(fname, hBitmap, hpal)) return true;
return false;
}
//
bool saveBitmap(LPCSTR filename, HBITMAP bmp, HPALETTE pal)
{
bool result = false;
PICTDESC pd;
pd.cbSizeofstruct = sizeof(PICTDESC);
pd.picType = PICTYPE_BITMAP;
pd.bmp.hbitmap = bmp;
pd.bmp.hpal = pal;
LPPICTURE picture;
HRESULT res = OleCreatePictureIndirect(&pd, IID_IPicture, false,
reinterpret_cast<void**>(&picture));
if (!SUCCEEDED(res))
return false;
LPSTREAM stream;
res = CreateStreamOnHGlobal(0, true, &stream);
if (!SUCCEEDED(res))
{
picture->Release();
return false;
}
LONG bytes_streamed;
res = picture->SaveAsFile(stream, true, &bytes_streamed);
HANDLE file = CreateFile(CA2W(filename), GENERIC_WRITE, FILE_SHARE_READ, 0,CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
if (!SUCCEEDED(res) || !file)
{
stream->Release();
picture->Release();
return false;
}
HGLOBAL mem = 0;
GetHGlobalFromStream(stream, &mem);
LPVOID data = GlobalLock(mem);
DWORD bytes_written;
result = !!WriteFile(file, data, bytes_streamed, &bytes_written, 0);
result &= (bytes_written == static_cast<DWORD>(bytes_streamed));
GlobalUnlock(mem);
CloseHandle(file);
stream->Release();
picture->Release();
return result;
}
//
int i = 1;
//
wchar_t buffer[256];
wsprintfW(buffer, L"%dn", i);
//
OutputDebugString(buffer);
//无成员变量
((CButton*)GetDlgItem(IDC_GodPower))->EnableWindow(FALSE);
((CButton*)GetDlgItem(IDC_GodPower))->SetWindowText(L"XXX");
//成员变量
m_btnQuit.EnableWindow(FALSE);
//启动
SetTimer(1,1000,NULL);//定时器ID,定时间隔,略
//关闭
KillTimer(1);
void Cxxx::OnTimer(UINT_PTR nIDEvent)
{
//
...
//
CDialogEx::OnTimer(nIDEvent);
}
1.win32指所有的32bit的平台,而x86仅仅是指Intel和AMD的32bit平台。
2.比如32bit的ARM平台,就包含在win32中,不在x86的范围中。
3.偶然调试一个win32项目的大漠插件vc++demo,移植到x86项目中报错,用了一天调试没有成功,后将该x86项目改为win32项目,移植成功。
- 【大漠插件】中的【FindColor】等函数在【VC++】中的坑:
//正确
VARIANT intX;
VARIANT intY;
int dm_ret = dm.FindColor(0, 0, 1920, 1080, _T("00ff00-505050"), 1.0, 0, &intX, &intY);
//错误
VARIANT* intX = 0;
VARIANT* intY = 0;
int dm_ret = dm.FindColor(0, 0, 1920, 1080, _T("00ff00-505050"), 1.0, 0, intX, intY);
//取值
intX.intVal;
intY.intVal;
//
int horizontal = 0;
int vertical = 0;
//
GetDesktopResolution(horizontal, vertical);
//
wchar_t buffer[256];
wsprintfW(buffer, L"%d %dn", horizontal, vertical);
//
OutputDebugString(buffer);
void GetDesktopResolution(int& horizontal, int& vertical)
{
RECT desktop;
// Get a handle to the desktop window
const HWND hDesktop = GetDesktopWindow();
// Get the size of screen to the variable desktop
GetWindowRect(hDesktop, &desktop);
// The top left corner will have coordinates (0,0)
// and the bottom right corner will have coordinates
// (horizontal, vertical)
horizontal = desktop.right;
vertical = desktop.bottom;
}
m_btnGodPower.IsWindowEnabled() == TRUE