2010年6月10日 星期四

使用MFC:重複執行出現多個相同程式(Fixed)

目的:
重複執行相同程式只允許一個程式被執行.

問題點:
被重複執行出現多個相同程式.

解法:
使用mutex來解決.

SampleCode:
bool CInitRegStatusDlg::CheckLaunchTwiceTime(void)
{
bool bFound = false;
HANDLE hMutexOneInstantance=CreateMutex(NULL,TRUE,_T("InitRegStatusInstance"));
if(GetLastError() == ERROR_ALREADY_EXISTS)
{
bFound=true;
}
if(hMutexOneInstantance)
{
ReleaseMutex(hMutexOneInstantance);
}
return bFound;
}



透過Facebook分享

MFC 讀取 command line 參數

撰寫MFC程式
卻要讀取由command line的參數

你可以使用以下方法

首先
找到
InitInstance function

使用

CString strCommand = GetCommandLine();
抓取command
ex. prun a.exe -m -y
就會完整抓出 -m -y

透過Facebook分享

2010年6月9日 星期三

install android 2.2

download android sdk: http://developer.android.com/sdk/download.html?v=android-sdk_r06-windows.zip

unzip android-sdk_r06-windows.zip

add these to system path:
C:\android\android-sdk-windows\tools;C:\android\android-sdk-windows;C:\Program Files\Java\jdk1.6.0_20\bin

manual create two folders - platforms and add-ons into the root of android sdk.
ex. C:\android\android-sdk-windows

execute C:\android\android-sdk-windows\tools\android.bat
Go to Settings and modify https to http.


Go to "Available Packages"
check "https://dl-ssl.google.com/android/repository/repository.xml"



Finally,


Reference:
http://developer.android.com/sdk/index.html

透過Facebook分享

2010年6月8日 星期二

How to build older gcc - build gcc 3.4.6 by using gcc 4.3.2

How to build gcc
http://www.faqs.org/docs/ldev/0130091154_71.htm

unzip file
./configure
(or ./configure --prefix=/home/nelsonchung/gcc)
make bootstrap

make install (將會把build好的gcc移到之前所定義的prefix地方) 



log
nelsonchung@debian:~/gcc/Binary/gcc-3.4.6/bin$ ./gcc -v
Reading specs from /home/nelsonchung/gcc/Binary/gcc-3.4.6/bin/../lib/gcc/i686-pc-linux-gnu/3.4.6/specs
Configured with: ./configure --prefix=/home/nelsonchung/gcc
Thread model: posix
gcc version 3.4.6
nelsonchung@debian:~/gcc/Binary/gcc-3.4.6/bin$ gcc
gcc: no input files
nelsonchung@debian:~/gcc/Binary/gcc-3.4.6/bin$ gcc -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.3.2-1.1' --with-bugurl=file:///usr/share/doc/gcc-4.3/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.3 --program-suffix=-4.3 --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr --enable-targets=all --enable-cld --enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu
Thread model: posix
gcc version 4.3.2 (Debian 4.3.2-1.1)
nelsonchung@debian:~/gcc/Binary/gcc-3.4.6/bin$

透過Facebook分享