⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 setup_c.cpp

📁 This software performs code conversion of Chinese characters, including GB2312/GBK and BIG5. It a
💻 CPP
📖 第 1 页 / 共 5 页
字号:
               }
            }

            return TRUE ;
         }

      default :
         break ;
   }

   return FALSE ;
}



////////////////////////////////////////////////////////
//               怴偟偄僼傽僀儖偺僐僺乕               //
////////////////////////////////////////////////////////



// 僼傽僀儖傪僐僺乕乮ANSI斉乯
// 僐僺乕偵幐攕偟僀儞僗僩乕儖傪拞巭偟偨傜 1 傪曉偡
int InstallFileA ( HWND hWnd, const char *szFileName, const char *szFolderName ) {

   char szSrcFileName [ MAX_PATH ] ;
   char szDstFileName [ MAX_PATH ] ;

   GetModuleFileNameA ( NULL, szSrcFileName, MAX_PATH ) ;
   ChangeFileNameA ( szSrcFileName, szFileName ) ;

   strcpy ( szDstFileName, szFolderName ) ;
   strcat ( szDstFileName, "\\" ) ;
   strcat ( szDstFileName, szFileName ) ;

   if ( ! strcmp ( szSrcFileName, szDstFileName ) ) return 0 ;

   if ( hWnd ) Dlg_Wm_SetTextFormatA ( hWnd, IDC_STATIC_PROG, "Copying  %s", szFileName ) ;

   if ( IsFileExistA ( szSrcFileName ) ) {

      if ( IsFileExistA ( szDstFileName ) ) SetFileAttributesA ( szDstFileName, 0 ) ;

      if ( CopyFileA ( szSrcFileName, szDstFileName, FALSE ) ) {
         SetFileAttributesA ( szDstFileName, FILE_ATTRIBUTE_ARCHIVE ) ;
         return 0 ;
      }
   }

   if ( MessageBoxFormatA ( hWnd, szCommandNameA, MB_OKCANCEL, GetStringA ( IDS_CANNOT_COPY ), szFileName ) == IDOK ) return 0 ;

   if ( hWnd ) {
      Dlg_Wm_SetTextA ( hWnd, IDC_STATIC_MESSAGE, GetStringA ( IDS_ABORT ) ) ;
      Dlg_Wm_SetTextA ( hWnd, IDC_STATIC_PROG, "" ) ;
      Dlg_EnableWindow ( hWnd, IDCANCEL, FALSE ) ;
      Dlg_Button_SetStyle ( hWnd, IDOK, BS_DEFPUSHBUTTON, TRUE ) ;
      Dlg_SetFocus ( hWnd, IDOK ) ;
   }

   MessageBeep ( MB_OK ) ;
   return 1 ;
}



// 僼傽僀儖傪僐僺乕乮UNICODE斉乯
// 僐僺乕偵幐攕偟僀儞僗僩乕儖傪拞巭偟偨傜 1 傪曉偡
int InstallFileW ( HWND hWnd, const wchar_t *szFileName, const wchar_t *szFolderName ) {

   wchar_t szSrcFileName [ MAX_PATH ] ;
   wchar_t szDstFileName [ MAX_PATH ] ;

   GetModuleFileNameW ( NULL, szSrcFileName, MAX_PATH ) ;
   ChangeFileNameW ( szSrcFileName, szFileName ) ;

   wcscpy ( szDstFileName, szFolderName ) ;
   wcscat ( szDstFileName, L"\\" ) ;
   wcscat ( szDstFileName, szFileName ) ;

   if ( ! wcscmp ( szSrcFileName, szDstFileName ) ) return 0 ;

   if ( hWnd ) Dlg_Wm_SetTextFormatW ( hWnd, IDC_STATIC_PROG, L"Copying  %s", szFileName ) ;

   if ( IsFileExistW ( szSrcFileName ) ) {

      if ( IsFileExistW ( szDstFileName ) ) SetFileAttributesW ( szDstFileName, 0 ) ;

      if ( CopyFileW ( szSrcFileName, szDstFileName, FALSE ) ) {
         SetFileAttributesW ( szDstFileName, FILE_ATTRIBUTE_ARCHIVE ) ;
         return 0 ;
      }
   }

   if ( MessageBoxFormatW ( hWnd, szCommandNameW, MB_OKCANCEL, GetStringW ( IDS_CANNOT_COPY ), szFileName ) == IDOK ) return 0 ;

   if ( hWnd ) {
      Dlg_Wm_SetTextW ( hWnd, IDC_STATIC_MESSAGE, GetStringW ( IDS_ABORT ) ) ;
      Dlg_Wm_SetTextW ( hWnd, IDC_STATIC_PROG, L"" ) ;
      Dlg_EnableWindow ( hWnd, IDCANCEL, FALSE ) ;
      Dlg_Button_SetStyle ( hWnd, IDOK, BS_DEFPUSHBUTTON, TRUE ) ;
      Dlg_SetFocus ( hWnd, IDOK ) ;
   }

   MessageBeep ( MB_OK ) ;
   return 1 ;
}



// 屆偄僼傽僀儖傪嶍彍乮ANSI斉乯
// 嶍彍偵幐攕偟僀儞僗僩乕儖傪拞巭偟偨傜 1 傪曉偡
int DeleteOldFileA ( HWND hWnd, const char *szFileName, const char *szFolderName ) {

   char szDstFileName [ MAX_PATH ] ;

   strcpy ( szDstFileName, szFolderName ) ;
   strcat ( szDstFileName, "\\" ) ;
   strcat ( szDstFileName, szFileName ) ;

   if ( ! IsFileExistA ( szDstFileName ) ) return 0 ;

   SetFileAttributesA ( szDstFileName, 0 ) ;

   if ( DeleteFileA ( szDstFileName ) ) {
      Dlg_Wm_SetTextFormatA ( hWnd, IDC_STATIC_PROG, "Deleting  %s", szFileName ) ;
      return 0 ;
   }

   if ( MessageBoxFormatA ( hWnd, szCommandNameA, MB_OKCANCEL, GetStringA ( IDS_CANNOT_DELETE ), szFileName ) == IDOK ) return 0 ;

   Dlg_Wm_SetTextA ( hWnd, IDC_STATIC_MESSAGE, GetStringA ( IDS_ABORT ) ) ;
   Dlg_Wm_SetTextA ( hWnd, IDC_STATIC_PROG, "" ) ;

   Dlg_EnableWindow ( hWnd, IDCANCEL, FALSE ) ;

   Dlg_Button_SetStyle ( hWnd, IDOK, BS_DEFPUSHBUTTON, TRUE ) ;
   Dlg_SetFocus ( hWnd, IDOK ) ;

   MessageBeep ( MB_OK ) ;
   return 1 ;
}



// 屆偄僼傽僀儖傪嶍彍乮UNICODE斉乯
// 嶍彍偵幐攕偟僀儞僗僩乕儖傪拞巭偟偨傜 1 傪曉偡
int DeleteOldFileW ( HWND hWnd, const wchar_t *szFileName, const wchar_t *szFolderName ) {

   wchar_t szDstFileName [ MAX_PATH ] ;

   wcscpy ( szDstFileName, szFolderName ) ;
   wcscat ( szDstFileName, L"\\" ) ;
   wcscat ( szDstFileName, szFileName ) ;

   if ( ! IsFileExistW ( szDstFileName ) ) return 0 ;

   SetFileAttributesW ( szDstFileName, 0 ) ;

   if ( DeleteFileW ( szDstFileName ) ) {
      Dlg_Wm_SetTextFormatW ( hWnd, IDC_STATIC_PROG, L"Deleting  %s", szFileName ) ;
      return 0 ;
   }

   if ( MessageBoxFormatW ( hWnd, szCommandNameW, MB_OKCANCEL, GetStringW ( IDS_CANNOT_DELETE ), szFileName ) == IDOK ) return 0 ;

   Dlg_Wm_SetTextW ( hWnd, IDC_STATIC_MESSAGE, GetStringW ( IDS_ABORT ) ) ;
   Dlg_Wm_SetTextW ( hWnd, IDC_STATIC_PROG, L"" ) ;

   Dlg_EnableWindow ( hWnd, IDCANCEL, FALSE ) ;

   Dlg_Button_SetStyle ( hWnd, IDOK, BS_DEFPUSHBUTTON, TRUE ) ;
   Dlg_SetFocus ( hWnd, IDOK ) ;

   MessageBeep ( MB_OK ) ;
   return 1 ;
}



// 僶僢僠僼傽僀儖傪嶌惉乮ANSI斉乯
int MakeBatchFileA ( const char *szFolderName, int IsForEnglish ) {

   char szBatchFileName [ MAX_PATH ] ;
   int nLangIdPrev ;

   if ( IsForEnglish ) nLangIdPrev = SetResourceLanguage ( LANGID_ENGLISH ) ;

   // 僶僢僠僼傽僀儖柤
   strcpy ( szBatchFileName, szFolderName ) ;
   strcat ( szBatchFileName, "\\" ) ;
   if ( IsForEnglish ) strcat ( szBatchFileName, BATCH_FILE_NAME_E_A ) ;
   else                strcat ( szBatchFileName, BATCH_FILE_NAME_J_A ) ;

   SetFileAttributesA ( szBatchFileName, 0 ) ;
   DeleteFileA ( szBatchFileName ) ;

   // 僶僢僠僼傽僀儖偺彂偒崬傒
   FILE *Fout = fsopen ( szBatchFileName, "w", _SH_DENYWR ) ;
   if ( Fout ) {

      fputs ( "@echo off\n", Fout ) ;
      fputs ( GetStringA ( IDS_BAT_MESSAGE ), Fout ) ;
      fputs ( "\n", Fout ) ;

      // NT宯側傜丄僷僗偺愝掕偼 loadcmd.exe 偱
      // 96宯側傜丄僷僗偺愝掕偼僶僢僠僼傽僀儖偱
      if ( ! IsNT () ) {
         fputs ( "doskey /insert > nul\nrem prompt $e[;37;1;40m$P$G\n", Fout ) ;
         if ( strchr ( szFolderName, 0x20 ) ) fprintf ( Fout, "path %%path%%;\"%s\"\n", szFolderName ) ;
         else                                 fprintf ( Fout, "path %%path%%;%s\n", szFolderName ) ;
      }

      fclose ( Fout ) ;
   }

   if ( IsForEnglish ) SetResourceLanguage ( nLangIdPrev ) ;

   return 0 ;
}



// 僶僢僠僼傽僀儖傪嶌惉乮UNICODE斉乯
int MakeBatchFileW ( const wchar_t *szFolderName, int IsForEnglish ) {

   wchar_t szBatchFileName [ MAX_PATH ] ;
   int nLangIdPrev ;

   if ( IsForEnglish ) nLangIdPrev = SetResourceLanguage ( LANGID_ENGLISH ) ;

   // 僶僢僠僼傽僀儖柤
   wcscpy ( szBatchFileName, szFolderName ) ;
   wcscat ( szBatchFileName, L"\\" ) ;
   if ( IsForEnglish ) wcscat ( szBatchFileName, BATCH_FILE_NAME_E_W ) ;
   else                wcscat ( szBatchFileName, BATCH_FILE_NAME_J_W ) ;

   SetFileAttributesW ( szBatchFileName, 0 ) ;
   DeleteFileW ( szBatchFileName ) ;

   // 僶僢僠僼傽僀儖偺彂偒崬傒
   FILE *Fout = wfsopen ( szBatchFileName, L"w", _SH_DENYWR ) ;
   if ( Fout ) {

      fputws ( L"@echo off\n", Fout ) ;
      fputws ( GetStringW ( IDS_BAT_MESSAGE ), Fout ) ;
      fputws ( L"\n", Fout ) ;

      // NT宯側傜丄僷僗偺愝掕偼 loadcmd.exe 偱
      // 96宯側傜丄僷僗偺愝掕偼僶僢僠僼傽僀儖偱
      if ( ! IsNT () ) {
         fputws ( L"doskey /insert > nul\nrem prompt $e[;37;1;40m$P$G\n", Fout ) ;
         if ( wcschr ( szFolderName, 0x20 ) ) fwprintf ( Fout, L"path %%path%%;\"%s\"\n", szFolderName ) ;
         else                                 fwprintf ( Fout, L"path %%path%%;%s\n", szFolderName ) ;
      }

      fclose ( Fout ) ;
   }

   if ( IsForEnglish ) SetResourceLanguage ( nLangIdPrev ) ;

   return 0 ;
}



// 僔儑乕僩僇僢僩傪嶌惉乮ANSI斉乯
int MakeShortcutA ( const char *szShortcutFolder, const char *szFolderName, int IsDesktop ) {

   char szComspecBuffer [ MAX_PATH ] ;
   char *szComspec = szComspecBuffer ;
   char *szTmp ;

   if ( IsNT () ) {
      if ( ! GetEnvironmentVariableA ( "COMSPEC", szComspec, MAX_PATH ) ) {
         int nResult = SearchPathA ( NULL, "CMD.EXE", NULL, MAX_PATH, szComspec, & szTmp ) ;
         if ( nResult <= 0 || nResult >= MAX_PATH ) szComspec = NULL ;
      }
   }
   else {
      int nResult = SearchPathA ( NULL, "PIFMGR.DLL", NULL, MAX_PATH, szComspec, & szTmp ) ;
      if ( nResult <= 0 || nResult >= MAX_PATH ) szComspec = NULL ;
   }


   char szLinkFileName [ MAX_PATH ] ;
   char szFileName [ MAX_PATH ] ;

   // 幚峴僼傽僀儖
   sprintf ( szFileName, "%s\\%s", szFolderName, ( InstallFileName [ 0 ] ).A ) ;
   sprintf ( szLinkFileName, "%s\\%s", szShortcutFolder, GetStringA ( IDS_EXE_LINK ) ) ;
   if ( IsFileExistA ( szLinkFileName ) ) { DeleteFileA ( szLinkFileName ) ; Sleep ( 200 ) ; }
   CreateShortcutA ( szLinkFileName, szFileName, NULL, NULL, NULL, NULL, 0, 0, 0, NULL, NULL ) ;

   // 僐儅儞僪儔僀儞
   sprintf ( szFileName, "%s\\%s", szFolderName, ( InstallFileName [ 3 ] ).A ) ;
   sprintf ( szLinkFileName, "%s\\%s", szShortcutFolder, GetStringA ( IDS_COM_LINK ) ) ;
   if ( IsFileExistA ( szLinkFileName ) ) { DeleteFileA ( szLinkFileName ) ; Sleep ( 200 ) ; }
   CreateShortcutA ( szLinkFileName, szFileName, NULL, NULL, NULL, szComspec, 0, 0, 0, NULL, NULL ) ;

   if ( ! IsDesktop ) {

      // 僿儖僾僼傽僀儖
      sprintf ( szFileName, "%s\\%s", szFolderName, GetStringA ( IDS_HELPFILE_HTML_FILENAME ) ) ;
      sprintf ( szLinkFileName, "%s\\%s", szShortcutFolder, GetStringA ( IDS_HELP_LINK ) ) ;
      if ( IsFileExistA ( szLinkFileName ) ) { DeleteFileA ( szLinkFileName ) ; Sleep ( 200 ) ; }
      CreateShortcutA ( szLinkFileName, szFileName, NULL, NULL, NULL, NULL, 0, 0, 0, NULL, NULL ) ;

      // 傾儞僀儞僗僩乕儔
      sprintf ( szFileName, "%s\\%s", szFolderName, "setup.exe" ) ;
      sprintf ( szLinkFileName, "%s\\%s", szShortcutFolder, GetStringA ( IDS_UNINSTALL_LINK ) ) ;
      if ( IsFileExistA ( szLinkFileName ) ) { DeleteFileA ( szLinkFileName ) ; Sleep ( 200 ) ; }
      CreateShortcutA ( szLinkFileName, szFileName, "/r", NULL, NULL, NULL, 0, 0, 0, NULL, NULL ) ;
   }

   return 0 ;
}



// 僔儑乕僩僇僢僩傪嶌惉乮UNICODE斉乯
int MakeShortcutW ( const wchar_t *szShortcutFolder, const wchar_t *szFolderName, int IsDesktop ) {

   wchar_t szComspecBuffer [ MAX_PATH ] ;
   wchar_t *szComspec = szComspecBuffer ;
   wchar_t *szTmp ;

   if ( IsNT () ) {
      if ( ! GetEnvironmentVariableW ( L"COMSPEC", szComspec, MAX_PATH ) ) {
         int nResult = SearchPathW ( NULL, L"CMD.EXE", NULL, MAX_PATH, szComspec, & szTmp ) ;
         if ( nResult <= 0 || nResult >= MAX_PATH ) szComspec = NULL ;
      }
   }
   else {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -