1. 程式人生 > >設定windows下的快捷鍵,例如新建文字,新建word,新建excel

設定windows下的快捷鍵,例如新建文字,新建word,新建excel

/*******************************************************************************

* 新建檔案快捷方式,例如設定ctrl +alt + n 新建一個文字文件

*2011-07-03

*

********************************************************************************/

#include <windows.h>

HWND FindControlInWindow(char *pStr,HWND prentHwnd)
{
HWND hwnd;
char Buffer[256] = "Can't find";


hwnd = ::FindWindowEx(prentHwnd,0, pStr,NULL);
if (hwnd == NULL)
{
strcat(Buffer,pStr);
MessageBox(NULL,(LPCSTR)Buffer,"title",MB_OK);
return 0;
}
return(hwnd);
}


int WINAPI WinMain (
HINSTANCE hInstance, 
HINSTANCE hPrevInstance,
PSTR szCmdLine, 
int iCmdShow
)
{
HWND hwnd;
char Buffer[256];
BOOL ret;


hwnd = FindWindow("ExploreWClass", NULL);
if (hwnd == NULL)
{
hwnd = FindWindow("CabinetWClass",NULL);
if (hwnd == NULL)
{
strcpy(Buffer,"can't find ExploreWClass and CabinetWClass");
MessageBox(NULL,(LPCSTR)Buffer,"title",MB_OK);
return 0;
}
}

hwnd = FindControlInWindow("WorkerW",hwnd);
hwnd = FindControlInWindow("ReBarWindow32",hwnd);
hwnd = FindControlInWindow("ComboBoxEx32",hwnd);
hwnd = FindControlInWindow("ComboBox",hwnd);
hwnd = FindControlInWindow("Edit",hwnd);


::SendMessage(hwnd, WM_GETTEXT, 256, LPARAM(Buffer)); 
strcat(Buffer,"\\new.txt");
ret = CopyFile("D:\\QuickBoot\\Quick_Create_Files\\new.txt",Buffer,FALSE);
if(FALSE == ret)
{
MessageBox(NULL,"Copy file error!","Error",MB_OK);
}

return 0;
}