/*******************************************************************************
* 新建文件快捷方式,例如设定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;
}