www.pudn.com > sharewareluncher.zip > addmenu.c


#include  
#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) 
		{ 
         if(!InFloppyDisk(0)) 
         { 
      		RegSetValueEx(hKey1,"ver",0,REG_SZ,(LPBYTE)"2.0",5); 
         	bSetAuto=TRUE; 
         } 
      } 
      else if(stricmp(szver,"2.0")<0) 
      { 
      	RegSetValueEx(hKey1,"ver",0,REG_SZ,(LPBYTE)"2.0",5); 
         bVerChanged=TRUE; 
         bSetAuto=TRUE; 
      } 
 
		lRetCode = RegQueryValueEx ( hKey1,"Num",NULL,&dwDisposition,(LPBYTE)(&dwFlag),&dwDateSize); 
     				// if we failed, note it, and leave 
		if (lRetCode != ERROR_SUCCESS) 
		{ 
         nAppNum=0; 
     		Errmsg("Error in getting Section1 value\n");//,"Reg Error",MB_OK); 
      	return; 
   	} 
      nAppNum=(int)dwFlag; 
   	if(dwFlag!=0) 
      	GetAppInfo(dwFlag); 
 
      lRetCode = RegQueryValueEx ( hKey1,"tiNum",NULL,&dwDisposition,(LPBYTE)(&dwFlag),&dwDateSize); 
     				// if we failed, note it, and leave 
		if (lRetCode != ERROR_SUCCESS) 
		{ 
         nTimerNum=0; 
         RegSetValueEx ( hKey1,"tiNum",0,REG_DWORD,(LPBYTE)(&dwFlag),dwDateSize); 
     		//Errmsg("Error in getting Section1 value\n");//,"Reg Error",MB_OK); 
      	return; 
   	} 
 
      nTimerNum=(int)dwFlag; 
      if(dwFlag!=0) 
      	GetTimerInfo(dwFlag); 
 
      lRetCode = RegQueryValueEx ( hKey1,"AlarmEveryHour",NULL,&dwDisposition,(LPBYTE)(&dwFlag),&dwDateSize); 
 
		if (lRetCode != ERROR_SUCCESS) 
		{ 
         nAlarmEveryHour=0; 
         RegSetValueEx ( hKey1,"AlarmEveryHour",0,REG_DWORD,(LPBYTE)(&dwFlag),dwDateSize); 
      	return; 
   	} 
		nAlarmEveryHour=(int)dwFlag; 
 
      lRetCode = RegQueryValueEx ( hKey1,"NoMsg",NULL,&dwDisposition,(LPBYTE)(&dwFlag),&dwDateSize); 
		if (lRetCode != ERROR_SUCCESS) 
		{ 
         bNoMsg=FALSE; 
         RegSetValueEx ( hKey1,"NoMsg",0,REG_DWORD,(LPBYTE)(&dwFlag),dwDateSize); 
      	return; 
   	} 
		bNoMsg=(BOOL)dwFlag; 
   } 
} 
 
