在windows底下,可以透過此指令查出電腦名稱:
nbtstat -A [IP address]
只要在 [IP address] 填入你想查詢的ip位址
2012年4月19日 星期四
2012年1月2日 星期一
C++ Big5 與 Unique 轉換
big5轉unicode是用MultiByteToWideChar
char *str = "big5轉unicode.txt";
wchar_t wcbuf[32];
MultiByteToWideChar (950,0,str,-1,wcbuf,32);
unique轉big5是用WideCharToMultiByte
wchar_t *wstr = L"unicode轉big5";
char mbcsbuf[32];
WideCharToMultiByte(950 ,0,wstr,-1,mbcsbuf,32,NULL,NULL);
記得要#include<Windows.h>
char *str = "big5轉unicode.txt";
wchar_t wcbuf[32];
MultiByteToWideChar (950,0,str,-1,wcbuf,32);
unique轉big5是用WideCharToMultiByte
wchar_t *wstr = L"unicode轉big5";
char mbcsbuf[32];
WideCharToMultiByte(950 ,0,wstr,-1,mbcsbuf,32,NULL,NULL);
記得要#include<Windows.h>
2011年7月9日 星期六
Win 7 設定NB分享無線網路 (Ad hoc AP)
參考這個網址就可以了。
http://blog.miniasp.com/post/2010/11/06/turn-windows-7-into-wireless-access-point.aspx
有些手機因為不支援ad hoc mode (例如android phone),所以可能會無法搜尋到這個NB架設起來的AP。
http://blog.miniasp.com/post/2010/11/06/turn-windows-7-into-wireless-access-point.aspx
有些手機因為不支援ad hoc mode (例如android phone),所以可能會無法搜尋到這個NB架設起來的AP。
2011年5月23日 星期一
C++設定windows timer resolution(計時器的經準度)
不知道各位有沒有經驗
在使用sleep之類的函數時,想要暫停幾個ms(千分之一秒),但是暫停的時間總是過長。
例如想要暫停3ms,卻發現暫停了20ms。
其實這是windows timer內部設定的問題。
可以透過以下方法解決:
TIMECAPS tc;
UINT wTimerRes;
if (timeGetDevCaps(&tc, sizeof(TIMECAPS)) != TIMERR_NOERROR)
{
wxMessageBox(wxT("Error; application can't continue"));
}
wTimerRes = min(max(tc.wPeriodMin, TARGET_RESOLUTION), tc.wPeriodMax);
MMRESULT result= timeBeginPeriod(wTimerRes);
if(result==TIMERR_NOERROR )
wxMessageBox(wxString::Format(wxT("success:%d"),wTimerRes));
else if(result==TIMERR_NOCANDO)
wxMessageBox(wxT("set timer resoluion fail"));
else
wxMessageBox(wxT("set timer resoluion other"));
在使用sleep之類的函數時,想要暫停幾個ms(千分之一秒),但是暫停的時間總是過長。
例如想要暫停3ms,卻發現暫停了20ms。
其實這是windows timer內部設定的問題。
可以透過以下方法解決:
TIMECAPS tc;
UINT wTimerRes;
if (timeGetDevCaps(&tc, sizeof(TIMECAPS)) != TIMERR_NOERROR)
{
wxMessageBox(wxT("Error; application can't continue"));
}
wTimerRes = min(max(tc.wPeriodMin, TARGET_RESOLUTION), tc.wPeriodMax);
MMRESULT result= timeBeginPeriod(wTimerRes);
if(result==TIMERR_NOERROR )
wxMessageBox(wxString::Format(wxT("success:%d"),wTimerRes));
else if(result==TIMERR_NOCANDO)
wxMessageBox(wxT("set timer resoluion fail"));
else
wxMessageBox(wxT("set timer resoluion other"));
2011年5月21日 星期六
C++測量時間
有windows及linux兩種作法:
windows:
#include <windows.h>
#include <iostream>
using namespace std;
void main(){
LARGE_INTEGER m_liPerfFreq={0};
QueryPerformanceFrequency(&m_liPerfFreq);
LARGE_INTEGER m_liPerfStart={0};
QueryPerformanceCounter(&m_liPerfStart);
for(int i=0; i< 100; i++)
cout << i << endl;
LARGE_INTEGER liPerfNow={0};
QueryPerformanceCounter(&liPerfNow);
int time=( ((liPerfNow.QuadPart - m_liPerfStart.QuadPart) * 1000)/m_liPerfFreq.QuadPart);
cout<<"執行時間:"<<time<<" ms"<<endl;
}
linux:
windows:
#include <windows.h>
#include <iostream>
using namespace std;
void main(){
LARGE_INTEGER m_liPerfFreq={0};
QueryPerformanceFrequency(&m_liPerfFreq);
LARGE_INTEGER m_liPerfStart={0};
QueryPerformanceCounter(&m_liPerfStart);
for(int i=0; i< 100; i++)
cout << i << endl;
LARGE_INTEGER liPerfNow={0};
QueryPerformanceCounter(&liPerfNow);
int time=( ((liPerfNow.QuadPart - m_liPerfStart.QuadPart) * 1000)/m_liPerfFreq.QuadPart);
cout<<"執行時間:"<<time<<" ms"<<endl;
}
linux:
timeval tim;
gettimeofday(&tim, NULL);
double t1=tim.tv_sec+(tim.tv_usec/1000000.0);
do_something_long();
gettimeofday(&tim, NULL);
double t2=tim.tv_sec+(tim.tv_usec/1000000.0);
printf("%.6lf seconds elapsed\n", t2-t1);
訂閱:
文章 (Atom)