typedef int (CALLBACK *SHUTDOWNDLG)(int); //显示关机对话框函数的指针
HINSTANCE hInst = LoadLibrary("shell32.dll"); //装入shell32.dll
SHUTDOWNDLG ShutDownDialog; //指向shell32.dll库中显示关机对话框函数的指针
if(hInst != NULL)
{
}
二、关闭计算机
OSVERSIONINFO OsVersionInfo; //包含操作系统版本信息的数据结构
OsVersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&OsVersionInfo); //获取操作系统版本信息
if(OsVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)
{
}
三、打开CD-ROM
mciSendString("Set cdAudio door open wait",NULL,0,NULL);
四、关闭CD_ROM
mciSendString("Set cdAudio door closed wait",NULL,0,NULL);
五、枚举所有字体
LOGFONT lf;
lf.lfCharSet = DEFAULT_CHARSET; // Initialize the LOGFONT structure
strcpy(lf.lfFaceName,"");
CClientDC dc (this);
// Enumerate the font families
::EnumFontFamiliesEx((HDC) dc,&lf, (FONTENUMPROC) EnumFontFamProc,(LPARAM) this,0);
//枚举函数
int CALLBACK EnumFontFamProc(LPENUMLOGFONT lpelf,
{
}
//其中m_ctlFontList是一个列表控件变量
/// 方法二:使用GDIPlus获取系统已经安装的字体,
/// 与方法一的结果有一些区别,其字体类型数量可能较少
InstalledFontCollection InstalledFont;
int iFontCount = InstalledFont.GetFamilyCount();
FontFamily* pInstalledFontFamilies = new FontFamily[iFontCount];
int numFamilies = 0;
InstalledFont.GetFamilies(iFontCount, pInstalledFontFamilies, &numFamilies);
ASSERT(iFontCount == numFamilies);
FontFamily* pFontFamilies = pInstalledFontFamilies;
for(int i = 0;i < iFontCount; ++i)
{
}
delete []pInstalledFontFamilies;
七、得到当前鼠标所在位置
CPoint pt;
GetCursorPos(&pt); //得到位置
八、获取可执行文件的图标
HICON hIcon=::ExtractIcon(AfxGetInstanceHandle(),_T("NotePad.exe"),0);
if (hIcon &&hIcon!=(HICON)-1)
{
DestroyIcon(hIcon);
九、改变应用程序图标的方法:
动态更改: 向主窗口发送WM_SETICON消息.代码如下:
十、一种改变窗口标题的方法
使用语句 CWnd* m_pCWnd = AfxGetMainWnd( ),然后,再以如下形式调用SetWindowText()函数:
//m_WindowText可以是一个CString类的变量。
SetWindowText( *m_pCWnd,(LPCTSTR)m_WindowText);