好友
阅读权限10
听众
最后登录1970-1-1
|
Windows输入法生成器类输入法VC++安装程序源代码
//五笔输入法安装程序
#include
#include
#include
#pragma comment (lib, "imm32")
#define LAYOUTTEXT_T("五笔输入法")
#define IMEFILE _T("wb.ime")
#define INST_TITLE_T("安装输入法")
#define UNINST_TITLE _T("卸载输入法")
#define FILENUM2
TCHAR sModuleFile[MAX_PATH];
TCHAR sSrcDir[MAX_PATH], sDestDir[MAX_PATH],CurrentTableDir[MAX_PATH]="";
TCHAR FileBeCopyed[FILENUM][MAX_PATH]={"wb.ime","wb.mb"};
//判断操作系统涵数及变量
typedef enum tagWin32SysType{
Windows32s,
WindowsNT3,
Windows95,
Windows98,
WindowsME,
WindowsNT4,
Windows2000,
WindowsXP,
Windows2003
}Win32SysType;
//判断操作系统涵数及变量
Win32SysType IsShellSysType()
{
Win32SysTypeShellType;
DWORD winVer;
OSVERSIONINFO *osvi;
winVer=GetVersion();
if(winVerdwOSVersionInfoSize=sizeof(OSVERSIONINFO);
GetVersionEx(osvi);
if(osvi->dwMajorVersion==4L)ShellType=WindowsNT4;
else if(osvi->dwMajorVersion==5L&&osvi->dwMinorVersion==0L)ShellType=Windows2000;
else if(osvi->dwMajorVersion==5L&&osvi->dwMinorVersion==1L)ShellType=WindowsXP;
else if(osvi->dwMajorVersion==5L&&osvi->dwMinorVersion==2L)ShellType=Windows2003;
free(osvi);
}
}
else if(LOBYTE(LOWORD(winVer))dwOSVersionInfoSize=sizeof(OSVERSIONINFO);
GetVersionEx(osvi);
if(osvi->dwMajorVersion==4L&&osvi->dwMinorVersion==10L)ShellType=Windows98;
else if(osvi->dwMajorVersion==4L&&osvi->dwMinorVersion==90L)ShellType=WindowsME;
free(osvi);
}
}
return ShellType;
}
//将两个字符串结合
void Add(TCHAR a[256],TCHAR b[256],TCHAR *c)
{
lstrcpy(c, a);
lstrcat(c, b);
}
int GetFilePath(TCHAR *FileName, TCHAR *Path)
{
int i;
i = lstrlen(FileName) - 1;
while (FileName != '\\' && i > 1)
i--;
lstrcpy(Path, FileName);
Path = 0;
return 0;
}
BOOL IsFileExist(const TCHAR *file)
{
WIN32_FIND_DATA data;
HANDLE handle;
if(!file)
return FALSE;
handle = FindFirstFile(file, &data);
if(handle == INVALID_HANDLE_VALUE)
return FALSE;
FindClose(handle);
return TRUE;
}
//复制文件的子程序
BOOL YJMCopyFile(TCHAR* FileSRC, TCHAR* FileDest)
{
TCHAR YJMMess1[256],YJMMess2[256],YJMMess3[256];
Add(FileDest,_T("已经存在,您要覆盖它吗?\n"),YJMMess1);
Add(FileSRC,_T("复制失败。\n输入法安装失败!"),YJMMess2);
Add(FileSRC,_T("复制失败。\n输入法安装失败!"),YJMMess3);
if(IsFileExist(FileDest)) {
if (MessageBox(NULL, YJMMess1, INST_TITLE,
MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON1) == IDYES) {
if (CopyFile(FileSRC, FileDest, FALSE) == 0) {
MessageBox(NULL,YJMMess2,INST_TITLE,MB_OK | MB_ICONSTOP);
return(FALSE);
}
}
}
else if(CopyFile(FileSRC, FileDest, FALSE) == 0) {
MessageBox(NULL,YJMMess3,INST_TITLE,MB_OK | MB_ICONSTOP);
return(FALSE);
}
return TRUE;
}
BOOL CopyIMEFile(HINSTANCE hInstance, TCHAR* sImeFile)
{
TCHAR sSrc[MAX_PATH], sDest[MAX_PATH];
int i;
//取得本文件执行路径。若用GetCurrentDirectory(400, sSrcDir)则可能是在别的目录执行。
GetModuleFileName(hInstance, sModuleFile, sizeof(sModuleFile) - 1);
GetFilePath(sModuleFile, sSrcDir);
lstrcat(sSrcDir, "\\");
//取得windows系统目录
GetSystemDirectory(sDestDir, sizeof(sDestDir) - 1);
lstrcat(sDestDir, "\\");
for(i=0;i |
|