2006年6月24日

关闭计算机,重新启动计算机,注销

摘要: //关机if(AfxMessageBox("是否要关闭计算机?",MB_YESNO)==IDYES){HANDLE htoken;TOKEN_PRIVILEGES tkp;OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY,&htoken);LookupPrivilegeValue(NULL,SE... 阅读全文

posted @ 2006-06-24 08:40 路吾 阅读(576) 评论(0) 推荐(0)

创建状态栏

摘要: 1.在protected : CStatusBarCtrl m_wndStatusBar;2.在OnInitDialog(): m_wndStatusBar.Create(WS_CHILD|WS_VISIBLE|CCS_BOTTOM, CRect (0,0,0,0), this, 102);int strPartDim[4]= {150,300,-1}; m_wndStatusBar.SetPar... 阅读全文

posted @ 2006-06-24 07:45 路吾 阅读(310) 评论(0) 推荐(0)

设置窗体透明

摘要: //使窗体处于透明SetWindowLong(this->GetSafeHwnd(),GWL_EXSTYLE,GetWindowLong(this->GetSafeHwnd(),GWL_EXSTYLE)^0x80000);HINSTANCE hInst=LoadLibrary("User32.DLL");if(hInst){typedef BOOL(WINAPI *MYFUNC)(HW... 阅读全文

posted @ 2006-06-24 07:27 路吾 阅读(358) 评论(1) 推荐(0)

获得系统信息---用户名称.计算机名称,操作系统名称

摘要: //获得用户名称UpdateData();char username[MAX_PATH];CString strusername;DWORD Size=MAX_PATH;::GetUserName(username,&Size);strusername.Format("%s",username);m_username=strusername;UpdateData(false);//----... 阅读全文

posted @ 2006-06-24 07:26 路吾 阅读(738) 评论(0) 推荐(0)

vc打开chm格式的帮助文件

摘要: ShellExecute(NULL, "open", "tcgdkehu.chm", NULL, NULL, SW_SHOWNORMAL);//打开指定的文件注意:tcgdkehu为帮助文件名。 阅读全文

posted @ 2006-06-24 07:20 路吾 阅读(1814) 评论(3) 推荐(0)

获得本计算机的名字和IP地址

摘要: WORD wVersionRequested; WSADATA wsaData; char name[255]; CString ip; PHOSTENT hostinfo; wVersionRequested = MAKEWORD( 2, 0 ); if ( WSAStartup( wVersionRequested, &wsaData ) == 0 ) { if( gethostnam... 阅读全文

posted @ 2006-06-24 07:19 路吾 阅读(466) 评论(1) 推荐(0)

按钮添加图标

摘要: 1.将按钮->属性->类型->图标2.设置按钮变量:在class wizard里CButton m_ok3.添加一个图标IDI_ICON1;4.在protected 下声明: HICON m_hIcon1;5.在程序的OnInitDialog()里: m_hIcon1 = AfxGetApp()->LoadIcon(IDI_ICON1); m_ok.SetIcon(m_hI... 阅读全文

posted @ 2006-06-24 07:00 路吾 阅读(561) 评论(0) 推荐(0)

获得鼠标移动的坐标

摘要: 在OnMouseMove(UINT nFlags, CPoint point) 事件里 CString str; str.Format("鼠标位置x=%d:y=%d",point.x,point.y); SetWindowText(str); //在标题栏显示鼠标坐标 GetDlgItem(IDC_STATIC1)->SetWindowText(str); 阅读全文

posted @ 2006-06-24 06:52 路吾 阅读(451) 评论(0) 推荐(0)

设置系统启动时程序自动运行

摘要: UpdateData(true);const TCHAR gcszAutoRunKey[]= _T( "Software\\microsoft\\windows\\currentversion\\run" );const TCHARgcszWindowClass[] = _T("我的程序");//设置开机程序自启动键值位置和其下新建子键值(可设为程序名)HKEY hKey;LONG lRet, l... 阅读全文

posted @ 2006-06-24 06:44 路吾 阅读(898) 评论(0) 推荐(0)

让程序窗口总是在最前面

摘要: UpdateData(true);if(m_bTopMost){AfxGetMainWnd()->SetWindowPos(&CWnd::wndTopMost,0,0,0,0,SWP_NOSIZE | SWP_NOMOVE);m_bTopMost=true;}else{AfxGetMainWnd()->SetWindowPos(&CWnd::wndNoTopMost ,... 阅读全文

posted @ 2006-06-24 06:38 路吾 阅读(976) 评论(0) 推荐(0)

导航