My Son and me

March 26, 2009 by kaineshu

15720020.JPG

幸福

March 23, 2009 by kaineshu

小兒子 七個月

March 23, 2009 by kaineshu

舊照,目前八個月,看起來比較可愛了

DSC_3317.JPG

linux kernel access file : filp_open – example

October 6, 2008 by kaineshu

int test(void){

char buf[100];
int i;

int count=0;
// do{
printk(“mmc_blk_remove() Open /var/run/SD_mount_record!”);
struct file *phMscd_Filp = NULL;

for(i=0;i<100;i++)
buf[i] = 0;

phMscd_Filp = filp_open(“/var/run/SD_mount_record”, O_RDWR | O_LARGEFILE, 0);
if (phMscd_Filp == NULL)
{
printk(KERN_ALERT “filp_open error!!.\n”);
}
mm_segment_t old_fs=get_fs();
set_fs(get_ds());
phMscd_Filp->f_op->read(phMscd_Filp, buf, 2, &phMscd_Filp->f_pos);
set_fs(old_fs);
printk(“buf:%s\n”,buf);

filp_close(phMscd_Filp,NULL);

return 1;
}

MFC get file list by using FindFirstFile

July 2, 2008 by kaineshu

void test(void){
CString cFileList[50];
int nFileTotalCount;
nFileTotalCount=0;
HANDLE hFile = NULL;
WIN32_FIND_DATA lpFindFileData;
// BOOL bContinue = FALSE;
int i = 0;
for(i=0;i <50;i++)
cFileList[i]=_T(“”);
i = 0;
hFile = FindFirstFile(_T(“\\PocketMory\\*.*”),&lpFindFileData);
if(hFile!=INVALID_HANDLE_VALUE){
cFileList[i]=lpFindFileData.cFileName;
i++;
nFileTotalCount++;
}else{
FindClose(hFile);
return;
}
while (1)
{
if (FindNextFile(hFile,&lpFindFileData)==0)
{
FindClose(hFile);
break;
}
i++;
nFileTotalCount++;
cFileList[i]=lpFindFileData.cFileName;
}
return;
}

MFC Hide Button or Show Button 隱藏 button

July 2, 2008 by kaineshu

GetDlgItem(ID)-> ShowWindow(SW_HIDE); //Hide

GetDlgItem(ID)-> ShowWindow(SW_RESTORE);//show

Grease Monkey script for Flickr : View on Flickriver

June 25, 2008 by kaineshu

Flickriver 是一個專門來看 flickr 照片網頁的一個網站,黑色底加上簡潔的畫面。

看 flickr 就不用辛苦的按來按去。

原始 flickr 畫面

透過 flickriver

官方有寫了一個給 Firefox grease monkey 用的 script,可以在看 sets , groups 等等中,出現一個 View on Flickriver 的按鈕

直接開到 flickriver 同樣的網頁去。

可惜的是在看單一 set 時,並不會出現(其實有作進去,不過那是 page 的問題)

針對單一 set 也出現這個連結,我改了一下原始檔案

改過的版本,按此安裝

MFC (eVC) : using SendMessage to emulate button clicked event 使用 SendMessage 模擬 button 按下

June 18, 2008 by kaineshu

利用 GetDlgOtem 傳入某個 ID,取得 CWnd

然後轉 hWnd,之後就可以 SendMessage

code:

CWnd* pWnd = GetDlgItem(IDC_BUTTON_KEY);

HWND hWnd = pWnd->GetSafeHwnd();
SendMessage(WM_COMMAND,IDC_BUTTON_KEY,0);

MFC evc Create Thread #2

June 16, 2008 by kaineshu

說明,利用 WaitForSingleObject 來使 thread 暫時釋放資源,改進使用 Sleep 的方式

在等待 5000( 5 秒 timeout )後,接著執行下面的指令

用 WaitForSingleObject 是滿常用的方式

HANDLE hEvent1;

UINT MyThreadProc( LPVOID pParam )
{
while(TRUE){
WaitForSingleObject(hEvent1, 5000); // auto reset
RETAILMSG( TRUE, (TEXT(“Something in thread\r\n”)));
}
return 0; // thread completed successfully
}
BOOL USB::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
// create event objects
hEvent1 = CreateEvent(NULL, FALSE, FALSE, NULL); // auto reset

//start a thread for test;
AfxBeginThread(MyThreadProc, NULL);

return TRUE; // return TRUE unless you set the focus to a control
}

MFC evc Create thread in winCE

June 12, 2008 by kaineshu

UINT MyThreadProc( LPVOID pParam )
{
// do something with ‘pObject’
RETAILMSG( TRUE, (TEXT(“Something in thread\r\n”)));
return 0; // thread completed successfully
}
BOOL USB::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here

AfxBeginThread(MyThreadProc, NULL);

return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}