void GetAppInfo(DWORD dwNum) 
{ 
	HKEY  hKey1;//, hKey2; 
  	DWORD  dwDisposition; 
  	LONG   lRetCode;
    DWORD dwDate,dwDateSize=sizeof(DWORD),dwCharSize;
    char szAppName[300];
    //char cmd[300];
    int i;
    char szSubKeyName[100],szTemp[]="SOFTWARE\\phonix\\sharewareluncher\\menuitem";
    MENUITEMINFO mi;
 
    mi.cbSize=sizeof(mi);
    mi.fMask=MIIM_TYPE | MIIM_ID;
   mi.fType=MFT_STRING;
   mi.fState=MFS_DEFAULT;
 
    for(i=0;i<(int)dwNum;i++)
    {
    	if(i<10)
       	wsprintf(szSubKeyName,"%s00%d",szTemp,i);
       else
       	wsprintf(szSubKeyName,"%s0%d",szTemp,i);
 
    	lRetCode=RegCreateKeyEx(HKEY_LOCAL_MACHINE,szSubKeyName,0, NULL, REG_OPTION_NON_VOLATILE,
                            KEY_QUERY_VALUE,NULL,&hKey1,&dwDisposition); 
   	if (lRetCode != ERROR_SUCCESS) 
   	{ 
     		Errmsg("Error in creating key\n");//,"Error",MB_OK); 
      	return ;//break; 
   	} 
      dwCharSize=80; 
   	lRetCode = RegQueryValueEx ( hKey1,"AppName",NULL,&dwDisposition,(LPBYTE)szAppName,&dwCharSize); 
 
  				// if we failed, note it, and leave 
		if (lRetCode != ERROR_SUCCESS) 
		{ 
     		Errmsg("Error in getting Section1 value\n");//,"Reg Error",MB_OK); 
      	return ;//break; 
   	} 
      wsprintf(aiAppInfo[i].szAppName,szAppName); 
 
      dwCharSize=300; 
   	lRetCode = RegQueryValueEx ( hKey1,"AppCmdLine",NULL,&dwDisposition,(LPBYTE)szAppName,&dwCharSize); 
 
  				// if we failed, note it, and leave 
		if (lRetCode != ERROR_SUCCESS) 
		{ 
     		Errmsg("Error in getting Section1 value\n");//,"Reg Error",MB_OK); 
      	return ;//break; 
   	} 
      wsprintf(aiAppInfo[i].szAppCmd,szAppName); 
 
      lRetCode = RegQueryValueEx ( hKey1,"Year",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); 
      	break; 
   	} 
      aiAppInfo[i].stVrDate.wYear=(WORD)dwDate; 
 
      lRetCode = RegQueryValueEx ( hKey1,"Month",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); 
      	break; 
   	} 
      aiAppInfo[i].stVrDate.wMonth=(WORD)dwDate; 
 
      lRetCode = RegQueryValueEx ( hKey1,"Day",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); 
      	break; 
   	} 
      aiAppInfo[i].stVrDate.wDay=(WORD)dwDate; 
 
   	mi.wID=11000+i;
   	//wsprintf(mi.dwTypeData,aiAppInfo[i].szAppName);
      mi.dwTypeData=aiAppInfo[i].szAppName;
   	mi.cch=strlen(aiAppInfo[i].szAppName);

      InsertMenuItem(hmenuTrackPopup,CM_SETCLOCK,FALSE,&mi);
      //InsertMenuItem(hmenuTrackPopup,i,TRUE,&mi);

      if(i==(int)(dwNum-1))
      {
      	mi.fType=MFT_SEPARATOR;
	   	InsertMenuItem(hmenuTrackPopup,CM_SETCLOCK,FALSE,&mi); 
         mi.fType=MFT_STRING; 
      } 
   } 
} 
 
void AddReg(APPINFO ai) 
{ 
	HKEY  hKey1;//, hKey2; 
  	DWORD  dwDisposition; 
  	LONG   lRetCode;
    DWORD dwFlag=(DWORD)nAppNum,dwDateSize=sizeof(DWORD);
    char cmd[150];
 
    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; 
   } 
 
	lRetCode = RegSetValueEx ( hKey1,"Num",NULL,REG_DWORD,(LPBYTE)(&dwFlag),dwDateSize); 
     				// if we failed, note it, and leave 
   if (lRetCode != ERROR_SUCCESS) 
	{ 
      nAppNum--; 
   	Errmsg("Error in getting Section1 value\n");//,"Reg Error",MB_OK); 
     	return; 
   } 
 
   if(naiIndex==-1) 
   { 
   	if(nAppNum<10) 
   		wsprintf(cmd,"SOFTWARE\\phonix\\sharewareluncher\\menuitem00%d",nAppNum-1); 
   	else 
   		wsprintf(cmd,"SOFTWARE\\phonix\\sharewareluncher\\menuitem0%d",nAppNum-1); 
   } 
   else 
   { 
   	if(naiIndex<10) 
   		wsprintf(cmd,"SOFTWARE\\phonix\\sharewareluncher\\menuitem00%d",naiIndex); 
   	else 
   		wsprintf(cmd,"SOFTWARE\\phonix\\sharewareluncher\\menuitem0%d",naiIndex); 
   } 
 
	lRetCode=RegCreateKeyEx(HKEY_LOCAL_MACHINE,cmd,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; 
   } 
 
   dwDateSize=80; 
   //lRetCode = 
   RegSetValueEx ( hKey1,"AppName",NULL,REG_SZ,(LPBYTE)(&(ai.szAppName)),dwDateSize); 
   dwDateSize=300; 
   //lRetCode = 
   RegSetValueEx ( hKey1,"AppCmdLine",NULL,REG_SZ,(LPBYTE)(&(ai.szAppCmd)),dwDateSize); 
   dwDateSize=sizeof(DWORD); 
   //lRetCode = 
   RegSetValueEx ( hKey1,"Year",NULL,REG_DWORD,(LPBYTE)(&(ai.stVrDate.wYear)),dwDateSize); 
   //lRetCode = 
   RegSetValueEx ( hKey1,"Month",NULL,REG_DWORD,(LPBYTE)(&(ai.stVrDate.wMonth)),dwDateSize); 
   //lRetCode = 
   RegSetValueEx ( hKey1,"Day",NULL,REG_DWORD,(LPBYTE)(&(ai.stVrDate.wDay)),dwDateSize); 
} 
 
