<PropertyGroup>
<X64SystemDir>$(SystemRoot)\Sysnative</X64SystemDir>
<X32SystemDir>$(SystemRoot)\System32</X32SystemDir>
</PropertyGroup>
<Choose>
<When Condition="Exists('$(X64SystemDir)')">
<PropertyGroup>
<SystemDir>$(X64SystemDir)</SystemDir>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup>
<SystemDir>$(X32SystemDir)</SystemDir>
</PropertyGroup>
</Otherwise>
</Choose>
星期三, 7月 25, 2012
在msbuild中取得system32位置,不分64還是32位元windows
星期三, 3月 14, 2012
C++11: make_shared<T>()
Sample:
#include <memory>
#include <iostream>
using namespace std;
class MyClass{
public:
int m_i;
MyClass(int i):m_i(i){ cout << "constructor" << endl;
}
~MyClass(){
cout << "destructor" << endl;
}
};
void _tmain(int argc, _TCHAR* argv[])
{
cout << "enter main" << endl;
auto a = make_shared<MyClass>(10);
cout << a->m_i << endl;
cout << "leave main" << endl;
}
output:
enter main
constructor
10
leave main
destructor
星期二, 11月 22, 2011
利用sregex_iterator找出所有符合指定regular expression的子字串
<<程式>>
#include <regex> #include <string> #include <iostream> using namespace std; int _tmain(int argc, _TCHAR* argv[]) { try{ regex re("\\d++"); string input("123 23 435 asd 000"); sregex_iterator ite(input.begin(), input.end(), re); sregex_iterator iteEnd; for(; ite != iteEnd; ++ite){ cout << "found: " << ite->str() << " at " << ite->position() << " length " << ite->length() << endl; } } catch(regex_error& e){ cout << "Error: " << e.what() << endl; } return 0; }
<<輸出>>
found: 123 at 0 length 3
found: 23 at 4 length 2
found: 435 at 7 length 3
found: 000 at 15 length 3
星期一, 5月 09, 2011
在c#中正確處理Unicode
程式碼:
string s = "哈\uD950\uDF21高"; Console.WriteLine("string length:" + s.Length);
TextElementEnumerator textEnum =
StringInfo.GetTextElementEnumerator(s); while (textEnum.MoveNext()) {
Console.WriteLine("word {0}: {1}",
textEnum.ElementIndex,
textEnum.Current.ToString());
}
* This source code was highlighted with Source Code Highlighter.
輸出:
string length:4
word 0: 哈
word 1: ??
word 3: 高
重點:
- UTF-32等同於UCS-4 (Universal Character Set –4 ), 編碼範圍在0~7F FF FF FF
- UTF-16不等同於UCS-2。USC-2只涵蓋部分USC-4的字元。而UTF-16可以涵蓋所有UTF-32的字元
- UTF-16利用surrogate機制,讓某些UTF-32的字元以一對UTF-16編碼的形式來表示
- USC-2跟UTF-16的差別在於有無surrogate機制上
- .Net使用的char型別存放的是UTF-16
星期一, 1月 10, 2011
在Microsoft Access筆記中
參照到使用者介面物件
- [Forms]![Questions]![RawData 子表單].Form![answer]
取得目前使用者
- http://www.utteraccess.com/forum/CurrentUser-returns-Admi-t1201126.html :
- Environ("USERNAME")
Have you implemented Access' security? Because the built-in CURRENTUSER function returns the ACCESS user, not the WINDOWS user. If you haven't implemented Access' workgroup security, everyone is an "ADMIN" user. If you want to get the name of the WINDOWS/network user logged in, see this link:
http://www.mvps.org/access/api/api0008.htm
星期日, 10月 24, 2010
Visual Studio的編譯會受Windows SDK版本設定的影響
幾個簡單檢視目前Windows SDK版本的方法:
- 方法一: 開啟Visual Studio Command Prompt, 下echo %windowssdkdir%指令
- 方法二: 開啟vc專案,找到”Include Directories”之類的設定項目,在編輯畫面的Macros中檢視 $(WindowsSDKDir)
Windows SDK版本設定如果不正確,可能會導致vc專案編譯失敗,出現類似像windows.h找不到的錯誤訊息。
修正方式:
- 在windows SDK目錄下,使用以下命令來設定(以下命令將SDK版本設定為v7.0A):
C:\Program Files\Microsoft SDKs\Windows\v7.1\Setup>WindowsSdkVer.exe -version:v7.0A
參考資料