SetProcessShutdownParameters(0x100, 0);
posted @
2010-11-26 22:03 张志松 阅读(284) |
评论 (0) |
编辑 收藏
BOOL LimitCPU(DWORD dwMask)
{
BOOL bRet = FALSE;
DWORD dwProcessAffinityMask = 0, dwSystemAffinityMask = 0;
bRet = GetProcessAffinityMask(GetCurrentProcess(), &dwProcessAffinityMask, &dwSystemAffinityMask);
if (0 == dwMask)
{
if (bRet)
{
bRet = SetProcessAffinityMask(GetCurrentProcess(), dwSystemAffinityMask);// ALL CPU
}
}
else if (((DWORD)- 1) == dwMask)
{
if (bRet)
{
bRet = SetProcessAffinityMask(GetCurrentProcess(), (dwSystemAffinityMask + 1) / 2); //LAST CPU
}
}
else
{
bRet = SetProcessAffinityMask(GetCurrentProcess(), dwMask);
}
return bRet;
}
posted @
2010-11-26 22:02 张志松 阅读(355) |
评论 (0) |
编辑 收藏
BOOL PlayWav(UINT nResId)
{
BOOL bRet = FALSE;
HRSRC hWaveRes = FindResource(AfxGetResourceHandle(), MAKEINTRESOURCE(nResId), _T("WAVE"));
if (hWaveRes != NULL)
{
HGLOBAL hGlobMem = LoadResource(AfxGetResourceHandle(), hWaveRes);
if (hGlobMem != NULL)
{
bRet = sndPlaySound((LPCTSTR)LockResource(hGlobMem), SND_ASYNC | SND_MEMORY);
FreeResource(hGlobMem);
}
}
return bRet;
}
posted @
2010-11-26 21:58 张志松 阅读(159) |
评论 (0) |
编辑 收藏
BOOL IsFullScreenMode()
{
BOOL bRet = FALSE;
HWND hDesktopWindow = GetDesktopWindow();
HWND hShellWindow = GetShellWindow();
DWORD dwDesktopWindow = 0, dwShellWindow = 0;
GetWindowThreadProcessId(hDesktopWindow, &dwDesktopWindow);
GetWindowThreadProcessId(hShellWindow, &dwShellWindow);
const INT nWidth = GetSystemMetrics(SM_CXSCREEN);
const INT nHeight = GetSystemMetrics(SM_CYSCREEN);
DWORD dwTmp = 0;
HWND hTmp = FindWindowEx(NULL, NULL, NULL, NULL);
while (hTmp != NULL)
{
CRect rect;
GetWindowRect(hTmp, &rect);
if (nWidth == rect.Width() && nHeight == rect.Height())
{
GetWindowThreadProcessId(hTmp, &dwTmp);
if (dwTmp != dwShellWindow && dwTmp != dwDesktopWindow)
{
bRet = TRUE;
TRACE("FullScreen:%d\n", dwTmp);
break;
}
}
hTmp = FindWindowEx(NULL, hTmp, NULL, NULL);
}
return bRet;
}
posted @
2010-11-26 21:57 张志松 阅读(753) |
评论 (0) |
编辑 收藏
如何区分一个按钮事件是由鼠标点击、回车还是快捷键产生的呢?
用AfxGetCurrentMessage获取当前的消息,根据消息的值来区分。
posted @
2010-11-21 19:06 张志松 阅读(1156) |
评论 (0) |
编辑 收藏
'代码页
Const CodePage_GB2312 = 936 ' 简体中文 (GB2312)
Const CodePage_BIG5 = 950 ' 繁体中文 (BIG5)
'设置WinHttpRequest的URL编码
Const WinHttpRequestOption_URLCodePage = 2
Dim WinHttpRequest
Set WinHttpRequest = CreateObject("WinHttp.WinHttpRequest.5.1")
WinHttpRequest.Option(WinHttpRequestOption_URLCodePage) = CodePage_GB2312
'设置ServerXMLHTTP的URL编码
Const SXH_OPTION_URL_CODEPAGE = 0
Dim ServerXMLHTTP
Set ServerXMLHTTP = CreateObject("Msxml2.ServerXMLHTTP")
ServerXMLHTTP.setOption SXH_OPTION_URL_CODEPAGE, CodePage_GB2312
posted @
2010-11-13 16:05 张志松 阅读(1287) |
评论 (0) |
编辑 收藏
enum CodePages
{
IBM037=37,
IBM437=437,
IBM500=500,
ASMO_708=708,
DOS_720=720,
ibm737=737,
ibm775=775,
ibm850=850,
ibm852=852,
IBM855=855,
ibm857=857,
IBM00858=858,
IBM860=860,
ibm861=861,
DOS_862=862,
IBM863=863,
IBM864=864,
IBM865=865,
cp866=866,
ibm869=869,
IBM870=870,
windows_874=874,
cp875=875,
shift_jis=932,
gb2312=936,
ks_c_5601_1987=949,
big5=950,
IBM1026=1026,
IBM01047=1047,
IBM01140=1140,
IBM01141=1141,
IBM01142=1142,
IBM01143=1143,
IBM01144=1144,
IBM01145=1145,
IBM01146=1146,
IBM01147=1147,
IBM01148=1148,
IBM01149=1149,
utf_16=1200,
unicodeFFFE=1201,
windows_1250=1250,
windows_1251=1251,
Windows_1252=1252,
windows_1253=1253,
windows_1254=1254,
windows_1255=1255,
windows_1256=1256,
windows_1257=1257,
windows_1258=1258,
Johab=1361,
macintosh=10000,
x_mac_japanese=10001,
x_mac_chinesetrad=10002,
x_mac_korean=10003,
x_mac_arabic=10004,
x_mac_hebrew=10005,
x_mac_greek=10006,
x_mac_cyrillic=10007,
x_mac_chinesesimp=10008,
x_mac_romanian=10010,
x_mac_ukrainian=10017,
x_mac_thai=10021,
x_mac_ce=10029,
x_mac_icelandic=10079,
x_mac_turkish=10081,
x_mac_croatian=10082,
utf_32=12000,
utf_32BE=12001,
x_Chinese_CNS=20000,
x_cp20001=20001,
x_Chinese_Eten=20002,
x_cp20003=20003,
x_cp20004=20004,
x_cp20005=20005,
x_IA5=20105,
x_IA5_German=20106,
x_IA5_Swedish=20107,
x_IA5_Norwegian=20108,
us_ascii=20127,
x_cp20261=20261,
x_cp20269=20269,
IBM273=20273,
IBM277=20277,
IBM278=20278,
IBM280=20280,
IBM284=20284,
IBM285=20285,
IBM290=20290,
IBM297=20297,
IBM420=20420,
IBM423=20423,
IBM424=20424,
x_EBCDIC_KoreanExtended=20833,
IBM_Thai=20838,
koi8_r=20866,
IBM871=20871,
IBM880=20880,
IBM905=20905,
IBM00924=20924,
EUC_JP=20932,
x_cp20936=20936,
x_cp20949=20949,
cp1025=21025,
koi8_u=21866,
iso_8859_1=28591,
iso_8859_2=28592,
iso_8859_3=28593,
iso_8859_4=28594,
iso_8859_5=28595,
iso_8859_6=28596,
iso_8859_7=28597,
iso_8859_8=28598,
iso_8859_9=28599,
iso_8859_13=28603,
iso_8859_15=28605,
x_Europa=29001,
iso_8859_8_i=38598,
iso_2022_jp=50220,
csISO2022JP=50221,
iso_2022_kr=50225,
x_cp50227=50227,
euc_jp=51932,
EUC_CN=51936,
euc_kr=51949,
hz_gb_2312=52936,
GB18030=54936,
x_iscii_de=57002,
x_iscii_be=57003,
x_iscii_ta=57004,
x_iscii_te=57005,
x_iscii_as=57006,
x_iscii_or=57007,
x_iscii_ka=57008,
x_iscii_ma=57009,
x_iscii_gu=57010,
x_iscii_pa=57011,
utf_7=65000,
utf_8=65001
};
posted @
2010-11-13 15:57 张志松 阅读(419) |
评论 (0) |
编辑 收藏
Dim WshShell As Object, MyShortcut As Object
Set WshShell = CreateObject("Wscript.shell")
Dim strDesktop As String
strDesktop = WshShell.SpecialFolders("Desktop")
Set MyShortcut = WshShell.CreateShortcut(strDesktop + "\我的快捷方式.lnk") '此处为快捷名称
MyShortcut.TargetPath = App.Path & "\" & App.EXEName & ".exe" '此处为源文件
'MyShortcut.IconLocation '此处为快捷图标,默认为应用程序的图标
MyShortcut.WorkingDirectory = App.Path '工作目录
MyShortcut.Description = "测试创建快捷方式" '备注
MyShortcut.Hotkey = "ALT+CTRL+A" '此处为快捷热键
MyShortcut.Save
posted @
2010-11-07 10:29 张志松 阅读(909) |
评论 (0) |
编辑 收藏
Function SaveResToFile(ByVal Id As Long, ByVal strFileName As String) As Boolean
Dim ByteArray() As Byte
ByteArray = LoadResData(Id, "FILE")
Dim hFile As Long
hFile = CreateFile(strFileName, GENERIC_WRITE, FILE_SHARE_READ Or FILE_SHARE_WRITE, ByVal 0&, CREATE_ALWAYS, 0, 0)
If hFile <> -1 Then
Dim lTmp As Long
WriteFile hFile, ByteArray(0), UBound(ByteArray) + 1, lTmp, ByVal 0&
Call CloseHandle(hFile)
SaveResToFile = True
End If
End Function
Private Sub Command2_Click()
SaveResToFile 101, ".\JMail.dll"
End Sub
posted @
2010-11-07 10:17 张志松 阅读(473) |
评论 (0) |
编辑 收藏
Private Declare Function JMail_DllGetClassObject Lib "JMail.dll" Alias "DllGetClassObject" (rclsid As UUID, riid As UUID, ByRef ppv As Any) As Long
Function CreateJMailMessage() As Object
'这里需要引用Win.tlb类型库
Dim IID_IClassFactory As UUID
Dim IID_IUnknow As UUID
Dim CLSID_Message As UUID
Const CLSIDSTR_Message As String = "{E5FF9F62-0E7C-4372-8AD5-DA7D2418070C}"
CLSIDFromString CLSIDSTR_Message, CLSID_Message
CLSIDFromString IIDSTR_IUnknown, IID_IUnknow
CLSIDFromString IIDSTR_IClassFactory, IID_IClassFactory
Dim ClassFactory As IVBClassFactory
Dim lRet As Long
lRet = JMail_DllGetClassObject(CLSID_Message, IID_IClassFactory, ClassFactory)
Dim MyObject As IUnknown
ClassFactory.CreateInstance Nothing, IID_IUnknow, MyObject
Set ClassFactory = Nothing
Set CreateJMailMessage = MyObject
End Function
Private Sub Command1_Click()
Dim JMailMessage As Object
Set JMailMessage = CreateJMailMessage
MsgBox JMailMessage.About
End Sub
posted @
2010-11-07 10:12 张志松 阅读(3521) |
评论 (1) |
编辑 收藏