在windows中找到安裝目錄"Visual Studio Tools"下的 "vs2xxx開發人員命令"
並輸入以下 注意空白鍵
devenv.exe /setup /resetuserdata /resetsettings
2019年11月25日 星期一
2019年10月22日 星期二
[C++]MFC按鈕添加提示文字
宣告在 *.h
CToolTipCtrl m_ctrlTT;
定義內容: *.cpp
BOOL SerialDlg::OnInitDialog() {......//prompt EnableToolTips(TRUE);//enable use it m_ctrlTT.Create(this); m_ctrlTT.Activate(TRUE); m_ctrlTT.SetDelayTime(150);//delayTime //IDC_BUTTON_SEND2 為要添加的控建IDC ,"Hello"為想添加的提示 m_ctrlTT.AddTool(GetDlgItem(IDC_BUTTON_SEND2), (LPCTSTR)"Hello"); return TRUE; }添加虛擬函示(ClassWizard中選擇虛擬函式 PreTranslateMessage)BOOL SerialDlg::PreTranslateMessage(MSG* pMsg) { // TODO: 在此加入特定的程式碼和 (或) 呼叫基底類別 m_ctrlTT.RelayEvent(pMsg); return CDialog::PreTranslateMessage(pMsg); }測試環境 MFC VC2015
2019年9月1日 星期日
[C++]獲取系統ip
#include"stdio.h" #include"string.h" #include"Winsock2.h" #pragma comment(lib,"WS2_32.lib")
printf("********************************\n"); printf("IP OUTPUT\n"); WSADATA wsaData; if (WSAStartup(MAKEWORD(2, 2), &wsaData) == SOCKET_ERROR) { exit(0); } int nLen = 256; char hostname[20]; gethostname(hostname, nLen); hostent *pHost = gethostbyname(hostname); LPSTR lpAddr = pHost->h_addr_list[0]; struct in_addr inAddr; memmove(&inAddr, lpAddr, 4); printf("有線IP地址:%s\n", inet_ntoa(inAddr)); memmove(&inAddr, lpAddr + 4, 4); printf("無線IP地址:%s\n", inet_ntoa(inAddr)); memmove(&inAddr, lpAddr + 8, 4); printf("環回IP地址:%s\n", inet_ntoa(inAddr)); memmove(&inAddr, lpAddr + 12, 4); printf("虛擬機1 IP地址:%s\n", inet_ntoa(inAddr)); memmove(&inAddr, lpAddr + 16, 4); printf("虛擬機2 IP地址:%s\n", inet_ntoa(inAddr)); printf("********************************\n");
可先參考 cmd 輸入ipconfig 確認ip
測試環境 :MFC 2015
[Windows]註冊密技,快捷指令
提供以下步驟,可以快速知道Windows的註冊狀況 與 註冊
打開cmd : (右鍵 "最高權限")
查詢windows註冊:
slmgr.vbs -xpr
===============================================
步驟1.解除windows註冊:
slmgr.vbs /upk
步驟2.輸入版本註冊序號:
專業版ex: (slmgr /ipk ______)
slmgr /ipk VK7JG-NPHTM-C97JM-9MPGT-3V66T
專業版:VK7JG-NPHTM-C97JM-9MPGT-3V66T
企業版:XGVPP-NMH47-7TTHJ-W3FW7-8HV2C
教育版:YNMGQ-8RYV3-4PGQ3-C8XTP-7CFBY
專業版N:2B87N-8KFHP-DKV6R-Y2C8J-PKCKT
企業版N:WGGHN-J84D6-QYCPR-T7PJ7-X766F
教育版N:84NGF-MHBT6-FXBX8-QWJK7-DRR8H
企業版S:FWN7H-PF93Q-4GGP8-M8RF3-MDWWW
步驟3.修改狀態:
slmgr /skms zh.us.to
步驟4.確認註冊:
slmgr /ato
==============================================
測試環境 win10 pro
引用來源
打開cmd : (右鍵 "最高權限")
查詢windows註冊:
slmgr.vbs -xpr
===============================================
步驟1.解除windows註冊:
slmgr.vbs /upk
步驟2.輸入版本註冊序號:
專業版ex: (slmgr /ipk ______)
slmgr /ipk VK7JG-NPHTM-C97JM-9MPGT-3V66T
專業版:VK7JG-NPHTM-C97JM-9MPGT-3V66T
企業版:XGVPP-NMH47-7TTHJ-W3FW7-8HV2C
教育版:YNMGQ-8RYV3-4PGQ3-C8XTP-7CFBY
專業版N:2B87N-8KFHP-DKV6R-Y2C8J-PKCKT
企業版N:WGGHN-J84D6-QYCPR-T7PJ7-X766F
教育版N:84NGF-MHBT6-FXBX8-QWJK7-DRR8H
企業版S:FWN7H-PF93Q-4GGP8-M8RF3-MDWWW
步驟3.修改狀態:
slmgr /skms zh.us.to
步驟4.確認註冊:
slmgr /ato
==============================================
測試環境 win10 pro
引用來源
2019年8月28日 星期三
[工具]Visual Studio Code (vscode)
官網下載點:
https://code.visualstudio.com/
推薦套件:
中文化
https://marketplace.visualstudio.com/items?itemName=MS-CEINTL.vscode-language-pack-zh-hant
c/c++
https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools
intelligent
https://marketplace.visualstudio.com/items?itemName=austin.code-gnu-global
參考設定:
https://kw0006667.wordpress.com/2017/01/31/%E9%80%8F%E9%81%8E-msbuild-%E5%9C%A8-visual-studio-code-%E7%B7%A8%E8%BC%AF%E5%9F%B7%E8%A1%8C-cc/
======後記=================
常見問題: 解決開檔亂碼問題
https://blog.xuite.net/anadachien/MyQuilt/490835461-%E5%A6%82%E4%BD%95%E8%A7%A3%E6%B1%BAMicrosoft+Visual+Studio+Code%E4%B8%80%E9%96%8B%E5%95%9F%E6%AA%94%E6%A1%88%E4%B8%AD%E6%96%87%E5%AD%97%E8%AE%8A%E4%BA%82%E7%A2%BC%E7%9A%84%E5%95%8F%E9%A1%8C
參考:解決方法--修改使用者設定檔。請點選[檔案]->[喜好設定]->[設定]->在settings.json檔案的右側[使用者設定]處輸入以下幾行設定。
https://code.visualstudio.com/
推薦套件:
中文化
https://marketplace.visualstudio.com/items?itemName=MS-CEINTL.vscode-language-pack-zh-hant
c/c++
https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools
intelligent
https://marketplace.visualstudio.com/items?itemName=austin.code-gnu-global
參考設定:
https://kw0006667.wordpress.com/2017/01/31/%E9%80%8F%E9%81%8E-msbuild-%E5%9C%A8-visual-studio-code-%E7%B7%A8%E8%BC%AF%E5%9F%B7%E8%A1%8C-cc/
======後記=================
常見問題: 解決開檔亂碼問題
https://blog.xuite.net/anadachien/MyQuilt/490835461-%E5%A6%82%E4%BD%95%E8%A7%A3%E6%B1%BAMicrosoft+Visual+Studio+Code%E4%B8%80%E9%96%8B%E5%95%9F%E6%AA%94%E6%A1%88%E4%B8%AD%E6%96%87%E5%AD%97%E8%AE%8A%E4%BA%82%E7%A2%BC%E7%9A%84%E5%95%8F%E9%A1%8C
參考:解決方法--修改使用者設定檔。請點選[檔案]->[喜好設定]->[設定]->在settings.json檔案的右側[使用者設定]處輸入以下幾行設定。
"files.encoding": "shiftjis",
"files.encoding": "eucjp",
"files.encoding": "big5hkscs",
"files.encoding": "GB18030",
"files.encoding": "GBK",
"files.encoding": "utf8",
"files.encoding": "GB2312",
"files.encoding": "Big5",
"files.autoGuessEncoding": true
2019年8月2日 星期五
[c++]Windows下C的計時器timeSetEvent
Sample:
UINT uRet = timeSetEvent(100, 100, &TimerSaveLog, (DWORD_PTR)this, TIME_ONESHOT);
void CALLBACK TimerSaveLog(UINT uTimerID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2)
{
if (!dwUser)
return;
return;
}
============================MSDN 分隔線==============================
MSDN裡定義的函數原型如下:
MMRESULT timeSetEvent(UINT uDelay,
UINT uResolution,
LPTIMECALLBACK fptc,
DWORD dwUser,
UINT fuEvent);
udelay的:以毫秒指定事件的週期。
uResolution:以毫秒指定延時的精度,數值越小定時器事件分辨率越高。缺省值為1ms。
fptc:指向一個回調函數。
dwUser:存放用戶提供的回調數據。
fuEvent:指定定時器事件類型:
TIME_ONESHOT:udelay的毫秒後只產生一次事件
TIME_PERIODIC:每隔uDelay毫秒週期性地產生事件。
============================我是分隔線==============================
sample:
#include "stdafx.h"
#include <stdio.h>
#include <Windows.h>
#include <Mmsystem.h>
#pragma comment(lib, "Winmm.lib")
void WINAPI onTimeFunc(UINT wTimerID, UINT msg,DWORD dwUser,DWORD dwl,DWORD dw2);int _tmain(int argc, _TCHAR* argv[])
{
MMRESULT timer_id;
int n = 0;
timer_id = timeSetEvent(5000, 1, (LPTIMECALLBACK)onTimeFunc, DWORD(1), TIME_PERIODIC);
if(NULL == timer_id)
{
printf("timeSetEvent() failed with error %d\n", GetLastError());
return 0;
}
while(n<20)
{
printf("Hello World\n");
Sleep(2000);
n++;
}
timeKillEvent(timer_id); //釋放定时器
return 1;
}void WINAPI onTimeFunc(UINT wTimerID, UINT msg,DWORD dwUser,DWORD dwl,DWORD dw2)
{
printf("time out\n");
return;
}
引用來源
UINT uRet = timeSetEvent(100, 100, &TimerSaveLog, (DWORD_PTR)this, TIME_ONESHOT);
void CALLBACK TimerSaveLog(UINT uTimerID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2)
{
if (!dwUser)
return;
return;
}
============================MSDN 分隔線==============================
MSDN裡定義的函數原型如下:
MMRESULT timeSetEvent(UINT uDelay,
UINT uResolution,
LPTIMECALLBACK fptc,
DWORD dwUser,
UINT fuEvent);
udelay的:以毫秒指定事件的週期。
uResolution:以毫秒指定延時的精度,數值越小定時器事件分辨率越高。缺省值為1ms。
fptc:指向一個回調函數。
dwUser:存放用戶提供的回調數據。
fuEvent:指定定時器事件類型:
TIME_ONESHOT:udelay的毫秒後只產生一次事件
TIME_PERIODIC:每隔uDelay毫秒週期性地產生事件。
============================我是分隔線==============================
sample:
#include "stdafx.h"
#include <stdio.h>
#include <Windows.h>
#include <Mmsystem.h>
#pragma comment(lib, "Winmm.lib")
void WINAPI onTimeFunc(UINT wTimerID, UINT msg,DWORD dwUser,DWORD dwl,DWORD dw2);int _tmain(int argc, _TCHAR* argv[])
{
MMRESULT timer_id;
int n = 0;
timer_id = timeSetEvent(5000, 1, (LPTIMECALLBACK)onTimeFunc, DWORD(1), TIME_PERIODIC);
if(NULL == timer_id)
{
printf("timeSetEvent() failed with error %d\n", GetLastError());
return 0;
}
while(n<20)
{
printf("Hello World\n");
Sleep(2000);
n++;
}
timeKillEvent(timer_id); //釋放定时器
return 1;
}void WINAPI onTimeFunc(UINT wTimerID, UINT msg,DWORD dwUser,DWORD dwl,DWORD dw2)
{
printf("time out\n");
return;
}
引用來源
訂閱:
文章 (Atom)
[SQL]顯示千分位與小數顯示
CONVERT ( data_type [ ( length ) ] , expression [ , style ] ) CONVERT style參數說明 1 (expression為 money 或 smallmoney型別): 0 : 預設,保留小數位後兩位,並四捨...