int CutCmdLine(LPSTR s) 
{ 
	int i,j; 
   char szTemp[256]="\0"; 
 
   for(i=0;i<300;i++) 
   { 
   	if(s[i]=='\0') 
      { 
      	j=i; 
         break; 
      } 
   } 
 
   for(i=0;i<=j;i++) 
   { 
      if(s[i]=='\0') 
         return 0; 
   	if(s[i]!='e' && s[i]!='c' && s[i]!='b' && s[i]!='s' && s[i]!='E' && s[i]!='C' 
      	&& s[i]!='B' && s[i]!='S') 
   		szTemp[i]=s[i]; 
      else if(i>0) 
      { 
         if((j-i)<=2) 
         	return 0; 
      	switch(s[i]) 
         { 
         	case 'e': 
            case 'E': 
            	if((s[i+1]=='x' || s[i+1]=='X') && (s[i+2]=='e' || s[i+2]=='E') && 
                 	(s[i+3]==' ' || s[i+3]==NULL || s[i+3]=='\0') && s[i-1]=='.') 
					{ 
                  strcat(szTemp,"exe\0"); 
                  wsprintf(szErr,szTemp); 
                  return EXE; 
               } 
               szTemp[i]=s[i]; 
               break; 
            case 'c': 
            case 'C': 
            	if((s[i+1]=='o' || s[i+1]=='O') && (s[i+2]=='m' || s[i+2]=='M') && 
               	(s[i+3]==' ' || s[i+3]=='\0' || s[i+3]==NULL) && s[i-1]=='.') 
					{ 
               	strcat(szTemp,"com\0"); 
                  wsprintf(szErr,szTemp); 
                  return COM; 
               } 
               szTemp[i]=s[i]; 
               break; 
            case 'b': 
            case 'B': 
            	if((s[i+1]=='a' || s[i+1]=='A') && (s[i+2]=='t' || s[i+2]=='T') && 
               	(s[i+3]==' ' || s[i+3]=='\0' || s[i+3]==NULL) && s[i-1]=='.') 
					{ 
               	strcat(szTemp,"bat\0"); 
                  wsprintf(szErr,szTemp); 
                  return BAT; 
               } 
               szTemp[i]=s[i]; 
               break; 
            case 's': 
            case 'S': 
            	if((s[i+1]=='c' || s[i+1]=='C') && (s[i+2]=='r' || s[i+2]=='R') && 
               	(s[i+3]==' ' || s[i+3]=='\0' || s[i+3]==NULL) && s[i-1]=='.') 
					{ 
               	strcat(szTemp,"scr\0"); 
                  wsprintf(szErr,szTemp); 
                  return SCR; 
               } 
               szTemp[i]=s[i]; 
               break; 
            default: 
               szTemp[i]=s[i]; 
               break; 
         } 
      } 
      else 
         szTemp[i]=s[i]; 
   } 
   wsprintf(szErr,szTemp); 
   return 0; 
} 
/* 
void Add_PDOS(void) 
{ 
   bAddExe=TRUE; 
   bAddPDOS=TRUE; 
	SendMessage(hMainWnd,WM_COMMAND,CM_ADD,0); 
} 
 
void domsgAddPDOS(void) 
{ 
   char szwin[MAX_PATH]; 
 
   wsprintf(aiAppInfoTemp.szAppName,"中文DOS方式"); 
 
   wsprintf(aiAppInfoTemp.szAppCmd,"\0"); 
   GetWindowsDirectory(aiAppInfoTemp.szAppCmd,MAX_PATH); 
	strcat(aiAppInfoTemp.szAppCmd,"\\command\\pdos95.bat"); 
 
   if(!CheckExistFile(aiAppInfoTemp.szAppCmd)) 
   { 
   	SetCurrentDirectory(aiAppInfoTemp.szAppCmd); 
      if(!CheckExistFile("pbios.exe")) 
      	return; 
      if(!CheckExistFile("font16.exe")) 
      	return; 
      if(!CheckExistFile("pbios.exe")) 
      	return; 
   RegisterInfo(); 
 
   return TRUE; 
} */