📄 addmenu.c
字号:
#include <user\dlg.h>
#include "sharewareluncher.h"
#include "tab.h"
#include "resource.h"
#define EXE 99
#define COM 98
#define BAT 97
#define SCR 96
int CutCmdLine(LPSTR s);
HWND hAddWnd=NULL;
BOOL bNoLunch=TRUE;
BOOL bAddPDOS=FALSE;
extern HINSTANCE hInst;
extern int nTimerNum;
extern char szRunCommand[300];
extern BOOL bAddExe,bCreateLink;
extern BOOL bNoMsg;
char szFileName[MAX_PATH]="\0";//,szAppName[80],szAppCmd[300];
int nfun;
SYSTEMTIME VirtualDate,RealDate;
char szErr[256];
APPINFO aiAppInfo[50],aiAppInfoTemp;
extern HMENU hmenu;
extern HMENU hmenuTrackPopup;
int nAppNum;
extern BOOL bSetAuto,bVerChanged;
extern int naiIndex;
int nAlarmEveryHour=0;
#pragma argsused
BOOL CALLBACK AddDlgProc(HWND hWnd,UINT uMsg,UINT wParam,LONG lParam)
{
switch(uMsg)
{
case WM_INITDIALOG:
hAddWnd=hWnd;
if(bAddExe)
SetDlgItemText(hWnd,IDHELP,"启 动");
else
SetDlgItemText(hWnd,IDHELP,"帮 助");
if(naiIndex!=-1)
{
SetWindowText(hWnd,"共享软件程序设置");
SetDlgItemText(hWnd,IDC_NAME,"该程序命名为:");
SetDlgItemText(hWnd,IDC_APPNAME,aiAppInfo[naiIndex].szAppName);
SetDlgItemText(hWnd,IDC_APPCMDLINE,aiAppInfo[naiIndex].szAppCmd);
if(aiAppInfo[naiIndex].stVrDate.wYear==0 || aiAppInfo[naiIndex].stVrDate.wMonth==0 ||
aiAppInfo[naiIndex].stVrDate.wDay==0);
else
{
SetDlgItemInt(hWnd,IDC_YEAR,aiAppInfo[naiIndex].stVrDate.wYear,FALSE);
SetDlgItemInt(hWnd,IDC_MONTH,aiAppInfo[naiIndex].stVrDate.wMonth,FALSE);
SetDlgItemInt(hWnd,IDC_DAY,aiAppInfo[naiIndex].stVrDate.wDay,FALSE);
}
}
if(bAddExe || bCreateLink)
{
if(CutCmdLine(szRunCommand)==SCR)
strcat(szRunCommand," /s\0");
SetDlgItemText(hWnd,IDC_APPCMDLINE,szRunCommand);
}
SetFocus(GetDlgItem(hWnd,IDC_APPNAME));
break;
case WM_COMMAND:
switch(wParam)
{
case IDOK:
if(bAddPDOS)
{
bAddPDOS=FALSE;
// domsgAddPDOS();
}
else
{
if(GetDlgItemText(hWnd,IDC_APPNAME,aiAppInfoTemp.szAppName,80)==0)
{
Errmsg("请键入共享软件程序名称。");
break;
}
wsprintf(aiAppInfoTemp.szAppCmd,"\0");
if(GetDlgItemText(hWnd,IDC_APPCMDLINE,aiAppInfoTemp.szAppCmd,300)==0)
{
Errmsg("请指定共享软件程序位置或启动命令行。");
break;
}
CutCmdLine(aiAppInfoTemp.szAppCmd);
if(!CheckExistFile(szErr))
{
Errmsg("指定的程序文件不存在.");
break;
}
nfun=CheckDate(hWnd);
if(nfun==-1)
{
Errmsg("无效日期!\n请键入合法日期。");
break;
}
}
RegisterInfo();
hAddWnd=NULL;
EndDialog(hWnd,TRUE);
return TRUE;
case IDCANCEL:
naiIndex=-1;
hAddWnd=NULL;
EndDialog(hWnd,FALSE);
return FALSE;
case IDHELP:
if(bAddExe)
{
bNoLunch=FALSE;
hAddWnd=NULL;
PostMessage(hWnd,WM_COMMAND,IDOK,0);
break;
}
ShowHelpInfo(hInst,"共享软件程序发射器\n(C) Copyright 11/19,1998\n[] Ver 2.0",
"版权信息",IDI_APPICON);
break;
case IDC_LOOK:
if(GetFileName(hInst,NULL,"共享软件程序\0*.exe;*.com;*.bat;*.scr\0",szFileName,"打开"))
{
SetDlgItemText(hWnd,IDC_APPCMDLINE,szFileName);
wsprintf(szFileName,"\0");
}
break;
}
break;
case WM_CLOSE:
naiIndex=-1;
hAddWnd=NULL;
EndDialog(hWnd,FALSE);
return FALSE;
default:
return FALSE;
}
return FALSE;
}
int CheckDate(HWND hWnd)
{
int BigYear,BigMonth,x=0;
SYSTEMTIME stTemp;
aiAppInfoTemp.stVrDate.wYear=(WORD)GetDlgItemInt(hWnd,IDC_YEAR,NULL,FALSE);
aiAppInfoTemp.stVrDate.wMonth=(WORD)GetDlgItemInt(hWnd,IDC_MONTH,NULL,FALSE);
aiAppInfoTemp.stVrDate.wDay=(WORD)GetDlgItemInt(hWnd,IDC_DAY,NULL,FALSE);
if(aiAppInfoTemp.stVrDate.wYear==0)
x+=1;
if(aiAppInfoTemp.stVrDate.wMonth==0)
x+=2;
if(aiAppInfoTemp.stVrDate.wDay==0)
x+=4;
switch(x)
{
case 0:
break;
case 1:
GetLocalTime(&stTemp);
aiAppInfoTemp.stVrDate.wYear=stTemp.wYear;
break;
case 2:
GetLocalTime(&stTemp);
aiAppInfoTemp.stVrDate.wMonth=stTemp.wMonth;
break;
case 3:
GetLocalTime(&stTemp);
aiAppInfoTemp.stVrDate.wYear=stTemp.wYear;
aiAppInfoTemp.stVrDate.wMonth=stTemp.wMonth;
break;
case 4:
GetLocalTime(&stTemp);
aiAppInfoTemp.stVrDate.wDay=stTemp.wDay;
break;
case 5:
GetLocalTime(&stTemp);
aiAppInfoTemp.stVrDate.wYear=stTemp.wYear;
aiAppInfoTemp.stVrDate.wDay=stTemp.wDay;
break;
case 6:
GetLocalTime(&stTemp);
aiAppInfoTemp.stVrDate.wMonth=stTemp.wMonth;
aiAppInfoTemp.stVrDate.wDay=stTemp.wDay;
break;
case 7:
return 1;
}
if(aiAppInfoTemp.stVrDate.wYear<1980 || aiAppInfoTemp.stVrDate.wMonth<=0 || aiAppInfoTemp.stVrDate.wMonth>12 || aiAppInfoTemp.stVrDate.wDay<=0 || aiAppInfoTemp.stVrDate.wDay>31)
return -1;
if(aiAppInfoTemp.stVrDate.wYear%4==0 && aiAppInfoTemp.stVrDate.wYear%100!=0 || aiAppInfoTemp.stVrDate.wYear%400==0)
BigYear=TRUE;
else
BigYear=FALSE;
if((aiAppInfoTemp.stVrDate.wMonth<=7 && aiAppInfoTemp.stVrDate.wMonth%2!=0) || (aiAppInfoTemp.stVrDate.wMonth>=8 && aiAppInfoTemp.stVrDate.wMonth%2==0))
BigMonth=TRUE;
else
BigMonth=FALSE;
if((BigMonth==FALSE && aiAppInfoTemp.stVrDate.wDay>30) || (BigYear==FALSE && aiAppInfoTemp.stVrDate.wMonth==2 && aiAppInfoTemp.stVrDate.wDay>28)
|| (BigYear==TRUE && aiAppInfoTemp.stVrDate.wMonth==2 && aiAppInfoTemp.stVrDate.wDay>29))
return -1;
else
return 1;
}
BOOL RegisterInfo(void)
{
HKEY hKey1;//, hKey2;
DWORD dwDisposition;
LONG lRetCode;
DWORD dwDate,dwDateSize=sizeof(DWORD);
int i;
lRetCode=RegCreateKeyEx(HKEY_LOCAL_MACHINE,"SOFTWARE\\phonix\\sharewareluncher",0, NULL, REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS,NULL,&hKey1,&dwDisposition);
if (lRetCode != ERROR_SUCCESS)
{
Errmsg("Error in creating key\n");//,"Error",MB_OK);
return FALSE;//break;
}
lRetCode = RegQueryValueEx ( hKey1,"Num",NULL,&dwDisposition,(LPBYTE)(&dwDate),&dwDateSize);
// if we failed, note it, and leave
if (lRetCode != ERROR_SUCCESS)
{
Errmsg("Error in getting Section1 value\n");//,"Reg Error",MB_OK);
return FALSE;//break;
}
if(naiIndex==-1)
{
if(dwDate==0)
i=0;
else
i=(int)dwDate;
nAppNum=(int)(dwDate+1);
}
else
i=naiIndex;
aiAppInfo[i]=aiAppInfoTemp;
AddReg(aiAppInfoTemp);
return TRUE;
}
void CheckReg(void)
{
HKEY hKey1;//, hKey2;
DWORD dwDisposition;
LONG lRetCode;
DWORD dwFlag=1,dwDateSize=sizeof(DWORD);
char szver[5];
wsprintf(szver,"\0");
lRetCode=RegCreateKeyEx(HKEY_LOCAL_MACHINE,"SOFTWARE\\phonix\\sharewareluncher",0, NULL, REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS,NULL,&hKey1,&dwDisposition);
if (lRetCode != ERROR_SUCCESS)
{
Errmsg("Error in creating key\n");//,"Error",MB_OK);
return;//break;
}
if(dwDisposition==REG_CREATED_NEW_KEY)
{
if(InFloppyDisk(0))
{
bSetAuto=FALSE;
dwFlag=0;
lRetCode=RegSetValueEx ( hKey1,"Autorun",0,REG_DWORD,(LPBYTE)(&dwFlag),dwDateSize);
}
else
{
bSetAuto=TRUE;
dwFlag=1;
lRetCode = RegSetValueEx ( hKey1,"Autorun",0,REG_DWORD,(LPBYTE)(&dwFlag),dwDateSize);
}
if (lRetCode != ERROR_SUCCESS)
{
Errmsg("Error in setting autorun Section1 value\n");//,"Reg Error",MB_OK);
return;
}
nAppNum=0;dwFlag=0;
lRetCode = RegSetValueEx ( hKey1,"Num",0,REG_DWORD,(LPBYTE)(&dwFlag),dwDateSize);
if (lRetCode != ERROR_SUCCESS)
{
Errmsg("Error in setting Section1 value\n");//,"Reg Error",MB_OK);
return;
}
lRetCode = RegSetValueEx ( hKey1,"tiNum",0,REG_DWORD,(LPBYTE)(&dwFlag),dwDateSize);
if (lRetCode != ERROR_SUCCESS)
{
Errmsg("Error in setting Section1 value\n");//,"Reg Error",MB_OK);
return;
}
RegSetValueEx(hKey1,"ver",0,REG_SZ,(LPBYTE)"2.0",5);
RegSetValueEx(hKey1,"NoMsg",0,REG_DWORD,(LPBYTE)(LPBYTE)(&dwFlag),dwDateSize);
}
else
{
RegQueryValueEx ( hKey1,"Autorun",NULL,&dwDisposition,(LPBYTE)(&dwFlag),&dwDateSize);
if(dwFlag==0)
{
if(!InFloppyDisk(0))
{
bSetAuto=TRUE;
dwFlag=1;
RegSetValueEx ( hKey1,"Autorun",0,REG_DWORD,(LPBYTE)(&dwFlag),dwDateSize);
}
}
else
bSetAuto=FALSE;
dwDateSize=5;
if(RegQueryValueEx ( hKey1,"ver",NULL,&dwDisposition,(LPBYTE)szver,&dwDateSize)!=ERROR_SUCCESS)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -