»áÔ±£º ÃÜÂ룺 ¡¡Ãâ·Ñ×¢²á | Íü¼ÇÃÜÂë | »áÔ±µÇ¼ ÍøÒ³¹¦ÄÜ£º ¼ÓÈëÊÕ²Ø ÉèΪÊ×Ò³ ÍøÕ¾ËÑË÷  
 °²È«¼¼Êõ¼¼ÊõÎĵµ
  ¡¤ °²È«ÅäÖÆ
  ¡¤ ¹¤¾ß½éÉÜ
  ¡¤ ºÚ¿Í½Ìѧ
  ¡¤ ·À»ðǽ
  ¡¤ Â©¶´·ÖÎö
  ¡¤ ÆƽâרÌâ
  ¡¤ ºÚ¿Í±à³Ì
  ¡¤ ÈëÇÖ¼ì²â
 °²È«¼¼ÊõÂÛ̳
  ¡¤ °²È«ÅäÖÆ
  ¡¤ ¹¤¾ß½éÉÜ
  ¡¤ ·À»ðǽ
  ¡¤ ºÚ¿ÍÈëÇÖ
  ¡¤ Â©¶´¼ì²â
  ¡¤ Æƽⷽ·¨
  ¡¤ É±¶¾×¨Çø
 °²È«¼¼Êõ¹¤¾ßÏÂÔØ
  ¡¤ É¨Ã蹤¾ß
  ¡¤ ¹¥»÷³ÌÐò
  ¡¤ ºóÃÅľÂí
  ¡¤ ¾Ü¾ø·þÎñ
  ¡¤ ¿ÚÁîÆƽâ
  ¡¤ ´úÀí³ÌÐò
  ¡¤ ·À»ðǽ
  ¡¤ ¼ÓÃܽâÃÜ
  ¡¤ ÈëÇÖ¼ì²â
  ¡¤ ¹¥·ÀÑÝʾ
°²È«·ÀÏß > ºÚ¿Í±à³Ì
ÈçºÎ½«¶à¸öÎļþÀ¦°ó³ÉÒ»¸ö¿ÉÖ´ÐÐÎļþ
·¢±íÈÕÆÚ£º2003-10-30 00:00:00×÷ÕߣºÐ ³ö´¦£º  

ÏÂÔØʾÀý³ÌÐò´úÂë(http://www.csdn.net/cnshare/soft/10/10356.shtm)

½«¶à¸öÎļþºÏ²¢³ÉÒ»¸ö×îÖÕ¿ÉÖ´ÐÐÎļþ£¬ÔËÐÐÕâ¸ö×îÖպϳÉÎļþºó£¬¾ÍÏ൱ÓÚÔËÐÐÁ˺ϲ¢Ç°µÄ¶à¸öÎļþ¡£ÕâÖÖ³ÌÐòÔÚľÂí³ÌÐòºÏ²¢Öлᾭ³£Óõ½£¬ÄãÏëÖªµÀËüÊÇÔõôÓóÌÐòʵÏÖµÄô£¿ÏÂÃæÎÒ¾ÍÄÃÎÒÓÃVC6.0×öµÄÒ»¸öÎļþÀ¦°óÆ÷µÄÀý×Ó´úÂëÀ´¸æËßÄ㣬³ÌÐòÔËÐкó½çÃæÈçÏ£º

 

ͼÀý

»ù±¾¹¹³É˼Ï룺Æäʵ£¬ÆäÖеĹ¹³É˼Ïë·Ç³£¼òµ¥¡£ºÏ²¢Îļþʱ£º½¨Á¢Ò»¸öеĶþ½øÖÆÎļþ£¬ÏÈдÈëÄãµÄ×ÔÉíÀ¦°ó³ÌÐòµÄÊý¾ÝºÍÆäÎļþ³¤¶È£¬ÔÙдÈëÄãÒªÀ¦°óµÄµÚÒ»¸öÎļþµÄÊý¾ÝºÍÆäÎļþ³¤¶È£¬ºóÔÙÖ±½ÓдÈëÄãÒªÀ¦°óµÄµÚ¶þ¸öÎļþµÄÊý¾ÝºÍÎļþ³¤¶È¡­¡­£¬×îºó¿ÉÖ±½ÓдÈëÄãÒªÀ¦°óµÄ×îºóÒ»¸öÎļþµÄÊý¾Ý(²»ÐèÆäÎļþ³¤¶È)¡£·Ö½âÊÍ·Å×îÖպϳÉÎļþʱ£¬Ò²¾ÍÊǽ«ÉÏÃæµÄ·½·¨Ë¼Ïëµ¹¹ýÀ´¼È¿É£º´ò¿ª×îÖպϳÉÎļþ£¬¶ÁÈ¡Ô´×ÔÉíÀ¦°ó³ÌÐòÎļþ³¤¶È£¬½«ÎļþÖ¸ÕëÒƵ½×ÔÉíÀ¦°ó³ÌÐòÊý¾Ýºó£¬¶ÁÈ¡µÚÒ»¸ö±»°ó¶¨ÎļþµÄ³¤¶È£¬½Ó×ŶÁÈ¡Æ䳤¶ÈµÄÎļþÊý¾Ý²¢Ð´È뵽һн¨Îļþ1ÖУ¬ÔÙ¶ÁÈ¡µÚ¶þ¸ö±»°ó¶¨ÎļþµÄ³¤¶È£¬½Ó×ŶÁÈ¡Æ䳤¶ÈµÄÊý¾Ý²¢Ð´È뵽н¨Îļþ2ÖС­¡­£¬Ö±µ½×îºóÖ±½Ó¶ÁÈ¡×îºóÒ»¸ö±»°ó¶¨ÎļþµÄÊý¾Ý²¢½«ÆäдÈëµ½×îºóÒ»¸öн¨ÎļþÖмȿɡ£(ÏÂÃæʵÀý½ö¸æËßÄãÈçºÎʵÏÖ¶þ¸öÎļþµÄÀ¦°ó£¬ÖÁÓÚ¶à¸öÎļþµÄÀ¦°ó£¬¶ÁÕßÖ»ÐèÂԼӸĶ¯¼È¿É£¬ÏêÇéÇë²é¿´ÏÂÔغóµÄʵÀý´úÂë¡£)

ÏÂÃæÎÒÀ´½²½²ÎļþÀ¦°ó×îºËÐĵIJ¿·Ö£¬ÒÔ¼°ÈçºÎ¾ßÌ彫ÆäÓôúÂëÀ´ÊµÏֵķ½·¨£º

1¡¢  À¦°ó¶à¸öÎļþΪһ¸ö¿ÉÖ´ÐгÌÐò

Ïȵõ½×ÔÉíÀ¦°ó³ÌÐòµÄÎļþ³¤¶ÈºÍµÚÒ»¸öÒªÀ¦°óÎļþµÄÎļþ³¤¶È£¬Ã¶¾ÙµÚÒ»¸öÒªÀ¦°óÎļþÓÐÎÞͼ±ê£¬ÓеĻ°¾ÍÓÃËü×öΪ×îÖÕÉú³ÉÎļþµÄͼ±ê£¬·ñÔòÓÃ×ÔÉíÀ¦°ó³ÌÐòËù´øĬÈÏͼ±ê×ö×îÖÕÉú³ÉÎļþµÄͼ±ê¡£ÔÚн¨¶þ½øÖÆÎļþÖÐдÈë×ÔÉíÀ¦°ó³ÌÐòµÄÊý¾ÝºÍÆäÎļþ³¤¶È£¬ÔÙдÈëµÚÒ»¸öÒªÀ¦°óÎļþµÄÊý¾Ý¼°ÆäÎļþ³¤¶È£¬×îºóÖ±½ÓдÈëµÚ¶þ¸öÎļþµÄÊý¾Ý¼È¿É¡£

  ºÏ²¢³ÌÐòº­ÊýµÄ¾ßÌå´úÂëʵÏÖÈçÏ£º

//¶¨ÒåҪʹÓõ½µÄÀ¦°ó³ÌÐò×ÔÉíÎļþÐÅÏ¢µÄ½á¹¹Ìå

struct MODIFY_DATA {

   unsigned int finder;  // ³£Á¿(¶¨Î»×ÔÉí)

   _off_t my_length;   //Îļþ³¤¶È(×ÔÉí)

} modify_data = {0x12345678, 0};

//°ó¶¨¶þ¸öÎļþΪһ¸ö¿ÉÖ´ÐÐÎļþ

bool CBindFileDlg::Bind_Files()

{

   FILE* myself;  //×ÔÉíÎļþ

   FILE* out;   //×îÖպϳÉÎļþ

   FILE* in;    //´ý°ó¶¨Îļþ

   int bytesin;  //Ò»´Î¶ÁÎļþ×Ö½ÚÊý

   int totalbytes = 0; //¶Á³öÎļþ×Ü×Ö½ÚÊý

   struct _stat ST;   //ÎļþµÄ״̬ÐÅÏ¢(ÈçÎļþ³¤¶ÈµÈ)

   unsigned int finder = 0x12345678; //×ÔÉíÎļþ¶¨Î»

   unsigned int i, k;

   int l=1;        //½ø¶ÈÌõ״̬ÏÔʾ±äÁ¿

   char buff[20];     //½ø¶ÈÌõ״̬ÏÔʾ±äÁ¿

   his_name = strFirstFilePath; //µÚÒ»¸ö°ó¶¨µÄÎļþÃû

   _stat(my_name, &ST);     //»ñÈ¡×ÔÉíÀ¦°óÎļþÐÅÏ¢

   modify_data.my_length = ST.st_size; //µÃµ½×ÔÉíÎļþ³¤¶È

   if (modify_data.my_length == 0)

   {

     MessageBox("°ó¶¨ÎļþÖУ¬×ÔÉíÎļþ³¤¶ÈΪÁãʱ³ö´í!","´íÎó");

     return false;

   }

   buf = (BYTE *)malloc(modify_data.my_length); //·ÖÅäÒ»¶¨´óС»º³åÇø

   if (buf == NULL)

   {

     MessageBox("°ó¶¨ÎļþÖУ¬·ÖÅä×ÔÉíÎļþ³¤¶Èʱ³ö´í!","´íÎó");

     return false;

   }

   myself = fopen(my_name, "rb"); //´ò¿ª×ÔÉíÎļþ

   if (myself == NULL)

   {

     free(buf);

     MessageBox("°ó¶¨ÎļþÖУ¬´ò¿ª×ÔÉíÎļþʱ³ö´í!","´íÎó");

     return false;

   }

   //ÏȶÁÈ¡À¦°ó³ÌÐò×ÔÉíÎļþÊý¾Ý

   bytesin = fread(buf, 1, modify_data.my_length, myself);

   fclose(myself);

   if (bytesin != modify_data.my_length)

   {

     free(buf);

     MessageBox("°ó¶¨ÎļþÖУ¬²»ÄÜÍêÈ«¶ÁÈ¡×ÔÉíÎļþÄÚÈÝʱ³ö´í!","´íÎó");

     return false;

   }

  //´æ´¢×ÔÉíÎļþÐÅÏ¢µ½»º³åÇø(È糤¶È)

   for (i = 0; i < modify_data.my_length - sizeof(finder); i += sizeof(finder))

   {

     for (k = 0; k < sizeof(finder); k++)

     {

        if (buf[i+k] != ((BYTE*)&finder)[k])

          break;

     }

     if (k == sizeof(finder))  //¶¨Î»²¢±£´æ×ÔÉíÊý¾ÝÎļþÐÅÏ¢

     {

        memcpy(buf+ i, &modify_data, sizeof(modify_data));

        break;

     }

   }

   if (i >= modify_data.my_length - sizeof(finder))

   {

     free(buf);

     MessageBox("°ó¶¨ÎļþÖУ¬²»Äܶ¨Î»×ÔÉíÎļþʱ³ö´í!","´íÎó");

     return false;

   }

  //»ñÈ¡µÚÒ»¸öÒª°ó¶¨ÎļþµÄÐÅÏ¢(Îļþ³¤¶È)

   if (_stat(strFirstFilePath, &ST) != 0 || ST.st_size == 0)

   {

     free(buf);

     MessageBox("°ó¶¨ÎļþÖУ¬¶ÁÈ¡µÚÒ»¸öÒª°ó¶¨Îļþʱ³ö´í!","´íÎó");

     return false;

   }

//»ñÈ¡×ÔÉíÎļþͼ±ê¼°µÚÒ»¸öÒª°ó¶¨ÎļþµÄͼ±ê(ÈçµÚÒ»¸öÒª°ó¶¨ÎļþûÓÐͼ±ê£¬

//ÔòÓÃ×ÔÉíÎļþͼ±ê¡£Æ亭ÊýʵÏÖÇë²Î¿´Àý³Ì)

   list_my_icons();

   out = fopen(strFinalFilePath, "wb"); //´´½¨×îÖպϳÉÎļþ

   if (out == NULL)

   {

     free(buf);

     MessageBox("°ó¶¨ÎļþÖУ¬´´½¨°ó¶¨ºóÉú³ÉµÄºÏ³ÉÎļþʱ³ö´í!","´íÎó");

     return false;

   }

   //ÏȽ«Ç°Ãæ¶Á³öµÄ×ÔÉíÀ¦°ó³ÌÐòµÄÊý¾ÝдÈë×îÖպϳÉÎļþÖÐ

   totalbytes += fwrite(buf, 1, bytesin, out);

   in = fopen(strFirstFilePath, "rb"); //´ò¿ªµÚÒ»¸öÒª°ó¶¨µÄÎļþ

   if (in == NULL)

   {

     free(buf);

     MessageBox("°ó¶¨ÎļþÖУ¬´ò¿ªµÚÒ»¸öÒª°ó¶¨Îļþʱ³ö´í!","´íÎó");

     return false;

   }

   //дÈëµÚÒ»¸öÒª°ó¶¨ÎļþµÄ³¤¶Èµ½×îÖպϳÉÎļþÖÐ

   totalbytes += fwrite(&ST.st_size, 1, sizeof(ST.st_size), out);

   //дÈë×îÖÕ·Ö½âºóÎļþÖ´Ðз½Ê½µÄ±ê־λ(ͬ²½»òÒì²½Ö´ÐÐ)

   UpdateData(TRUE); //´«¿Ø¼þÖµµ½±äÁ¿m_SyncÖÐ

   totalbytes += fwrite(&m_Sync, 1, sizeof(int), out);

   //дÈëµÚÒ»¸öÒª°ó¶¨ÎļþµÄÊý¾Ýµ½×îÖպϳÉÎļþÖÐ

   while (bytesin = fread(buf, 1, modify_data.my_length, in))

   {

     totalbytes += fwrite(buf, 1, bytesin, out);

   }

   fclose(in); //¹Ø±ÕµÚÒ»¸ö°ó¶¨Îļþ¾ä±ú

   //ÉèÖýø¶ÈÌõÏÔʾ

   m_Progress.SetRange(0,500);

   for (int m = 0; m < 500; m++)

    m_Progress.SetPos(m);

   m_Parts = _ltoa(l, buff, 10);

   m_Parts += _T("¸öÎļþÒÑ°ó¶¨");

   UpdateData(FALSE);

   l++;

   in = fopen(strSecondFilePath, "rb");  //´ò¿ªµÚ¶þ¸öÒª°ó¶¨µÄÎļþ

   if (in == NULL)

   {

     free(buf);

     MessageBox("°ó¶¨ÎļþÖУ¬´ò¿ªµÚ¶þ¸öÒª°ó¶¨Îļþʱ³ö´í!","´íÎó");

     return false;

}

//Ö±½ÓдÈëµÚ¶þ¸öÒª°ó¶¨ÎļþµÄÊý¾Ýµ½×îÖպϳÉÎļþÖÐ

   while (bytesin = fread(buf, 1, modify_data.my_length, in))

   {

     totalbytes += fwrite(buf, 1, bytesin, out);

   }

   //ÉèÖýø¶ÈÌõÏÔʾ

   m_Progress.SetRange(0,500);

   for (int n = 0; n < 500; n++)

    m_Progress.SetPos(n);

   m_Parts = _ltoa(l, buff, 10);

   m_Parts += _T("¸öÎļþÒÑ°ó¶¨");

   UpdateData(FALSE);

   l++;

   fclose(in); //¹Ø±ÕµÚ¶þ¸ö°ó¶¨Îļþ¾ä±ú

   fclose(out); //¹Ø±Õ×îÖպϳÉÎļþ¾ä±ú

   free(buf);  //ÊÍ·Å»º³åÇø

   return true;

}

2¡¢  ÊÍ·Å×îÖպϳÉÎļþ²¢Í¬3¡¢  Ê±ÔËÐÐËüÃÇ¡£

´ò¿ª×ÔÉíÎļþ£¬´ÓÖеõ½×ÔÉíÀ¦°ó³ÌÐòµÄÎļþ³¤¶È£¬±ã¿É½«ÎļþÖ¸Õ붨λµ½µÚÒ»¸ö±»À¦°óÎļþµÄλÖ㬶ÁÈ¡ÆäÎļþ³¤¶ÈºÍÆäÊý¾Ý£¬½«Æä¶Á³öÊý¾ÝдÈëµÚÒ»¸öн¨ÎļþÖС£Í¬Ñù£¬Í¨¹ýÒѶÁÈ¡µÄ×ÔÉíÀ¦°ó³ÌÐòÎļþ³¤¶ÈºÍµÚÒ»¸ö±»À¦°óÎļþµÄÎļþ³¤¶È¼ÓÉÏÆä±£´æÕâÁ½¸öÎļþ³¤¶ÈÖµµÄ×Ö½ÚÊý£¬¼È¿É׼ȷ¶¨Î»µÚ¶þ¸ö±»À¦°óÎļþµÄλÖ㬶ÁÈ¡ÆäÊý¾Ý£¬Ð´Èëµ½µÚ¶þ¸öн¨ÎļþÖС£Í¬Ê±£¬ÔËÐÐÕâÁ½¸öÎļþ£¬×îºóÔÙɾ³ýÕâÁ½¸öÎļþ¼È¿É¡£

  ÊÍ·Å×îÖպϳÉÎļþµÄ´úÂë¾ßÌåʵÏÖÈçÏ£º

//´´½¨·Ö½âÎļþºó£¬ÔËÐи÷·Ö½âÎļþʱµÄ½ø³Ì

void CBindFileDlg::Create_Process(const char* temp_exe, BOOL async)

{

   HANDLE hProcess;      //½ø³Ì¾ä±ú

   HANDLE hThread;      //Ï߳̾ä±ú

   PROCESS_INFORMATION PI;  //½ø³ÌÐÅÏ¢

   STARTUPINFO SI;      //Æô¶¯ÐÅÏ¢

   memset(&SI, 0, sizeof(SI));  //·ÖÅäÒ»¶¨µÄÄÚ´æ

   SI.cb = sizeof(SI);      //´óС¸³¸øÆô¶¯ÐÅÏ¢ÄÚCB

   CreateProcess(temp_exe, NULL, NULL, NULL, FALSE,NORMAL_PRIORITY_CLASS, NULL, NULL, &SI, &PI);   

/* --- Ôݲ»Ó㬷ñÔòÐèÒª±£´æԭʼ°ó¶¨µÄÎļþÃû³Æ 

   //Èç¹û·Ö½âºóµÄÎļþ²»ÊÇÖ´ÐÐÎļþµÄ»°£¬ÔòÖ±½Ó´ò¿ªËü

   if(!CreateProcess(temp_exe, NULL, NULL, NULL, FALSE,NORMAL_PRIORITY_CLASS, NULL, NULL, &SI, &PI))

     HINSTANCE result =ShellExecute(NULL, _T("open"), temp_exe, NULL,NULL, SW_SHOW);  

--- */   

    hProcess = PI.hProcess;    

   hThread = PI.hThread;

   //Òì²½Ö´ÐÐʱ£¬Ö´Ðкó²»É¾³ý·Ö½âºóµÄÎļþ;ͬ²½Ö´ÐÐʱ£¬Ö´Ðкóɾ³ý·Ö½âºóµÄÎļþ

   if (!async) //µ±Í¬²½Ö´ÐÐʱ

   {

     //Ò»Ö±µÈ´ý£¬Ö±µ½µ±Ç°³ÌÐòÔËÐнø³Ì½áÊø

     WaitForSingleObject(hProcess, INFINITE);

     unlink(temp_exe);  //ɾ³ýtemp.exeÎļþ

   }

}

//·Ö½âÒѺϲ¢µÄÎļþ£¬Í¬Ê±ÔËÐÐËüÃÇ

void CBindFileDlg::Unbind()

{

   FILE* myself;           //×ÔÉíÎļþ

   FILE* out;            //·Ö½âºóÎļþ

   int bytesin;           //Ò»´Î¶Á³öÎļþµÄ×Ö½ÚÊý

   int totalbytes = 0;        //¶Á³öÎļþµÄ×Ü×Ö½ÚÊý

   char temp_exe1[] = "temp1.exe"; //·Ö½âºóµÄ°ó¶¨ÎļþÃûÒ»(¿ÉÈÎÒâÈ¡)

   char temp_exe2[] = "temp2.exe"; //·Ö½âºóµÄ°ó¶¨ÎļþÃû¶þ(¿ÉÈÎÒâÈ¡)

    int SyncFlag;         //Îļþ×îÖÕÖ´ÐбêÖ¾(ͬ²½»òÒì²½)

     //ÏÈ·ÖÅäÒ»¶¨´óСµÄ»º³åÇø(´óСµÈÓÚÀ¦°ó³ÌÐò³¤¶È)

   buf = (BYTE*)malloc(modify_data.my_length);

   myself = fopen(my_name, "rb"); //´ò¿ª×îÖպϳÉÎļþ

   if (myself == NULL)

   {

     free(buf);

   MessageBox("·ÖÀëÎļþÖУ¬´ò¿ª×ÔÉíÎļþʱ³ö´í!","´íÎó");

     return;

   }

   out = fopen(temp_exe1, "wb");  //´´½¨µÚÒ»¸ö°ó¶¨µÄÎļþ

   if (out == NULL)

   {

     free(buf);

    MessageBox("·ÖÀëÎļþÖУ¬´´½¨µÚÒ»¸ö±»°ó¶¨Îļþʱ³ö´í!","´íÎó");

     return;

   }

   //½«ÎļþÖ¸Õ붨λµ½À¦°óÆ÷³ÌÐò³¤¶Èβ²¿

 fseek(myself, modify_data.my_length, SEEK_SET);

   //¶ÁÈ¡µÚÒ»¸ö°ó¶¨ÎļþµÄ³¤¶È¡¡

   if (fread(&prog1_length, sizeof(prog1_length), 1, myself) == 0)

   {

     free(buf);

   MessageBox("·ÖÀëÎļþÖУ¬¶ÁÈ¡µÚÒ»¸ö±»°ó¶¨Îļþ³¤¶Èʱ³ö´í!","´íÎó");

     return;

   }

   //¶ÁÈ¡×îÖÕÎļþÖ´Ðз½Ê½(ͬ²½»òÒì²½Ö´ÐÐ)

   if (fread(&SyncFlag, sizeof(int), 1, myself) == 0)

   {

     free(buf);

   MessageBox("·ÖÀëÎļþÖУ¬¶ÁÈ¡µÚÒ»¸ö±»°ó¶¨Îļþ³¤¶Èʱ³ö´í!","´íÎó");

     return;

   }

   

   //¶ÁÈ¡µÚÒ»¸öÎļþÄÚÈݲ¢Ð´È뵽н¨µÄtemp1.exeÎļþÖÐ

   while (bytesin = fread(buf, 1, sizeof(buf), myself))

   {

     if (totalbytes + bytesin > prog1_length)

        bytesin = prog1_length - totalbytes;

     totalbytes += fwrite(buf, 1, bytesin, out);

   }

   fclose(out); //¹Ø±ÕµÚÒ»¸ö°ó¶¨Îļþ¾ä±ú

#ifdef DEBUG_PRINT

   fprintf(stderr, "ÒѸ´ÖÆ %d ×Ö½Ú!\n", totalbytes);

#endif DEBUG_PRINT

   totalbytes = 0;

   out = fopen(temp_exe2, "wb");   //´´½¨µÚ¶þ¸ö°ó¶¨µÄÎļþ

   if (out == NULL)

   {

     free(buf);

    MessageBox("·ÖÀëÎļþÖУ¬´´½¨µÚ¶þ¸ö±»°ó¶¨Îļþʱ³ö´í!","´íÎó");

     return;

   }

   //½«ÎļþÖ¸Õ붨λµ½×îÖպϳÉÎļþÖеĵڶþ¸ö°ó¶¨ÎļþÍ·²¿, Æ«ÒÆÁ¿ ==

   //(À¦°óÆ÷×ÔÉíÎļþ³¤¶È+±£´æµÚÒ»¸ö°ó¶¨Îļþ³¤¶ÈËùÕ¼×Ö½ÚÊý+±£´æ×îÖÕÎļþÖ´ÐбêÖ¾ËùÕ¼×Ö½ÚÊý+µÚÒ»¸ö°ó¶¨Îļþ³¤¶È)

   fseek(myself,modify_data.my_length+ sizeof(modify_data.my_length) + sizeof(int) + prog1_length, SEEK_SET);

  

   //¶ÁÈ¡µÚ¶þ¸ö°ó¶¨ÎļþÄÚÈݲ¢Ð´È뵽н¨µÄtemp2.exeÎļþÖÐ

   while (bytesin = fread(buf, 1, sizeof(buf), myself))

{

   totalbytes += fwrite(buf, 1, bytesin, out);

 }

   fclose(out); //¹Ø±ÕµÚ¶þ¸ö°ó¶¨Îļþ¾ä±ú

#ifdef DEBUG_PRINT

   fprintf(stderr, "ÒѸ´ÖÆ %d ×Ö½Ú\n", totalbytes);

#endif DEBUG_PRINT

   fclose(myself); //¹Ø±Õ×îÖպϳÉÎļþ¾ä±ú

   if (totalbytes == 0)

   {

     free(buf);

    MessageBox("·ÖÀëÎļþÖУ¬ÔÚ×ÔÉíÎļþÖÐûÓб»·ÖÀëµÄ¶ÔÏó!","´íÎó");

     return;

   }

   free(buf);  //ÊÍ·Å»º³åÇø

//ÅжÏÇ°Ãæ¶ÁÈ¡µÄ×îÖÕÎļþÖ´ÐбêÖ¾£¬À´¾ö¶¨ÒÔºÎÖÖ·½Ê½ÔËÐÐËü

   if(!SyncFlag) //(0 -- ͬ²½Ö´ÐУ¬1 -- Òì²½Ö´ÐÐ)

   {

    //ÖÃΪ·Ö½âºó£¬ÎªÍ¬²½Ö´Ðз½Ê½

    Create_Process(temp_exe1, false); 

    Create_Process(temp_exe2, false);

   }

   else

   {

    //ÖÃΪ·Ö½âºó£¬ÎªÒì²½Ö´Ðз½Ê½

    Create_Process(temp_exe1, true); 

    Create_Process(temp_exe2, true);

   }

}

3¡¢ÅжϺÎʱÀ¦°ó³ÌÐò£¬ºÎʱÓÖ·Ö½â×îÖպϳɳÌÐò¡£

ÓÉÓÚ±¾³ÌÐòÊǽ«×ÔÉíÀ¦°ó³ÌÐò×÷ΪÎļþÍ·£¬Òª°ó¶¨Îļþ¸½¼ÓÆäºó·½Ê½Éú³É×îÖպϳÉÎļþµÄ¡£ËùÒÔ£¬Ö»ÒªÖªµÀ×ÔÉíÀ¦°ó³ÌÐòµÄÎļþ³¤¶È£¬ÔÙÔÚ³õʼ»¯¶Ô»°¿òº­ÊýOnInitDialog()¼ÓÒÔÅжϼ°¿ÉÖªµÀÊÇ·ñÊÇ×îÖպϳÉÎļþ(Òª²»ÒªÊÍ·ÅÄÚ²¿°ó¶¨Îļþ)¡£±¾Àý³ÌÓÃVC6.0²ÉÓþ²Ì¬Á¬½Ó·½Ê½Éú³ÉµÄRelease°æ£¬Îļþ´óСΪ184K¡£

¹ÊÅжÏÊÇÀ¦°ó»¹ÊÇÊÍ·ÅÎļþµÄ´úÂë¾ßÌåʵÏÖÈçÏ£º

BOOL CBindFileDlg::OnInitDialog()

{

  CDialog::OnInitDialog();

  // Add "About..." menu item to system menu.

  // IDM_ABOUTBOX must be in the system command range.

  ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);

  ASSERT(IDM_ABOUTBOX < 0xF000);

  CMenu* pSysMenu = GetSystemMenu(FALSE);

  if (pSysMenu != NULL)

  {

    CString strAboutMenu;

    strAboutMenu.LoadString(IDS_ABOUTBOX);

    if (!strAboutMenu.IsEmpty())

    {

      pSysMenu->AppendMenu(MF_SEPARATOR);

      pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);

    }

  }

  // Set the icon for this dialog. The framework does this automatically

  // when the application''s main window is not a dialog

  SetIcon(m_hIcon, TRUE);      // Set big icon

  SetIcon(m_hIcon, FALSE);    // Set small icon

  

  //Ôڴ˳õʼ»¯½¥±äÉ«½ø¶ÈÌõ

  m_Progress.SetRange32(1,500);

m_Progress.SetBkColor(RGB(160,180,220));

  m_Progress.ShowPercent(true);  

  m_Progress.SetPos(500);

  //³õʼÖø÷ÎļþÃû±äÁ¿Îª¿Õ

  strFirstFilePath = "";  //Òª°ó¶¨µÚÒ»¸öÎļþÃû

  strSecondFilePath = ""; //Òª°ó¶¨µÚ¶þ¸öÎļþÃû

  strFinalFilePath = "";  //×îÖպϳÉÎļþÃû

  //³õʼ»¯±äÁ¿

  prog1_length = 0;    //Îļþ³¤¶È

  his_name = "";     //°ó¶¨ÎļþÃû

  buf = NULL;      //»º³åÇøÖÿÕ

  //»ñÈ¡×ÔÉíÎļþÃûµ½my_mane±äÁ¿ÖÐ

  ::GetModuleFileName(0, my_name, sizeof(my_name));

  struct _stat ST; 

  _stat(my_name, &ST);  //»ñÈ¡×ÔÉíÎļþÐÅÏ¢(³¤¶È)

  //Ôڴ˼ÓÈëÀ¦°óÆ÷³ÌÐòµÄ×îÖÕ´óС£¬À´ÅжÏÊÇ°ó¶¨Îļþ»¹ÊÇ·Ö½âÖ´ÐÐÎļþ

//µ±·¢ÏÖ×ÔÉíÎļþ´óС´óÓÚÔ­´óС184Kʱ£¬ÎªÊÍ·ÅÄÚ²¿ºÏ³ÉÎļþ

  if(ST.st_size > 184*1024)

{

  Unbind(); //·ÖÀëÎļþ²¢ÔËÐÐ

   exit(0);  //Ö±½ÓÍ˳ö³ÌÐò,²»ÏÔʾÀ¦°ó³ÌÐò»­Ãæ

  }

  

  return TRUE; // return TRUE unless you set the focus to a control

}

ÆäÖоßÌåʵÏÖϸ½ÚÎÊÌ⣬¿ÉÔÚÏÂÔØʵÀý´úÂëºó£¬×Ðϸ²é¿´¼È¿É(ÄÚÓÐÏêϸעÊÍ)¡£

ÁªÏµ·½Ê½£º

µØÖ·£ºÉÂÎ÷Ê¡Î÷°²ÊÐÀͶ¯Â·2ºÅÔºÁùµ¥Ôª

Óʱࣺ710082

×÷ÕßEMAIL£ºjingzhou_xu@163.net

δÀ´¹¤×÷ÊÒ(Future Studio)

¡¾·µ»Ø¶¥²¿¡¿ ¡¾´òÓ¡±¾Ò³¡¿ ¡¾¹Ø±Õ´°¿Ú¡¿

¹ØÓÚÎÒÃÇ / ¸øÎÒÁôÑÔ / °æȨ¾Ù±¨ / Òâ¼û½¨Òé / ÍøÕ¾±à³ÌQQȺ   
Copyright ©2003- 2024 Lihuasoft.net webmaster(at)lihuasoft.net ¼ÓÔØʱ¼ä 0.00174