Visual C++ General 论坛General questions about Visual C++ , including the development environment, libraries, setup, debugger, samples, and documentation.© 2009 Microsoft Corporation。保留所有权利。Sun, 29 Nov 2009 23:44:04 Z805bdc3f-bf13-4784-9e81-548b5030302bhttp://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/670c79f5-6bb5-475d-b2f0-04437caa3fbehttp://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/670c79f5-6bb5-475d-b2f0-04437caa3fbereginat1http://social.msdn.microsoft.com/Profile/zh-CN/?user=reginat1Calling a Function Need Help ASAPI am confused about calling functions and need help. I do not know what I am doing wrong. The code does not have any errors, but does not work correctly. I have found several different ways to call functions, but I am unsure as to how to use them. Please help ASAP.<br/><br/><br/> <pre lang=x-cpp>#include &lt;iostream&gt; using std::cin; using std::cout; using std::endl; #include &lt;cstdlib&gt; using std::rand; using std::srand; #include &lt;ctime&gt; using std::time; void multiplication(); // function prototype for the function you are programming! void correctMessage(); // function prototype void incorrectMessage(); // function prototype bool needHelp( int, int ); // function prototype int main() { srand( (unsigned int)time( 0 ) ); // seed random number generator multiplication(); // begin multiplication practice return 0; // indicate successful termination } // end main // function multiplication produces pairs of random numbers and prompts the user for the product // it also produces random comments for correct and incorrect answers by calling the appropriate function // in addition, it counts the number of correct and incorrect answers, and // after 10 answers, it calculates the percentage of correct answers; // if the percentage is lower than 75%, it calls the function needHelp and terminates. void multiplication() { // Variable declarations; no other variables are required. int x; // first factor int y; // second factor int response = 0; // user response for product int correct = 0; // total number of correct responses int incorrect = 0; // total number of incorrect responses int count = 0; // count for every 10 responses // use sentinel-controlled repetition cout &lt;&lt; &quot;Enter -1 to End.&quot; &lt;&lt; endl; // loop until sentinel value read from user while ( response != -1 ) { x = rand() % 10; // generate 1-digit random number y = rand() % 10; // generate 1-digit random number cout &lt;&lt; &quot;How much is &quot; &lt;&lt; x &lt;&lt; &quot; times &quot; &lt;&lt; y &lt;&lt; &quot; (-1 to End)? &quot;; cin &gt;&gt; response; // loop until sentinel value or correct response while ( response != -1 &amp;&amp; response != x * y ) { response = incorrect; // calls incorrectMessages() } // end while // correct response if ( response == x * y ) response = correct; // call correctMessage() } // end while cout &lt;&lt; &quot;That's all for now. Bye.&quot; &lt;&lt; endl; } // end function multiplication // function correctMessage randomly chooses response to correct answer void correctMessage() { // generate random number between 0 and 3 switch ( rand() % 4 ) { case 0: cout &lt;&lt; &quot;Very good!&quot;; break; case 1: cout &lt;&lt; &quot;Excellent!&quot;; break; case 2: cout &lt;&lt; &quot;Nice work!&quot;; break; case 3: cout &lt;&lt; &quot;Keep up the good work!&quot;; break; } // end switch cout &lt;&lt; endl &lt;&lt; endl; } // end function correctMessage // function incorrectMessage randomly chooses response to incorrect answer void incorrectMessage() { // generate random number between 0 and 3 switch ( rand() % 4 ) { case 0: cout &lt;&lt; &quot;No. Please try again.&quot;; break; case 1: cout &lt;&lt; &quot;Wrong. Try once more.&quot;; break; case 2: cout &lt;&lt; &quot;Don't give up!&quot;; break; case 3: cout &lt;&lt; &quot;No. Keep trying.&quot;; break; } // end switch cout &lt;&lt; endl &lt;&lt; &quot;? &quot;; } // end function incorrectMessage // function needHelp returns true if &lt; 75% right bool needHelp( int right, int wrong ) { // if &lt; 75% right if ( static_cast&lt; double &gt; ( right ) / ( right + wrong ) &lt; .75 ) { cout &lt;&lt; &quot;Please ask your instructor for extra help.&quot; &lt;&lt; endl; return true; } // end if else // otherwise, return false return false; } // end function needHelp</pre> <br/><br/><br/>Sun, 29 Nov 2009 23:23:20 Z2009-11-29T23:44:04Zhttp://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/507b7f95-1aa7-428d-bb30-b36775346040http://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/507b7f95-1aa7-428d-bb30-b36775346040blacksynmhttp://social.msdn.microsoft.com/Profile/zh-CN/?user=blacksynmHow to convert from char* to lpcwstr in ansi C with visua studio 2005How to convert from char* to lpcwstr in ansi C with visual studio 2005?.<br/> <br/> Help!, thanks.Sun, 29 Nov 2009 20:57:01 Z2009-11-29T23:06:49Zhttp://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/f23c4605-d51f-43cd-a016-b7d3a4caaf07http://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/f23c4605-d51f-43cd-a016-b7d3a4caaf07awlinqhttp://social.msdn.microsoft.com/Profile/zh-CN/?user=awlinqIs there an API to export the entire registry from the computer level like regedit/file/export does?Is there an API to export the entire registry from the computer level like regedit/file/export does?<br/>Don't see RegSaveKey takes Computer as HKEY.<br/><br/>Sun, 29 Nov 2009 13:57:02 Z2009-11-29T22:48:42Zhttp://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/52dff40d-6e9d-4b30-9410-087a28a03124http://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/52dff40d-6e9d-4b30-9410-087a28a03124vandermudehttp://social.msdn.microsoft.com/Profile/zh-CN/?user=vandermudeNo ncb file and parameters set but no IntellisenseI have a Visual Studio solution that is essentially the Windows CE operating system. There is a *.sln and a *.suo file, but no *.ncb Intellisense file. I have options &quot;Auto List Members&quot; and &quot;Parameter Information&quot; set in the Options, but nothing happens. If I right click on anything and sak for &quot;Go to definition&quot; I get &quot;x is not defined&quot; I have not been able to turn on Intellisense for love or money. Help!Sun, 29 Nov 2009 21:49:43 Z2009-11-29T21:49:43Zhttp://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/68c79f7b-a8c2-41a7-86f4-081237c34fabhttp://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/68c79f7b-a8c2-41a7-86f4-081237c34fabes1968http://social.msdn.microsoft.com/Profile/zh-CN/?user=es1968Atl Attributes TutorialHi,<br/> Atl Attributes Tutorial needs attributed option which isn't supported by Visual Studio 2008 (Microsoft .Net Framework 3.5).<br/> How should I complete the <a title="Step 3: Implementing the Server" href="http://msdn.microsoft.com/en-us/library/etath6w1(VS.71).aspx" title="Step 3: Implementing the Server">Step 3: Implementing the Server</a> in Atl Attributes Tutorial ?<br/> The problem is <strong>To add and define the Transfer event</strong> .<br/> <br/> Thanks in advance,<br/> EyalSun, 29 Nov 2009 20:33:38 Z2009-11-29T20:33:38Zhttp://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/ac2e1629-68c1-4a98-be31-74c75d5131a7http://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/ac2e1629-68c1-4a98-be31-74c75d5131a7dadoftwinshttp://social.msdn.microsoft.com/Profile/zh-CN/?user=dadoftwinsMFC and Excel Automation Copy sheet failed issueI am trying to create a new sheet from a copy of an existing sheet. So far I have not had any luck.<br/> <br/> Below is the code that I am using/used to try and get the sheet copied. However, everything I do results in an error message stating that the copy failed.<br/> <br/> <pre lang=x-cpp> COleVariant covOpt((long)DISP_E_PARAMNOTFOUND, VT_ERROR), covWidth((short)40), covFalse((short)FALSE), covTrue((short)TRUE); COleVariant vBefore, vAfter, vCount, vType; LPDISPATCH lpDisp; Worksheets oTemplateSheets; _Worksheet oTemplateSheet, oNewSheet; Range oRange, oRange2; // Set the template as the active sheet oTemplateSheet = m_oWorkSheets.GetItem(COleVariant((short)1)); oTemplateSheet.Activate(); oTemplateSheet.Unprotect(covOpt); // Insert next to active sheet vAfter.vt = VT_DISPATCH; vAfter.pdispVal = m_oWorkSheets.GetItem(COleVariant((short)2)); //vAfter.vt = VT_I2; //vAfter.iVal = 1; oTemplateSheet.Copy(covOpt, vAfter); oTemplateSheet.Protect(covOpt, covOpt, covOpt, covOpt, covOpt); </pre> <br/> I found the following article that was very helpful, but when I tried it the formatting of the original sheet was not copied. e.g. panes freeze<br/> <br/> http://codeguru.earthweb.net/forum/showthread.php?p=796794<br/> <br/> _Application app;<br/> Workbooks books;<br/> _Workbook book;<br/> Worksheets sheets;<br/> _Worksheet sheet,sheet2;<br/> Range range,range2;<br/> <br/> COleVariant <br/> covOpt((long)DISP_E_PARAMNOTFOUND, VT_ERROR),covWidth((short)40),<br/> covFalse((short)FALSE),<br/> covTrue((short)TRUE);<br/> if(!app.CreateDispatch(&quot;Excel.Application&quot;)) return;<br/> <br/> app.SetDisplayAlerts(FALSE);<br/> app.SetVisible(TRUE);<br/> app.SetUserControl(TRUE);<br/> <br/> books = app.GetWorkbooks();<br/> book = books.Open(&quot;d:\\junk.xls&quot;,covOpt,covOpt,covOpt,covOpt,covOpt,covOpt,covOpt,covOpt,covOpt,covOpt,covOpt,covOpt);<br/> <strong>sheets =book.GetSheets();<br/> </strong> <br/> <strong>sheet=sheets.GetItem(COleVariant((short)1));<br/> range=sheet.GetUsedRange();<br/> range.Copy(covOpt);<br/> sheet2=sheets.Add(covOpt,covOpt,covOpt,covOpt);<br/> range2=sheet2.GetRange(COleVariant(&quot;A1&quot;),COleVariant(&quot;A1&quot;));<br/> range2.Select();<br/> sheet2.Paste(covOpt,covOpt);<br/> app.ReleaseDispatch();<br/> </strong> app=NULL; <br/> <br/> Does anyone have any suggestions? I have tried changing the copy Variants to everything I can think of, but these all failed. The only time it does not is if both are set to covOpt. However, this does not create the sheet in the same workbook.<br/> <br/> TIA<br/>Sun, 29 Nov 2009 05:54:26 Z2009-11-29T18:55:46Zhttp://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/24a79f4f-83ce-449b-be5f-24d437c6a141http://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/24a79f4f-83ce-449b-be5f-24d437c6a141jukkasuhttp://social.msdn.microsoft.com/Profile/zh-CN/?user=jukkasuusing dll made with visual studio 6.0 in visual studio 4.2-projectIs it possible to use a dll that is made using Visual C++ 6.0 in Visual C++ 4.2 ?<br/> <br/> I'm trying to use a dll which exports one function, int checkp(void*).<br/> <br/> If I use .def file and define the function as:<br/>     extern &quot;C&quot; int checkp(void* data)<br/> in 6.0, LoadLibrary in 4.2-code loads the dll but I can't get function's address with GetProcAddress. <br/> <br/> If I export function using __declspec(dllexport) and link to dll normally in 4.2, linker warns about different subsystem (LNK4064) and doesn't find the function.<br/> <br/> - jukka<br/>Thu, 26 Nov 2009 19:00:28 Z2009-11-29T18:41:59Zhttp://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/acb0f430-01f4-4b84-9a23-bd100fde4b8fhttp://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/acb0f430-01f4-4b84-9a23-bd100fde4b8fRobert Pucketthttp://social.msdn.microsoft.com/Profile/zh-CN/?user=Robert%20PuckettData pulling from database with a string problem.<p>Any one able to help this would be awsome.</p> <p>Here is the original code from PXI <a href="http://projectxi.org">http://projectxi.org</a></p> <pre>int CZoneHandler::loadZoneList(unsigned short zone) { MYSQL_RES * res; MYSQL_ROW row; MYSQL* mysqlConn; unsigned long size = 0, count, *lengths; char query[4096]; if(zone &gt; 255) { return 0; } CConsole::outTime(&quot;Loading %s...&quot;, CUtil::getZoneName(zone)); //Clear the NPC list for the zone, incase this is a reload if((this-&gt;npcZoneList[zone].size() &gt; 0)) { this-&gt;npcZoneList[zone].clear(); } //Clear the MOB list for the zone, incase this is a reload if((this-&gt;mobZoneList[zone].size() &gt; 0)) { this-&gt;mobZoneList[zone].clear(); } //Clear the Region list for the zone, incase this is a reload if((this-&gt;m_zoneList.at(zone).m_pRegionList-&gt;size() &gt; 0)) { this-&gt;m_zoneList.at(zone).m_pRegionList-&gt;clear(); } //load NPCs and MOBs sprintf(query, &quot;SELECT npc.name, npc.id, npc.type, npc.type, npc.flag, npc.look, npc.animation,npc.alt_animation, npc.namevis, npc.speed, npc.alt_speed, npc.targid, npc.status, npc.unknown, npc.name_prefix, npc.pos_x, npc.pos_y, npc.pos_z, npc.pos_rot FROM `npc_list` AS npc WHERE npc.zone = %i ORDER BY id ASC&quot;, zone); count = (int) strlen(query); mysqlConn=CDb::getConn(); //get conn mysql_real_query(mysqlConn, query, count); res = mysql_store_result(mysqlConn); CDb::pushConn(mysqlConn); //release conn char newName[512]; if(!res) { // CConsole::outErr(&quot;Zone 0x%X\t -&gt; %s not found in DB!&quot;,zone ,CUtil::getZoneName(zone)); //return 0; } else if(!mysql_num_rows(res)) { mysql_free_result(res); //return size; } else { int npccnt = 0; int mobcnt = 0; int run = 0; CNpc* npc; while((row = mysql_fetch_row(res))) { npc = new CNpc(); lengths = mysql_fetch_lengths(res); memset(npc-&gt;m_name, 0 , 17); memset(newName,0,512); memcpy(newName, row[0], lengths[0]); memcpy(npc-&gt;m_name,newName,16); npc-&gt;setId((unsigned int)atoi(row[1])); npc-&gt;setZone((unsigned char)zone); npc-&gt;type = atoi(row[2]); npc-&gt;moveState = 0; npc-&gt;flag = atoi(row[4]); if(npc-&gt;type == 0x57) { memcpy(&amp;npc-&gt;lookc, row[5], 20); } else { memcpy(&amp;npc-&gt;look, row[5], 4); } npc-&gt;setAnimation(atoi(row[6])); npc-&gt;m_animationAlt = atoi(row[7]); npc-&gt;namevis = atoi(row[8]); npc-&gt;m_speed = atoi(row[9]); npc-&gt;m_speedAlt = atoi(row[10]); npc-&gt;setTargId(atoi(row[11])); npc-&gt;status = atoi(row[12]); npc-&gt;unknown = atoi(row[13]); npc-&gt;loc.p.x = (float) atof(row[15]); npc-&gt;loc.p.y = (float)atof(row[16]); npc-&gt;loc.p.z = (float)atof(row[17]); npc-&gt;loc.p.rotation = (unsigned short)atoi(row[18]); npc-&gt;incombat = false; npc-&gt;ownerId = 0; npc-&gt;oldtime = 0; npc-&gt;update = false; npc-&gt;timestamp = 0; npc-&gt;targ_p = npc-&gt;loc.p; npc-&gt;m_maxHp = 100; npc-&gt;h.hp = npc-&gt;getMaxHp(); npc-&gt;m_objType = OBJ_NPC; npc-&gt;sizeMod = 0; npccnt++; this-&gt;npcZoneList[zone].push_back(npc); npc = NULL; } //CConsole::outTime(&quot;Zone 0x%X\t -&gt; %i NPCs %i MOBs loaded!&quot;,zone ,npccnt, mobcnt); mysql_free_result(res); } //CConsole::outTime(&quot;Zone 0x%X\t %s -&gt; %i PATH %i SPAWN points loaded!&quot;,zone ,CUtil::getZoneName(zone) ,pathcnt, spawncnt); CLuaManager::OnZoneInitialize(zone); //CConsole::outTimePos(0,9, &quot; &quot;); return 0; } <br/></pre> <pre>Now here is our code that we are workign with. <br/>int CZoneHandler::loadZoneList(unsigned short zone) { //char newName[512]; int npccnt = 0; int mobcnt = 0; int run = 0; CNpc* npc; if (zone &gt; 255) { return 0; } if((this-&gt;npcZoneList[zone].size() &gt; 0)) { this-&gt;npcZoneList[zone].clear(); } //Clear the MOB list for the zone, incase this is a reload if((this-&gt;mobZoneList[zone].size() &gt; 0)) { this-&gt;mobZoneList[zone].clear(); } //Clear the Region list for the zone, incase this is a reload if((CLuaManager::regionList[zone].size() &gt; 0)) { CLuaManager::regionList[zone].clear(); } QueryResult *result = WorldDatabase.PQuery(&quot;SELECT npc.name, npc.id, npc.type, npc.type, npc.flag, npc.look, npc.animation,npc.alt_animation, npc.namevis, npc.speed, npc.alt_speed, npc.targid, npc.status, npc.unknown, npc.name_prefix, npc.pos_x, npc.pos_y, npc.pos_z, npc.pos_rot FROM `npc_list` AS npc WHERE npc.zone = %i ORDER BY id ASC&quot;,zone); if( !result ) { sLog.RedConsoleMsg (&quot;Zone 0x%X\t -&gt; %s Npcs not found in DB!&quot;,zone ,CUtil::getZoneName(zone)); return 0; } sLog.LGreenConsoleMsg(&quot;Loading %s...&quot;, CUtil::getZoneName(zone)); barGoLink bar( result-&gt;GetRowCount() ); do { Field *fields = result-&gt;Fetch(); bar.step(); npc = new CNpc(); /* const char* nametest = fields[0].GetString(); memset(npc-&gt;m_name, 0 , 17); memset(newName,0,512); memcpy(newName, nametest, 25); memcpy(&amp;npc-&gt;m_name,newName,16);*/ npc-&gt;setId(fields[1].GetUInt16()); npc-&gt;setZone((unsigned char)zone); npc-&gt;type = fields[2].GetUInt16();//atoi(row[2]); npc-&gt;moveState = 0; npc-&gt;flag = fields[4].GetInt32();//atoi(row[4]); /*const char* lookstest = fields[5].GetString(); if(npc-&gt;type == 0x57) { memcpy(&amp;npc-&gt;lookc, lookstest, 20); } else { memcpy(&amp;npc-&gt;look, lookstest, 4); }*/ npc-&gt;setAnimation(fields[6].GetUInt16()); npc-&gt;m_animationAlt = fields[7].GetUInt16();//atoi(row[7]); npc-&gt;namevis = fields[8].GetUInt16();//atoi(row[8]); npc-&gt;m_speed = fields[9].GetUInt16();//atoi(row[9]); npc-&gt;m_speedAlt = fields[10].GetUInt16();//atoi(row[10]); npc-&gt;setTargId(fields[11].GetUInt32()); npc-&gt;status = fields[12].GetUInt32();//atoi(row[12]); npc-&gt;unknown = fields[13].GetUInt32();//atoi(row[13]); npc-&gt;loc.p.x = fields[15].GetFloat();//(float) atof(row[15]); npc-&gt;loc.p.y = fields[16].GetFloat();//(float)atof(row[16]); npc-&gt;loc.p.z = fields[17].GetFloat();//(float)atof(row[17]); npc-&gt;loc.p.rotation = fields[18].GetUInt16(); npc-&gt;incombat = false; npc-&gt;ownerId = 0; npc-&gt;oldtime = 0; npc-&gt;update = false; npc-&gt;timestamp = 0; npc-&gt;targ_p = npc-&gt;loc.p; npc-&gt;m_maxHp = 100; npc-&gt;h.hp = npc-&gt;getMaxHp(); npc-&gt;m_objType = OBJ_NPC; npc-&gt;sizeMod = 0; npccnt++; this-&gt;npcZoneList[zone].push_back(npc); npc = NULL; } while (result-&gt;NextRow()); delete result; sLog.outString(); CLuaManager::OnZoneInitialize(zone); return 0; }</pre> <p> </p> <p>Our problems are Displaying the Names for the NPCS and Displaying the Look or the costume the NPC is. In wow server this would be called DisplayID.<br/>Im unable to pull the data from the database into the game to show the name of the NPC and the look of the NPC. Please id any one can help this would be awsome becasue I just cant get it yet I been trying for 4 days so far.</p> <p>here is where Im having problems converting the code over to our system.<br/>Here is the original code from PXI <a href="http://projectxi.org">http://projectxi.org</a><br/></p> <pre>lengths = mysql_fetch_lengths(res); memset(npc-&gt;m_name, 0 , 17); memset(newName,0,512); memcpy(newName, row[0], lengths[0]); memcpy(npc-&gt;m_name,newName,16);</pre> <p>I need to beable to make our system do this also. to pull the names correctly.</p> <p>Here is the original code from PXI <a href="http://projectxi.org">http://projectxi.org</a><br/></p> <pre>if(npc-&gt;type == 0x57) { memcpy(&amp;npc-&gt;lookc, row[5], 20); } else { memcpy(&amp;npc-&gt;look, row[5], 4); }</pre> <p> </p> <p>Here is where we would get the DisplayID or the Look of the NPC costume they are in. But Were unable to pull the data into our server with our system so far So if any one can solve this problem please help.</p> <hr class=sig> Robert PuckettSun, 29 Nov 2009 17:45:09 Z2009-11-29T17:45:12Zhttp://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/db23a7f8-f3d6-4d37-8ec7-f06052a7fd67http://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/db23a7f8-f3d6-4d37-8ec7-f06052a7fd67Xunterhttp://social.msdn.microsoft.com/Profile/zh-CN/?user=XunterGetting Type Library for DLL (c++ COM)Hi,<br/> <br/> I would like to get an type library from existing COM DLL using command line. Is it possible?<br/> The final goal is to get type library that could be used as input for mt.exe to create manifest file for registry free COM.<br/> <br/> <br/> Thanks<br/>Sun, 29 Nov 2009 15:15:54 Z2009-11-29T17:08:08Zhttp://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/4669ec78-7bdd-4bed-a7da-4bf48948e05ehttp://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/4669ec78-7bdd-4bed-a7da-4bf48948e05eAmare1982http://social.msdn.microsoft.com/Profile/zh-CN/?user=Amare1982Priority QueueHi, The current implementation of Priority Queue does not allow us to remove a partiuclar element from the priority queue. Instead we can only remove the top element and that's it. I am trying to implement my own priority queue as a result. So far I tried with vectors as underlying data structures but its slow because of too much iteration while insertion. Just wondering what will be the best underlying data structure for implementing priority queues so that, insertion, removal of a particular element (and of course it should keep elements in the sorted order) can be done in log n worst case scenario or close to that.<br/> <br/> Thanks<br/> <br/> Amare<br/>Sun, 29 Nov 2009 04:10:23 Z2009-11-29T15:12:45Zhttp://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/8a3c92a4-7e8e-47ec-bcb3-f927f225541ehttp://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/8a3c92a4-7e8e-47ec-bcb3-f927f225541eawlinqhttp://social.msdn.microsoft.com/Profile/zh-CN/?user=awlinqHow to move the vertical scrollbar on CEdit control to the bottom to show all the text after SetWindowText?<p>I tried the following code, the scrollbar does move to the bottom, but it does not show all the text, always about 7 lines are out. If I click on the scrollbar, instantly the scrollbar moves up a bit, then I can manually move the bar to the bottom and see all the text.<br/><br/><span style="font-size:x-small">SCROLLINFO info;<br/>CWnd * edit = </span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">this</span></span><span style="font-size:x-small">-&gt;GetDlgItem(IDC_EDITPINGSTATUS);<br/>edit-&gt;GetScrollInfo(SB_VERT, &amp;info);<br/>edit-&gt;SetScrollPos(SB_VERT,info.nMax);<br/><br/>what extra needs to be called to show all the text up to real bottom?<br/><br/>TIA</span></p>Sat, 28 Nov 2009 13:38:02 Z2009-11-29T13:53:32Zhttp://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/d007e820-c30c-4bd2-94f1-0514728c13c9http://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/d007e820-c30c-4bd2-94f1-0514728c13c9Zvika V.http://social.msdn.microsoft.com/Profile/zh-CN/?user=Zvika%20V.Get "Class not registered" error when calling ApcHost.Create when the code is compiled using VS 2008<p>Following is my code:<br/><br/><span style="font-size:x-small"> <p>HRESULT hr = NOERROR;</p> <p>CString name,strLicKey(LICENSEKEY);</p> <p>name = m_pszAppName;</p> <p>DWORD dwLCID = MAKELCID(m_nVBALanguage,SORT_DEFAULT);</p> <p>CComPtr&lt;IRPHApplication&gt; p;</p> <p>ApcGetPrimary(&amp;p);</p> <p>hr = ApcHost.Create(GetMainWnd()-&gt;m_hWnd, name.AllocSysString(),</p> <p>p, strLicKey.AllocSysString(),dwLCID) ;<br/><br/>The last call fails.<br/>When VS 6.0 is used, this works fine.<br/>Thanks in advance for any help.<br/>Zvika.</p> </span></p>Thu, 19 Nov 2009 14:10:59 Z2009-11-29T10:12:09Zhttp://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/97039b9b-cf2f-4e44-894f-73ac4d1cc004http://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/97039b9b-cf2f-4e44-894f-73ac4d1cc004Lê Khánh Thànhhttp://social.msdn.microsoft.com/Profile/zh-CN/?user=L%u00ea%20Kh%u00e1nh%20Th%u00e0nherror C4430 with class, help !!!hi,<br/> <br/> I have a class Vehicles like (in Vehicle.h):<br/> <br/> class Vehicles<br/> {<br/> public:<br/>     Vehicles(Core *frameListener, K_SceneManager *sceneMgr, VEHICLE_TYPE type, K_VECTOR offset = K_VECTOR::ZERO, Vehicles *leader = NULL);<br/>     ~Vehicles(K_EMPTY);<br/> }<br/> <br/> And in a include file (SteeringBehavior.h), i have:<br/> <br/> #pragma once<br/> class Vehicles;<br/> <br/> class SterringBehaviors<br/> {<br/>       <strong> SteeringBehaviors(Vehicles *vehicle);    </strong> <br/> }<br/> <br/> then i compile, I have an error message at line with bold color above, this error like:<br/> <strong><br/> error C4430: missing type specifier - int assumed. Note: C++ does not support default-int</strong> <br/> <br/> I try to fix the error but i couldn't, i don't where my code is wrong ? Anybody help me ?<br/> <br/> Thanks <hr class=sig> thanhly'sSun, 29 Nov 2009 06:01:31 Z2009-11-29T07:58:18Zhttp://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/61d465d6-1780-402e-b45e-bf9d113d275dhttp://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/61d465d6-1780-402e-b45e-bf9d113d275dkalanesilvahttp://social.msdn.microsoft.com/Profile/zh-CN/?user=kalanesilvaNo error in release mode. Why not ?<p>#include &lt;iostream&gt;<br/><br/>using namespace std;<br/><br/>int main()<br/>{<br/>     char *p = &quot;John&quot;;<br/>     *p = 'A';<br/>     cout &lt;&lt; p &lt;&lt; endl;     // Prints &quot;John&quot; in release mode without error<br/>}<br/><br/>As expected, in debug mode there's an error.</p>Sat, 28 Nov 2009 17:06:24 Z2009-11-29T05:48:02Zhttp://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/9234a3cb-eca5-440c-839e-7d45e54fd38bhttp://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/9234a3cb-eca5-440c-839e-7d45e54fd38bLeyondhttp://social.msdn.microsoft.com/Profile/zh-CN/?user=LeyondHow to explain this right shiftHere is the some basic definitions:<br/> 1.<br/> <pre lang=x-cpp>#define IP_ADDRESS_FAMILY(buffer) ((*(PUCHAR)(buffer)) &gt;&gt; 4)</pre> 2.<br/> <pre lang=x-cpp>#define IP_ADDRESS_FAMILY_IP4 4</pre> <pre lang=x-cpp> UCHAR packetBuffer[ETH_MAX_PACKET_SIZE];</pre> <pre lang=x-cpp> UCHAR AddressFamily = 0;</pre> <br/> 3.<br/>   suppose that packetBuffer is used to save some network data with <span style="text-decoration:underline">underline</span> received by our NIC. The data is described as bellow:<br/> <span style="font-size:medium">    000000: <span style="text-decoration:underline"><strong>00 A0 CC 63 08 1B 00 40 : 95 49 03 5F 08 00</strong> 45 00</span> ...c...@.I._..E. <br/>     000010: <span style="text-decoration:underline">00 3C 82 47 00 00 20 01 : 94 C9 C0 A8 01 20 C0 A8</span> .&lt;.G.. ...... .. <br/>     000020: <span style="text-decoration:underline">01 40 08 00 48 5C 01 00 : 04 00 61 62 63 64 65 66</span> .@..H\....abcdef <br/>     000030: <span style="text-decoration:underline">67 68 69 6A 6B 6C 6D 6E : 6F 70 71 72 73 74 75 76</span> ghijklmnopqrstuv <br/>     000040: <span style="text-decoration:underline">77 61 62 63 64 65 66 67 : 68 69</span>                    wabcdefghi...... </span> <br/> 4. Let's consider about the following codes:<br/> <pre lang=x-cpp>AddressFamily = IP_ADDRESS_FAMILY(packetBuffer + bytesParsed); if (IP_ADDRESS_FAMILY_IP4 == AddressFamily){ //do something .... }</pre> in above codes: bytesParesd is the length of network data identified by <strong>bold</strong> type.  I am confused that why the right shift by 4 could get the number 4(UCHAR)?(Notes: network data is hexadecimal) 。 thanks very much<hr class="sig">Work and SmileSat, 28 Nov 2009 13:00:04 Z2009-11-29T04:50:32Zhttp://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/946e0cf1-a316-478b-96cb-80e2f052f5c4http://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/946e0cf1-a316-478b-96cb-80e2f052f5c4Ayasanohttp://social.msdn.microsoft.com/Profile/zh-CN/?user=AyasanoStrange linker error<p>I recieve this error when I try to compile any project in VC++ 2008:<span style="font-size:xx-small"> <p>LINK : fatal error LNK1181: cannot open input file '.\Release\Test.obj'<br/><br/>Same thing but with debug instead of release if it's set to debug configuration.<br/><br/>This is after reinstalling, (I kept getting the error before and couldn't fix it so I removed VC++ with Add/Remove Programs and then resintalled it) nothing changed, I just clicked file &gt; new &gt; project, and then created an empty project called test. The only code in the project is:</p> <pre lang=x-cpp>int main() { return 1; } </pre> <p><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">I had to do a Windows XP repair installation a while back and that seems to be when this started. I was able to compile projects before that. I have SP 3 installed.<br/><br/>I'm able to compile projects in Dev-C++, but need VC++ for DirectX applications.</span></span></p> </span></p>Sat, 28 Nov 2009 19:50:43 Z2009-11-28T23:52:35Zhttp://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/d29a5390-d127-45e4-b839-4fb139c59086http://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/d29a5390-d127-45e4-b839-4fb139c59086Vyasahttp://social.msdn.microsoft.com/Profile/zh-CN/?user=VyasaWhich is the best tool for designing stylish GUI.?Hello , <div style="font-weight:inherit;font-style:inherit;font-family:inherit;padding:0px;margin:0px;border:0px initial initial"><br/></div> <div style="font-weight:inherit;font-style:inherit;font-family:inherit;padding:0px;margin:0px;border:0px initial initial">I want to know which is the best tool which can be used to make GUI . Currently I'm working on VC++ 6.0 and I can't give a good look(Vista Look) in that. </div> <div style="font-weight:inherit;font-style:inherit;font-family:inherit;padding:0px;margin:0px;border:0px initial initial"><br/></div> <div style="font-weight:inherit;font-style:inherit;font-family:inherit;padding:0px;margin:0px;border:0px initial initial">So can anyone help me which one will be more suitable for GUI .. Java or any other tool and if you can give the reason then it is very helpful.</div> <div style="font-weight:inherit;font-style:inherit;font-family:inherit;padding:0px;margin:0px;border:0px initial initial"><br/></div> <div style="font-weight:inherit;font-style:inherit;font-family:inherit;padding:0px;margin:0px;border:0px initial initial">Thanks</div>Thu, 26 Nov 2009 04:13:09 Z2009-11-28T22:17:08Zhttp://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/6afc8926-afff-4d84-a920-4d8de414ee28http://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/6afc8926-afff-4d84-a920-4d8de414ee28azertykkhttp://social.msdn.microsoft.com/Profile/zh-CN/?user=azertykkCopy a file (With process)Hi,<br/><br/>I want to copy a File From Location <strong>A</strong> to <strong>B<br/><br/></strong>I know i could use one of the following methods<br/><br/>Using Buffers [ifstream.read(),ofstream.write()]<br/>File handles[CreateFile(),ReadFile(),WriteFile() ]<br/>goldenoldie[_tsystem(_T(&quot;copy A B&quot;))]<br/><br/>but i want to receive/calculate the <strong>status</strong><br/>so when copy a large file the user can see its process...<br/><br/>Fri, 27 Nov 2009 11:34:59 Z2009-11-29T09:34:53Zhttp://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/33438678-af63-4733-b681-0087a955b47ehttp://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/33438678-af63-4733-b681-0087a955b47eNoobzohttp://social.msdn.microsoft.com/Profile/zh-CN/?user=Noobzoare handles global to processes?Hello, i am trying to take a handle (like HBITMAP) and pass it to  another process (while its still valid) to draw that bitmap, its not working though.<br/> <br/> whats going on here, are handles specific to processes? and cannot be passed on to another process? thank you in advance.Sat, 28 Nov 2009 15:51:33 Z2009-11-28T19:25:47Zhttp://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/ca91cf1a-1e6e-4978-82e8-f93a3f2e63c7http://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/ca91cf1a-1e6e-4978-82e8-f93a3f2e63c7Mahesh Mahindrakarhttp://social.msdn.microsoft.com/Profile/zh-CN/?user=Mahesh%20MahindrakarHow to Get the Hbrush from Brush object???Hi<br/> I have a brush of type HBRUSH and i want to use it inside FillPath method, but the problem is that FillPath takes GDI+ Brush object so i cant use it directly<br/> so is there any method available to type cast HBRUSH object to Brush object???<br/> please suggest some way to do this...<br/> <br/> Thanks in advance<br/> Mahesh Mahindrakar...Sat, 28 Nov 2009 05:53:25 Z2009-11-28T19:09:38Zhttp://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/cef6584d-d05e-4510-a7c2-7ab529c303f9http://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/cef6584d-d05e-4510-a7c2-7ab529c303f9spujiahttp://social.msdn.microsoft.com/Profile/zh-CN/?user=spujiaSetting User Registry Keys (HKCU) From a Local System Account ServiceGreetings,<br/> <br/> I have a service running on the local system account, from which I wish to modify the the registry settings for the logged on user in the currently active session.  Note that if a process (service) is running in the local system account, accessing HKCU will redirect to HKCU\.Default, rather than to the hive of a logged on user in the active session.<br/> <br/> From researching the net, I have figured this process to involve impersonating a logged on user from within my service and then accessing the registry.  This works in as much as opening an HKCU key does in fact operate on the user's hive.  HOWEVER, since the user that I am impersonating does not have authority to modify certain registry settings, once the service impersonates them it cannot modify the settings!  AAAACKK!<br/> <br/> So you figure, &quot;Let's just adjust the priveledges of the token&quot;.  Sorry, that won't work either, since AdjustTokenPriveledges will only modify existing privs that the token already has :(<br/> <br/> So the question is, &quot;How do you modify ANY registry settings for the logged on user of the active session from the local system account?&quot;<br/> <br/> So far, this is what I have.<br/> <br/> <ol> <li>Run a service in the local system account</li> <li>From that service, obtain a process handle (via OpenProcess) to a process that is running in the active session of a logged on user (i.e., &quot;explorer.exe&quot;).  This uses the toolhelp API and WTSGetActiveConsoleSessionId(), etc.</li> <li>From the process handle, I obtain it's token</li> <li>Using the token, call &quot;ImpersonateLoggedOnUser&quot;</li> <li>Access the registry (And be denied!)</li> <li>Call &quot;RevertToSelf&quot; to revert the service back to itself</li> </ol> <br/> What I need is a token that impersonates the user but has the priveledges of the local system account :)<br/> Kind regards,<br/> <br/> SteveTue, 24 Nov 2009 22:09:04 Z2009-11-28T19:04:39Zhttp://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/cd09511c-d67c-46d2-b88d-670a844ef292http://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/cd09511c-d67c-46d2-b88d-670a844ef292WWJDJIMhttp://social.msdn.microsoft.com/Profile/zh-CN/?user=WWJDJIMMFC Automation how to implement RemoveDocument OnCloseDocumentI have an MFC MDI Application and I am trying to implement Automation with it. I am trying to create a RemoveDocument() method. How is that done? OnCloseDocument is causing problems. Is there a &quot;standard&quot; way for doing that?<br/> <br/> my sample automation code would look like this:<br/> <br/>         Dim App As New MyApp.Application<br/>         Dim Docs As MyApp.Documents<br/>         Dim Doc As MyApp.Document<br/>         Docs = App.Documents<br/> <br/>         Doc = Docs.OpenDocument(&quot;C:\Test.txt&quot;)<br/>         Doc.Save()<br/>         Docs.CloseDocument(Doc)<br/>         Doc = Nothing<br/>         <br/>         ' Need the ability to reopen the doc<br/>         Doc = Docs.OpenDocument(&quot;C:\Test.txt&quot;)<br/>         Doc.Save()<br/>         Docs.CloseDocument(Doc)<br/>         Doc = Nothing<br/> <br/>         Docs = Nothing<br/>         App = Nothing<br/> <br/> This always results in a crash... I even tried the TIA sample from 1998.. that sample has issues as well..Tue, 24 Nov 2009 22:41:03 Z2009-11-28T18:19:54Zhttp://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/83966183-f12e-4df1-abe7-cc141d48a4f8http://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/83966183-f12e-4df1-abe7-cc141d48a4f8eldienerhttp://social.msdn.microsoft.com/Profile/zh-CN/?user=eldienerFinding the reason for StretchBlt failing In my WM_PAINT handler code in a dialog I call StretchBlt and it fails with a return of FALSE. The source DC is a memory DC and the destination DC is my WM_PAINT handler DC accessed via the BeginPaint function.<br/> <br/> According to the documentation for StretchBlt:<br/> <br/> &quot;StretchBlt If the function succeeds, the return value is nonzero. If the function fails, the return value is zero.<strong> Windows NT/2000/XP:</strong> To get extended error information, call <strong>GetLastError</strong> .&quot;<br/> <br/> So I immediately call GetLastError only to be returned 0.<br/> <br/> I checked the capabilities of both the source and destination device contexts using GetDeviceCaps and RASTERCAPS and had supported for the source and destination devices:<br/> <br/> RC_BITBLT<br/> RC_BITMAP64<br/> RC_DI_BITMAP<br/> RC_DIBTODEV<br/> RC_STRETCHBLT<br/> RC_STRETCHDIB <br/> <br/> while the destination device also had RC_FLOODFILL supported.<br/> <br/> I am baffled on how to determine why the StretchBlt fails as it is keeping a window from displaying data. If I attempt other device context operations on my destination context, such as FillRect, Rectangle, TextOut etc., they all succeed. It is possible the rectangular co-ordinates for my source and destination DCs are &quot;incorrect&quot; in the StretchBlt call, but I would expect a GetLastError code if that were the situation. <br/> <br/> Any ideas or help tracking this GDI failure down would be appreciated.<br/> <br/> I am testing this on Windows Vista 64 Ultimate in a 32-bit application.Fri, 27 Nov 2009 23:49:42 Z2009-11-28T23:36:46Zhttp://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/c56ff7f2-e979-482d-be10-01b5d01a2835http://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/c56ff7f2-e979-482d-be10-01b5d01a2835BA08http://social.msdn.microsoft.com/Profile/zh-CN/?user=BA08More than 100 errors compiling StdAfx.cpp !!!<p align=left><font face=Arial size=2></font> </p> <p>Here is the error list, I am truly desparated:</p> <p align=left> </p><font size=1> <p>------ Build started: Project: IEHelper, Configuration: Debug Win32 ------</p> <p>Compiling...</p> <p>StdAfx.cpp</p> <p>Note: including file: c:\dokumente und einstellungen\hp_besitzer\eigene dateien\visual studio 2008\projects\bho_re\stdafx.h</p> <p>Note: including file: C:\Programme\Microsoft Visual Studio 9.0\VC\atlmfc\include\atlbase.h</p> <p>Note: including file: C:\Programme\Microsoft Visual Studio 9.0\VC\atlmfc\include\atldef.h</p> <p>Note: including file: C:\Programme\Microsoft Visual Studio 9.0\VC\atlmfc\include\atlrc.h</p> <p>Note: including file: C:\Programme\Microsoft Visual Studio 9.0\VC\include\errno.h</p> <p>Note: including file: C:\Programme\Microsoft Visual Studio 9.0\VC\include\sal.h</p> <p>Note: including file: C:\Programme\Microsoft Visual Studio 9.0\VC\include\malloc.h</p> <p>Note: including file: C:\Programme\Microsoft Visual Studio 9.0\VC\include\crtdefs.h</p> <p>Note: including file: C:\Programme\Microsoft Visual Studio 9.0\VC\include\crtassem.h</p> <p>Note: including file: C:\Programme\Microsoft Visual Studio 9.0\VC\include\vadefs.h</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(117) : error C2337: 'SA_Post' : attribute not found</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(117) : error C2065: 'SA_Yes' : undeclared identifier</p> <p>missing quotes (&quot;&quot;) around 'SA_Yes'?</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(117) : error C2337: 'SA_Post' : attribute not found</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(117) : error C2065: 'SA_Maybe' : undeclared identifier</p> <p>missing quotes (&quot;&quot;) around 'SA_Maybe'?</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(117) : error C2337: 'SA_Pre' : attribute not found</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(117) : error C2065: 'SA_No' : undeclared identifier</p> <p>missing quotes (&quot;&quot;) around 'SA_No'?</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(117) : error C2337: 'SA_Pre' : attribute not found</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(117) : error C2065: 'SA_Yes' : undeclared identifier</p> <p>missing quotes (&quot;&quot;) around 'SA_Yes'?</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(117) : error C2065: 'SA_Read' : undeclared identifier</p> <p>missing quotes (&quot;&quot;) around 'SA_Read'?</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(117) : error C2337: 'SA_Pre' : attribute not found</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(117) : error C2065: 'SA_No' : undeclared identifier</p> <p>missing quotes (&quot;&quot;) around 'SA_No'?</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(117) : error C2337: 'SA_Pre' : attribute not found</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(117) : error C2065: 'SA_Yes' : undeclared identifier</p> <p>missing quotes (&quot;&quot;) around 'SA_Yes'?</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(117) : error C2065: 'SA_Read' : undeclared identifier</p> <p>missing quotes (&quot;&quot;) around 'SA_Read'?</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(118) : error C2337: 'SA_Pre' : attribute not found</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(118) : error C2065: 'SA_Maybe' : undeclared identifier</p> <p>missing quotes (&quot;&quot;) around 'SA_Maybe'?</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(118) : error C2337: 'SA_Pre' : attribute not found</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(118) : error C2065: 'SA_Yes' : undeclared identifier</p> <p>missing quotes (&quot;&quot;) around 'SA_Yes'?</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(118) : error C2337: 'SA_Post' : attribute not found</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(118) : error C2065: 'SA_Yes' : undeclared identifier</p> <p>missing quotes (&quot;&quot;) around 'SA_Yes'?</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(119) : error C2337: 'SA_Post' : attribute not found</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(119) : error C2065: 'SA_Yes' : undeclared identifier</p> <p>missing quotes (&quot;&quot;) around 'SA_Yes'?</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(119) : error C2337: 'SA_Post' : attribute not found</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(119) : error C2065: 'SA_Maybe' : undeclared identifier</p> <p>missing quotes (&quot;&quot;) around 'SA_Maybe'?</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(119) : error C2337: 'SA_Pre' : attribute not found</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(119) : error C2065: 'SA_No' : undeclared identifier</p> <p>missing quotes (&quot;&quot;) around 'SA_No'?</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(119) : error C2337: 'SA_Pre' : attribute not found</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(119) : error C2065: 'SA_Yes' : undeclared identifier</p> <p>missing quotes (&quot;&quot;) around 'SA_Yes'?</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(119) : error C2065: 'SA_Read' : undeclared identifier</p> <p>missing quotes (&quot;&quot;) around 'SA_Read'?</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(120) : error C2337: 'SA_Post' : attribute not found</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(120) : error C2065: 'SA_Yes' : undeclared identifier</p> <p>missing quotes (&quot;&quot;) around 'SA_Yes'?</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(120) : error C2337: 'SA_Post' : attribute not found</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(120) : error C2065: 'SA_Maybe' : undeclared identifier</p> <p>missing quotes (&quot;&quot;) around 'SA_Maybe'?</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(120) : error C2337: 'SA_Pre' : attribute not found</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(120) : error C2065: 'SA_Maybe' : undeclared identifier</p> <p>missing quotes (&quot;&quot;) around 'SA_Maybe'?</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(120) : error C2337: 'SA_Pre' : attribute not found</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(120) : error C2065: 'SA_Yes' : undeclared identifier</p> <p>missing quotes (&quot;&quot;) around 'SA_Yes'?</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(120) : error C2337: 'SA_Pre' : attribute not found</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(120) : error C2065: 'SA_Read' : undeclared identifier</p> <p>missing quotes (&quot;&quot;) around 'SA_Read'?</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(120) : error C2337: 'SA_Pre' : attribute not found</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(120) : error C2065: 'SA_No' : undeclared identifier</p> <p>missing quotes (&quot;&quot;) around 'SA_No'?</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(120) : error C2337: 'SA_Pre' : attribute not found</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(120) : error C2065: 'SA_Yes' : undeclared identifier</p> <p>missing quotes (&quot;&quot;) around 'SA_Yes'?</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(120) : error C2065: 'SA_Read' : undeclared identifier</p> <p>missing quotes (&quot;&quot;) around 'SA_Read'?</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(121) : error C2337: 'SA_Post' : attribute not found</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(121) : error C2065: 'SA_Yes' : undeclared identifier</p> <p>missing quotes (&quot;&quot;) around 'SA_Yes'?</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(121) : error C2337: 'SA_Post' : attribute not found</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(121) : error C2065: 'SA_Maybe' : undeclared identifier</p> <p>missing quotes (&quot;&quot;) around 'SA_Maybe'?</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(121) : error C2337: 'SA_Pre' : attribute not found</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(121) : error C2065: 'SA_Maybe' : undeclared identifier</p> <p>missing quotes (&quot;&quot;) around 'SA_Maybe'?</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(121) : error C2337: 'SA_Pre' : attribute not found</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(121) : error C2065: 'SA_Yes' : undeclared identifier</p> <p>missing quotes (&quot;&quot;) around 'SA_Yes'?</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(121) : error C2337: 'SA_Pre' : attribute not found</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(121) : error C2065: 'SA_Read' : undeclared identifier</p> <p>missing quotes (&quot;&quot;) around 'SA_Read'?</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(121) : error C2337: 'SA_Pre' : attribute not found</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(121) : error C2065: 'SA_No' : undeclared identifier</p> <p>missing quotes (&quot;&quot;) around 'SA_No'?</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(121) : error C2337: 'SA_Pre' : attribute not found</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(121) : error C2065: 'SA_Yes' : undeclared identifier</p> <p>missing quotes (&quot;&quot;) around 'SA_Yes'?</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(121) : error C2065: 'SA_Read' : undeclared identifier</p> <p>missing quotes (&quot;&quot;) around 'SA_Read'?</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(121) : error C2337: 'SA_Pre' : attribute not found</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(121) : error C2065: 'SA_No' : undeclared identifier</p> <p>missing quotes (&quot;&quot;) around 'SA_No'?</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(121) : error C2337: 'SA_Pre' : attribute not found</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(121) : error C2065: 'SA_Yes' : undeclared identifier</p> <p>missing quotes (&quot;&quot;) around 'SA_Yes'?</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(121) : error C2065: 'SA_Read' : undeclared identifier</p> <p>missing quotes (&quot;&quot;) around 'SA_Read'?</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(122) : error C2337: 'SA_Pre' : attribute not found</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(122) : error C2065: 'SA_Maybe' : undeclared identifier</p> <p>missing quotes (&quot;&quot;) around 'SA_Maybe'?</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(122) : error C2337: 'SA_Pre' : attribute not found</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(122) : error C2065: 'SA_Yes' : undeclared identifier</p> <p>missing quotes (&quot;&quot;) around 'SA_Yes'?</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(122) : error C2337: 'SA_Post' : attribute not found</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(122) : error C2065: 'SA_Yes' : undeclared identifier</p> <p>missing quotes (&quot;&quot;) around 'SA_Yes'?</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(123) : error C2337: 'SA_Post' : attribute not found</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(123) : error C2065: 'SA_Yes' : undeclared identifier</p> <p>missing quotes (&quot;&quot;) around 'SA_Yes'?</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(123) : error C2337: 'SA_Post' : attribute not found</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(123) : error C2065: 'SA_Maybe' : undeclared identifier</p> <p>missing quotes (&quot;&quot;) around 'SA_Maybe'?</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(123) : error C2337: 'SA_Pre' : attribute not found</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(123) : error C2065: 'SA_No' : undeclared identifier</p> <p>missing quotes (&quot;&quot;) around 'SA_No'?</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(123) : error C2337: 'SA_Pre' : attribute not found</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(123) : error C2065: 'SA_Yes' : undeclared identifier</p> <p>missing quotes (&quot;&quot;) around 'SA_Yes'?</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(123) : error C2065: 'SA_Read' : undeclared identifier</p> <p>missing quotes (&quot;&quot;) around 'SA_Read'?</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(123) : error C2337: 'SA_Pre' : attribute not found</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(123) : error C2065: 'SA_No' : undeclared identifier</p> <p>missing quotes (&quot;&quot;) around 'SA_No'?</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(123) : error C2337: 'SA_Pre' : attribute not found</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(123) : error C2065: 'SA_Yes' : undeclared identifier</p> <p>missing quotes (&quot;&quot;) around 'SA_Yes'?</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(123) : error C2065: 'SA_Read' : undeclared identifier</p> <p>missing quotes (&quot;&quot;) around 'SA_Read'?</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(124) : error C2337: 'SA_Post' : attribute not found</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(124) : error C2065: 'SA_Yes' : undeclared identifier</p> <p>missing quotes (&quot;&quot;) around 'SA_Yes'?</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(124) : error C2337: 'SA_Post' : attribute not found</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(124) : error C2065: 'SA_Maybe' : undeclared identifier</p> <p>missing quotes (&quot;&quot;) around 'SA_Maybe'?</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(124) : error C2337: 'SA_Pre' : attribute not found</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(124) : error C2065: 'SA_No' : undeclared identifier</p> <p>missing quotes (&quot;&quot;) around 'SA_No'?</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(124) : error C2337: 'SA_Pre' : attribute not found</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(124) : error C2065: 'SA_Yes' : undeclared identifier</p> <p>missing quotes (&quot;&quot;) around 'SA_Yes'?</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(124) : error C2065: 'SA_Read' : undeclared identifier</p> <p>missing quotes (&quot;&quot;) around 'SA_Read'?</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(124) : error C2337: 'SA_Pre' : attribute not found</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(124) : error C2065: 'SA_No' : undeclared identifier</p> <p>missing quotes (&quot;&quot;) around 'SA_No'?</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(124) : error C2337: 'SA_Pre' : attribute not found</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(124) : error C2065: 'SA_Yes' : undeclared identifier</p> <p>missing quotes (&quot;&quot;) around 'SA_Yes'?</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(124) : error C2065: 'SA_Read' : undeclared identifier</p> <p>missing quotes (&quot;&quot;) around 'SA_Read'?</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(124) : error C2337: 'SA_Pre' : attribute not found</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(124) : error C2065: 'SA_No' : undeclared identifier</p> <p>missing quotes (&quot;&quot;) around 'SA_No'?</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(124) : error C2337: 'SA_Pre' : attribute not found</p> <p>c:\programme\microsoft visual studio 9.0\vc\include\malloc.h(124) : fatal error C1003: error count exceeds 100; stopping compilation</p> <p>Build log was saved at &quot;file://c:\Dokumente und Einstellungen\HP_Besitzer\Eigene Dateien\Visual Studio 2008\Projects\BHO_re\Debug\BuildLog.htm&quot;</p> <p>IEHelper - 102 error(s), 0 warning(s)</p> <p>========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========</p></font>Tue, 19 Feb 2008 10:44:43 Z2009-11-28T06:51:27Zhttp://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/4d65e8c7-4557-4773-bc8c-806fb3e7933dhttp://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/4d65e8c7-4557-4773-bc8c-806fb3e7933dstokkiehttp://social.msdn.microsoft.com/Profile/zh-CN/?user=stokkiecrash with Variantclear<br/>My program is crashing sometimes (not always) when the VariantClear function is called. VariantClear is trying to clean up a BString at the end of a thread. The Bstring is a message that is used for an input parameter of a com method. The event viewer shows that an access violation occured during the crash.<br/>Anyone already has a clue? I'll put my code snippet here (it's the VariantClear at the end of the thread): <pre lang=x-cpp>unsigned long __stdcall ProcessMSG( void* pArguments ) { BSTR bstrInput; UINT OleBufLen = 0; char szLogBuffer[MAXBUF]; // Used as buffer to format logoutput for MQ2COM // ------------- // COM variables // ------------- VARIANT vArgsTypeText[1]; /* VARIANT, COM Invoke parameter */ VARIANT vResult; /* VARIANT, COM Invoke parameter */ DISPPARAMS dpTypeText; /* VARIANT, COM Invoke parameter */ // ------------------------ // Initialize COM variables // ------------------------ HRESULT hResult = S_OK; /* Result handle */ int iResult = 0; // ------------ // MQ variables // ------------ MQMD mqOutputMessageDescriptor = {MQMD_DEFAULT}; /* Local Output Message Descriptor */ // --------------- // Timer variables // --------------- clock_t tStart; clock_t tFinish; // -------------------------------------------- // Initialize buffers for LOG and DATA messages // -------------------------------------------- char *pszTempBuffer = NULL; char *pszLogBuffer = NULL; unsigned long ulThisThreadID; // -------------------------------- // Initialize variable containing id of this thread for logging to recognise which thread is putting the log message // -------------------------------- ulThisThreadID = GetCurrentThreadId(); // ------------------------------------------------- // Set the CPU clock marking for statistical logging // ------------------------------------------------- tStart = clock(); // -------------------------------- // Initialize COM Invoke parameters // -------------------------------- VariantInit(&amp;vArgsTypeText[1]); VariantInit(&amp;vResult); // ---------------------------------------------------------------------------------------------------- // Put methode name and request buffer (input message) in an BSTR as needed for using the COM Interface // ---------------------------------------------------------------------------------------------------- //ThreadParameters* pThreadParameters; //pThreadParameters = (ThreadParameters*) pArguments; //bstrInput = SysAllocString(CComBSTR((char*)pThreadParameters-&gt;pszSendBuffer)); bstrInput = SysAllocString(CComBSTR((char*)pArguments)); /* This function allocates a new string and copies the passed string into it. */ // ------------------------------------------------------------------- // Input message descriptor is copied to the output message descripton // ------------------------------------------------------------------- /* Memcpy copies characters between buffers; */ /* void *memcpy( void *dest, const void *src, size_t count ) */ memcpy(&amp;mqOutputMessageDescriptor, &amp;g_pMq-&gt;m_mqInputMessageDescriptor, sizeof(g_pMq-&gt;m_mqInputMessageDescriptor)); memcpy(&amp;mqOutputMessageDescriptor.CorrelId, &amp;g_pMq-&gt;m_mqInputMessageDescriptor.CorrelId, sizeof(g_pMq-&gt;m_mqInputMessageDescriptor.CorrelId)); memcpy(&amp;mqOutputMessageDescriptor.MsgId, &amp;g_pMq-&gt;m_mqInputMessageDescriptor.MsgId, sizeof(g_pMq-&gt;m_mqInputMessageDescriptor.MsgId)); mqOutputMessageDescriptor.CodedCharSetId = MQCCSI_Q_MGR; /* PH, 20031215 Codedcharachterset-id of queuemanager to which MQ2COM has been connected. */ // ---------------------------------------------------------- // Leave the critical section so Supervisor loop can continue // ---------------------------------------------------------- ::LeaveCriticalSection(&amp;csSupCriticalSection); /* The LeaveCriticalSection function releases ownership of the specified critical section object. */ // ---------------------- // Copy Buffer to Variant // ---------------------- vArgsTypeText[0].vt = VT_BSTR; /* vArgsTypeText is a variant. A variant always contains 2 fields. vt stands for variable type?*/ vArgsTypeText[0].bstrVal = bstrInput; /* Fill a variant with the request message */ // -------------------- // Set method arguments // -------------------- /* Fill the Dispatch parameter structure. We expect 1 unnamed argument. DISPPARAMS.cArgsargument // Amount of unnamed arguments of the method. DISPPARAMS.cNamedArgs // Amount of named arguments of the method. DISPPARAMS.rgvarg // Array of argument values in reverse order. The parameters of the methode of the COM object. With reverse order we mean that the last element of the array will contain the first parameter of the method. */ dpTypeText.cArgs = 1; /* In this case rgvarg will contain just 1 argument */ dpTypeText.cNamedArgs = 0; dpTypeText.rgvarg = vArgsTypeText; //BS,16022009, CoInitializeEx verplaatst naar de processmessage // ---------------------------------------- // Initialize the COM library MULTITHREADED // ---------------------------------------- hResult = CoInitializeEx(NULL, COINIT_MULTITHREADED); /* Initializes the COM library for use by the calling thread, sets the thread's concurrency model, */ /*and creates a new apartment for the thread if one is required. */ if (FAILED(hResult)) { // Log naar BIMon queue (Event) sprintf(szLogBuffer,&quot;Thread %d: Failed to initialize COM library&quot;,ulThisThreadID); logMessage(1,szLogBuffer); return -1; } // ---------------------------------------------------- // Call method ... of COM object to execute COM methode // ---------------------------------------------------- /* The method IDispatch::Invoke provides access to properties and methods exposed by an object. HRESULT Invoke( DISPID dispIdMember, // Identifies the member. Use GetIDsOfNames or the object’s documentation to obtain the dispatch identifier. REFIID riid, // Reserved for future use; set to IID_NULL. LCID lcid, // The locale context in which to interpret parameters. WORD wFlags, // Flags describing the context (A method or a property) of the Invoke call. DISPATCH_METHOD: The member is invoked as a method. DISPPARAMS FAR *pDispParams, // Pointer to a structure that contains an array of parameters, an array of parameter DISPIDs for named parameters, and counts for the number of elements in the arrays. VARIANT FAR *pVarResult, // Pointer to the location where the result is to be stored, or NULL if the caller expects no result. EXCEPINFO FAR *pExcepInfo, // Pointer to a structure that contains exception information. Can be NULL. unsigned int FAR *puArgErr // The index within rgvarg of the first parameter that has an error. ); */ sprintf(szLogBuffer,&quot;Thread %d: Calling the method of the COM object specified in the ini file&quot;,ulThisThreadID); logMessage(4,szLogBuffer); //16-02-2009, BAST, CoInitializeEx try { hResult = pDispatch-&gt;Invoke(dispid_Class, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &amp;dpTypeText, &amp;vResult, NULL, NULL); } catch( _com_error &amp;e ) { sprintf(szLogBuffer,&quot;Thread %d: Com error opgetreden bij aanroep com method&quot;,ulThisThreadID); logMessage(4,szLogBuffer); // Crack _com_error // _bstr_t bstrSource(e.Source()); // _bstr_t bstrDescription(e.Description()); // // TRACE( &quot;Exception thrown for classes generated by #import&quot; ); // TRACE( &quot;\tCode = %08lx\n&quot;, e.Error()); // TRACE( &quot;\tCode meaning = %s\n&quot;, e.ErrorMessage()); // TRACE( &quot;\tSource = %s\n&quot;, (LPCTSTR) bstrSource); // TRACE( &quot;\tDescription = %s\n&quot;, (LPCTSTR) bstrDescription); } catch (...) { sprintf(szLogBuffer,&quot;Thread %d: Unhandled Exception opgetreden bij aanroep com method&quot;,ulThisThreadID); logMessage(4,szLogBuffer); } sprintf(szLogBuffer,&quot;Thread %d: After calling the method of the COM object specified in the ini file&quot;,ulThisThreadID); logMessage(4, szLogBuffer); if (FAILED(hResult)) { // Log naar BIMon queue (Event) (PH, 12-11-2003, changed, sprintf statement added and second parameter of LogMessage changed from &quot;Method ..&quot; to szLogBuffer. //sprintf(szLogBuffer,&quot;Method Invoke returned an Error&quot;); //logMessage(1,szLogBuffer); switch (hResult) { case S_OK: {sprintf(szLogBuffer,&quot;Thread %d: Method Invoke returned an Error, S_OK&quot;,ulThisThreadID);} break; case DISP_E_BADPARAMCOUNT: {sprintf(szLogBuffer,&quot;Thread %d: Method Invoke returned an Error, DISP_E_BADPARAMCOUNT&quot;,ulThisThreadID);} break; case DISP_E_BADVARTYPE: {sprintf(szLogBuffer,&quot;Thread %d: Method Invoke returned an Error, DISP_E_BADVARTYPE&quot;,ulThisThreadID);} break; case DISP_E_EXCEPTION: {sprintf(szLogBuffer,&quot;Thread %d: Method Invoke returned an Error, DISP_E_EXCEPTION&quot;,ulThisThreadID);} break; case DISP_E_MEMBERNOTFOUND: {sprintf(szLogBuffer,&quot;Thread %d: Method Invoke returned an Error, DISP_E_MEMBERNOTFOUND&quot;,ulThisThreadID);} break; case DISP_E_NONAMEDARGS: {sprintf(szLogBuffer,&quot;Thread %d: Method Invoke returned an Error, DISP_E_NONAMEDARGS&quot;,ulThisThreadID);} break; case DISP_E_OVERFLOW: {sprintf(szLogBuffer,&quot;Thread %d: Method Invoke returned an Error, DISP_E_OVERFLOW&quot;,ulThisThreadID);} break; case DISP_E_PARAMNOTFOUND: {sprintf(szLogBuffer,&quot;Thread %d: Method Invoke returned an Error, DISP_E_PARAMNOTFOUND&quot;,ulThisThreadID);} break; case DISP_E_TYPEMISMATCH: {sprintf(szLogBuffer,&quot;Thread %d: Method Invoke returned an Error, DISP_E_TYPEMISMATCH&quot;,ulThisThreadID);} break; case DISP_E_UNKNOWNINTERFACE: {sprintf(szLogBuffer,&quot;Thread %d: Method Invoke returned an Error, DISP_E_UNKNOWNINTERFACE&quot;,ulThisThreadID);} break; case DISP_E_UNKNOWNLCID: {sprintf(szLogBuffer,&quot;Thread %d: Method Invoke returned an Error, DISP_E_UNKNOWNLCID&quot;,ulThisThreadID);} break; case DISP_E_PARAMNOTOPTIONAL: {sprintf(szLogBuffer,&quot;Thread %d: Method Invoke returned an Error, DISP_E_PARAMNOTOPTIONAL&quot;,ulThisThreadID);} break; default: {sprintf(szLogBuffer,&quot;Thread %d: Method Invoke returned an Error, Unknown error %d&quot;,ulThisThreadID, hResult);} } logMessage(1,szLogBuffer); // --------------------------------------------------------------------------------------- // PH, 2004-03-15, When failed then also ... // Free allocated buffers; IDispatch argument and the Input message and Release COM object // --------------------------------------------------------------------------------------- VariantClear(&amp;vArgsTypeText[1]); ::SysFreeString(bstrInput); return -2; } sprintf(szLogBuffer,&quot;Thread %d: Method of com object did not return an error&quot;,ulThisThreadID); logMessage(4,szLogBuffer); //BS, 16022009: CoUninitialize() weer terug in processmesg // --------------------------------------------------------- // Closes the COM library on the current thread, // unloads all DLLs loaded by the thread, // frees any other resources that the thread maintains, and // forces all RPC connections on the thread to close. // --------------------------------------------------------- CoUninitialize(); // ------------------- // Build reply message // ------------------- if (vResult.vt == VT_BSTR) { sprintf(szLogBuffer,&quot;Thread %d: Begin build reply message&quot;,ulThisThreadID); logMessage(4,szLogBuffer); // ---------------------------------------------------------------------------------- // Calculated length of the string parameter returned by the method of the COM object // ---------------------------------------------------------------------------------- OleBufLen = SysStringLen(vResult.bstrVal); /* A variant, in our case vResult, exists of 2 fields; vt and bstrVal*/ // ----------------------------------------------------- // Alloc the buffer for return message + null terminator // ----------------------------------------------------- pszTempBuffer = new char[OleBufLen + 1]; // --------------------------------------------------------- // Copy the buffer to pszTempBuffer WITH the 0 terminator // You can verify the copy with the \0 terminator. Length is OleBufLen + 1 // A few statements futher the terminator is still placed to be absolutely // certain that it is done correctly // --------------------------------------------------------- sprintf(szLogBuffer,&quot;Thread %d: Begin conversion widechartomultibyte&quot;,ulThisThreadID); logMessage(4,szLogBuffer); iResult = WideCharToMultiByte(CP_ACP,0,vResult.bstrVal,OleBufLen + 1, pszTempBuffer,OleBufLen + 1,NULL,NULL); if ( iResult == 0) { // if the result code is zero '0' an error occurred in the above function call DWORD dw = GetLastError(); sprintf(szLogBuffer,&quot;Thread %d: buffer conversion unicode to multcode failed code = %u Application will exit\n&quot;,ulThisThreadID,dw); logMessage(1,szLogBuffer); exit(-2); } sprintf(szLogBuffer,&quot;Thread %d: widechartomultibyte did not return an error&quot;,ulThisThreadID); logMessage(4,szLogBuffer); // ------------------------- // Place the null terminator // ------------------------- pszTempBuffer[OleBufLen] = '\0'; // ------------------------------------------------------------------------------- // Release memory from output buffer/return buffer of the method of the COM object // ------------------------------------------------------------------------------- VariantClear(&amp;vResult); // ---------------------------- // Write reply message to queue // ---------------------------- // PH, 21-01-2004, added sprintf(szLogBuffer,&quot;Thread %d: put Reply Message to Output Queue&quot;,ulThisThreadID); logMessage(3,szLogBuffer); if(! g_pMq-&gt;PutMessage( pszTempBuffer, g_pMq-&gt;GetOutputQ(), RFH2, mqOutputMessageDescriptor)) { sprintf(szLogBuffer,&quot;Thread %d: put Failed. Application will continue\n&quot;,ulThisThreadID); logMessage(1,szLogBuffer); } // ------------------------- // Free the temporary buffer // ------------------------- if (pszTempBuffer != NULL) { delete [] pszTempBuffer; } } // ------------------------------------------ // Log to BIMon Queue (Snapshot, statistics) // ------------------------------------------ // --------------------------------------------------- // set the &quot;clock end marking&quot; for statistical logging // --------------------------------------------------- tFinish = clock(); g_pMq-&gt;LOGGING.dElapsedMsgTime = (double)(tFinish - tStart) / CLOCKS_PER_SEC; // --------------------------- // Construct message for BIMon // --------------------------- pszLogBuffer = g_pMq-&gt;ConstructStatBuffer(); // -------------------------- // Put message on BIMon queue // -------------------------- // PH, 21-01-2004, added sprintf(szLogBuffer,&quot;Thread %d: snapshot Message to BIMon Queue (statistical queue)&quot;,ulThisThreadID); logMessage(3,szLogBuffer); if(! g_pMq-&gt;PutMessage( pszLogBuffer, g_pMq-&gt;GetStatQ(), DEFAULT, mqOutputMessageDescriptor)) { // Log (PH, 12-11-2003, changed, sprintf statement added and second parameter of LogMessage changed from &quot;Put ..&quot; to szLogBuffer. sprintf(szLogBuffer,&quot;Thread %d: put Failed. Check the ini-Configuration. Application will exit\n&quot;,ulThisThreadID); logMessage(1,szLogBuffer); exit(-2); } sprintf(szLogBuffer,&quot;Thread %d: ProcessMsg: Free allocated memory of Log Buffer&quot;,ulThisThreadID); logMessage(4,szLogBuffer); // ----------------------------------- // Free allocated memory of log buffer // ----------------------------------- if (pszLogBuffer != NULL) { delete [] pszLogBuffer; } sprintf(szLogBuffer,&quot;Thread %d: ProcessMsg: Free allocated buffers of IDispatch argument&quot;,ulThisThreadID); logMessage(4,szLogBuffer); // ---------------------------------------------------------------- // Free allocated buffers; IDispatch argument and the Input message // ---------------------------------------------------------------- VariantClear(&amp;vArgsTypeText[1]); sprintf(szLogBuffer,&quot;Thread %d: ProcessMsg: Free allocated buffers of the Input message&quot;,ulThisThreadID); logMessage(4,szLogBuffer); ::SysFreeString(bstrInput); // --------------------- // Terminate this thread // --------------------- sprintf(szLogBuffer,&quot;Thread %d: ProcessMsg: Leave ProcessMsg function&quot;,ulThisThreadID); logMessage(4,szLogBuffer); return 0; }</pre>Fri, 20 Nov 2009 15:34:42 Z2009-11-28T06:23:24Zhttp://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/bd446d59-1929-4f5d-82fb-1fc63173fe69http://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/bd446d59-1929-4f5d-82fb-1fc63173fe69eswar pothulahttp://social.msdn.microsoft.com/Profile/zh-CN/?user=eswar%20pothulais it possible to convert speech to text.hi every body,<br/> <br/> in my application convert voice to text is required,<br/> <br/> but i am getting to text to speech tools only and these tools working properly.<br/> <br/> but my work is if any person record voice is  &quot;hi how are you&quot;  then it is automatically displayed in text box(or)edit box  &quot;hi how are you&quot;<br/> <br/> and one more thing is my application developed in vc++6.0,<br/> <br/> please help me ,<br/> thanks in advance............<br/>Fri, 27 Nov 2009 10:26:20 Z2009-11-28T05:46:33Zhttp://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/355b93c4-f093-47f1-ad67-9635c6dfb650http://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/355b93c4-f093-47f1-ad67-9635c6dfb650Firebug99http://social.msdn.microsoft.com/Profile/zh-CN/?user=Firebug99WIN32_LEAN_AND_MEANwhat is this and how can i get rid of it. it is in the file stdafx.h when I start a win32 project.<hr class="sig">A young neophyte programmerTue, 24 Nov 2009 02:33:55 Z2009-11-28T03:04:06Zhttp://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/e7e8e2be-8248-40ee-a465-18dbbc8e6729http://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/e7e8e2be-8248-40ee-a465-18dbbc8e6729p3t3r5229http://social.msdn.microsoft.com/Profile/zh-CN/?user=p3t3r5229Microsoft Visual C++ 2008 Redistributable Package (x86)<p align=left><font face="Times New Roman" size=2>i would like to ask for help.. </font></p> <p align=left><font face="Times New Roman" size=2>i got Microsoft Visual C++ 2005 Redistributable Package (x86) installed in my laptop, but i would like to </font></p> <p align=left><font face="Times New Roman" size=2>upgrade it to Microsoft Visual C++ 2008 Redistributable Package (x86).</font></p> <p align=left> </p> <p align=left>so my question is, do i have to uninstall Microsoft Visual C++ 2005 Redistributable Package (x86), before install Microsoft Visual C++ 2008 Redistributable Package (x86)?</p> <p align=left> </p> <p align=left>please help me and email me at <a title="mailto:p3t3r5229@yahoo.co.uk" href="mailto:p3t3r5229@yahoo.co.uk">p3t3r5229@yahoo.co.uk</a></p> <p align=left> </p> <p align=left>thank you for your kind help.</p> <p align=left><font face="Times New Roman"></font> </p> <p align=left><font face="Times New Roman"></font> </p>Wed, 26 Mar 2008 11:17:38 Z2009-11-28T02:04:02Zhttp://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/0ab3860e-da8d-4a85-b768-f32dbcc6ea8fhttp://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/0ab3860e-da8d-4a85-b768-f32dbcc6ea8fMichał Januszczykhttp://social.msdn.microsoft.com/Profile/zh-CN/?user=Micha%u0142%20JanuszczykOpen-With menu items for given file extensionHi, <br/>I need the list of executables' paths registered to appear in open-with context menu for particular extensions.<br/><br/>I suppose that there is no managed API for that, so I might see a native approach, and convert that to managed version with pInvoke if possible...<br/><br/>//pseudo code: <br/>String[] GetPathsOfRegisteredPrograms(String extension)<br/>{<br/>   // how to get the list... ? <br/>}<br/><br/>example usage: <br/>String[] executablePaths = GetPathsOfRegisteredPrograms(&quot;.jpg&quot;);<br/><br/>//should return list: <br/>c:\windows\PhotoAndFaxViewer.exe<br/>c:\windows\Notepad.exe<br/>c:\Program Files\Photoshop\Ps.exe<br/>..and so on...<br/><br/>Thanks, <br/>Michal <br/>Sat, 28 Nov 2009 00:18:57 Z2009-11-28T01:56:24Zhttp://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/d7fa3f2c-12bf-4180-8021-f3dbb4f211fahttp://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/d7fa3f2c-12bf-4180-8021-f3dbb4f211faNarnianhttp://social.msdn.microsoft.com/Profile/zh-CN/?user=NarnianHmmm, started VS Starting, what are we doing wrong?My coworker and I are building a windows service that scans an FTP folder for specific files, and then loads the data into SQL server when new files appear.  The service starts up and runs correctly (in the sense that it does what it supposed to do) but when you look in the control panel and open up &quot;services&quot; it says &quot;starting . . .&quot; and never actually says it's started.<br/><br/>Anyone have any suggestions?  Is there some simple thing we're supposed to do to let the operating system know that the service has successfully started?Fri, 27 Nov 2009 22:49:51 Z2009-11-27T22:59:32Zhttp://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/e885a9c5-c083-43e1-82e9-d2b8c5b67600http://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/e885a9c5-c083-43e1-82e9-d2b8c5b67600_Well_http://social.msdn.microsoft.com/Profile/zh-CN/?user=_Well_CMFCToolBar. How to add control?I have trouble without ends with the new CMFCToolBar. I try to add some controls to my toolbar and unsuccessfully! I even tried to adapt the ToolBarTimeDatePicker example, it doesn't really work actually!<br/> MY CASE: I have no Menu, only ToolBar, and I do not need Customize Option for ToolBar. So I excluded it from the project. So what I need is a simple toolbar with edit in it. To make it as it seems I need to add new Button and some code in OnToolbarReset(WPARAM wp,LPARAM) function. Which I did:<br/>           <br/> <pre lang=x-cpp> CMFCToolBarEditBoxButton myEdtButton (ID_TEST, GetCmdMgr ()-&gt;GetCmdImage (ID_TEST,FALSE),WS_TABSTOP|ES_LEFT|ES_UPPERCASE|WS_BORDER); m_wndToolBar.ReplaceButton (ID_TEST, myEdtButton ); </pre> Please help me. What can I do, just to see the EDIT CONTROL? I am desparately struggling with it without success.<br/> <br/> Thanks in advance.Fri, 27 Nov 2009 16:04:31 Z2009-11-27T22:39:22Zhttp://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/45b5b951-f5b6-49df-9f23-b2e2960d0a78http://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/45b5b951-f5b6-49df-9f23-b2e2960d0a78Andrey Nautilushttp://social.msdn.microsoft.com/Profile/zh-CN/?user=Andrey%20NautilusAbstract class instantiation<p><span style="font-size:x-small">In VS2008 I faced with very interesting problem.<br/></span><span style="font-size:x-small"><span style="font-size:x-small">Here is the source code:</span><br/></span><span style="font-size:x-small"><br/>struct IMyClass<br/>{<br/>public:<br/>   int field;<br/>   IMyClass(int a): field(a) {}<br/>   virtual int foo() const = 0;<br/>};</span></p> <p><span style="font-size:x-small">int func_foo(const IMyClass &amp;obj)<br/>{<br/>   return obj.foo();<br/>}</span></p> <p><span style="font-size:x-small">int main(void)<br/>{<br/>   func_foo(1);<br/>   return 0;<br/>}<br/><br/>when function func_foo is called in main, number 1 is implicitly casted to IMyClass by creating an object of the IMyClass type. In fact, in func_foo I have an ordinary object of an abstract class :) And operator sizeof(obj) returns 4, but sizeof(IMyClass) returns 8.</span> <br/><span style="font-size:x-small"><br/>I compiled this code with warning level 4, and there were no messages.<br/></span><span style="font-size:x-small;font-family:"><br/>Of course, in runtime this program fails at line obj.foo() with exception R6025 &quot;pure virtual function call&quot;, The most amazing is that an object of an abstract class was created. :)</span></p>Fri, 27 Nov 2009 07:02:27 Z2009-11-28T08:41:55Zhttp://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/54765215-d363-4279-8062-7034aeabbd48http://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/54765215-d363-4279-8062-7034aeabbd48JGMillerhttp://social.msdn.microsoft.com/Profile/zh-CN/?user=JGMillerWinSxS mfc80.dll won't load WinSxS msvcr80.dll<p>I am trying to fix a client's problem with one of my company's products.  One of the dll's won't register there, but works here (isn't always the case).  I had them do a dependency walker check and it states that msvcr80.dll cannot be found under the WinSxS mfc80.dll branch.  However the very next branch has the WinSxS msvcr80.dll loading fine.</p> <p>winsxs\*4053*\mfc80.dll<br/>     - msvcr80.dll (dependency not found)<br/>     - (other dlls)<br/>winsxs\*4053*\msvcr80.dll  (this branch has no errors)</p> <p>I don't understand why it produces a dependency not found when in fact it has it in another branch.</p> <p>Any suggestions?</p> <p> </p><hr class="sig">John MillerTue, 24 Nov 2009 12:49:35 Z2009-11-27T20:46:38Zhttp://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/c56223aa-e2ae-4aad-87bf-9e6787e88dbahttp://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/c56223aa-e2ae-4aad-87bf-9e6787e88dbaVitalikVhttp://social.msdn.microsoft.com/Profile/zh-CN/?user=VitalikVIs it possible to pull through _ConnectionPtr clean hands?<span class="short_text"><span title="OLE DB Services=-1">OLE DB Services =- 1<br/> </span> <span title="Возможно ли через &#9;_ConnectionPtr очистить пулл руками?">Is it possible to pull through _ConnectionPtr clean hands?</span> </span>Thu, 26 Nov 2009 14:58:39 Z2009-11-27T17:10:20Zhttp://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/9efb2196-1474-4a3b-a637-2dfda39f8997http://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/9efb2196-1474-4a3b-a637-2dfda39f8997kalamramhttp://social.msdn.microsoft.com/Profile/zh-CN/?user=kalamramchild process termination info without wait timehi,<br/> <br/> I am creating one application that receive command string and start the different application using createProcess().<br/> <br/> So, when the child process terminates, i need to intimate parent process about it.<br/> <br/> Actually,. i used WaitForSingleObject().<br/> <br/> but, one problem is the parent application strucked(paused) untill child application terminated.<br/> <br/> In my program, I continuously receive command string and start different application.<br/> <br/> So, I can't wait each child process to terminate.<br/> <br/> I got one suggestion to use thread for waiting child process termination.<br/> <br/> But, that also problem, because i need to create thread for each child process and declare child process information structure globally for each createProcess().<br/> <br/> my code is,<br/> [code]<br/> <br/> // while loop to check continuous socket connection<br/>     while (1)<br/>     {<br/>         int str1,str2;<br/>         char *cmdName = NULL;<br/>         printf(&quot;while begin \n&quot;);<br/>         aSock = INVALID_SOCKET;<br/>         asSize = sizeof(serverSock);<br/>         printf(&quot;a1\n&quot;);<br/>         while(aSock == INVALID_SOCKET)<br/>         {    <br/>             printf(&quot;while aSock= %d\n&quot;,aSock);<br/>             aSock = accept(sock, (struct sockaddr *)&amp;serverSock,(int *) &amp;asSize);    <br/>             printf(&quot; aSock = %d\n&quot;,aSock);<br/>         }<br/>         printf(&quot;aSock= %d\n&quot;,aSock);<br/>         printf(&quot;a3\n&quot;);<br/> #if 0<br/>         while (aSock == SOCKET_ERROR)<br/>         {<br/>             //aSock = accept(sock,(struct sockaddr *)&amp;serverSock, &amp;asSize);<br/>                 aSock = accept(sock, NULL, NULL);<br/>         }<br/> #endif<br/>         if (aSock == SOCKET_ERROR)<br/>         {<br/>             printf(&quot;a4\n&quot;);<br/>             printf(&quot;sockserver: accept() error!. \n&quot;);<br/>         }<br/>      // When SAS server connection accepted, change the temp socket (aSock) connection to original one (sock)<br/>     printf(&quot;a5\n&quot;);<br/>     printf(&quot;sockserver: SAS Connected!\n&quot;);<br/>     printf(&quot;test 0\n&quot;);<br/>     //sock = aSock; <br/>     printf(&quot;test 1\n&quot;);<br/> //**************************************<br/>     memset(dataBuffer, '\0', sizeof(dataBuffer));<br/>     byteRecv = recv(aSock,dataBuffer,sizeof(dataBuffer),0);<br/>     printf(&quot; String Received ============= %s \n&quot;, dataBuffer);<br/>     str1 = strlen(dataBuffer);<br/>     printf(&quot;String length ============= %d \n&quot;, str1);<br/>     str1 = strlen(dataBuffer);<br/>     dataBuffer[byteRecv] = '\0';<br/> <br/>     printf(&quot; String Received after   ****============= %s \n&quot;, dataBuffer);<br/>     str2 = strlen(dataBuffer);<br/>     //printf(&quot;String length  after ============= %d \n&quot;, str2);<br/>     if(dataBuffer == NULL || strlen(dataBuffer) == 0 )<br/>     {<br/>         printf(&quot;String is null \n&quot;);<br/>     }<br/>     <br/>     printf(&quot;test 1b\n&quot;);<br/>     if(byteRecv == SOCKET_ERROR)<br/>     {<br/>         printf(&quot;test 1c\n&quot;);<br/>         printf(&quot;Data sent by SAS server is not received!. \n&quot;);<br/> <br/>     }<br/>     else<br/>     {<br/>        printf(&quot;test 1d\n&quot;);<br/>        printf(&quot;sockserver: Received data is: %s \n&quot;, dataBuffer);<br/>        printf(&quot;sockserver: Bytes received: %ld.\n&quot;, byteRecv);<br/>     //   closesocket(aSock);<br/> <br/>     }<br/>     cmdName = strtok_s( dataBuffer, seps, &amp;next_token);<br/>     printf(&quot; cmdName : %s \n&quot;, cmdName);<br/> <br/>     if (strcmp(cmdName,&quot;cmdStartApplication&quot;) == 0)<br/>     {<br/>         printf(&quot;test 1 \n&quot;);<br/>             int i = 0;<br/> //            int k;            <br/>             int eindex;            <br/>             char *event_index = NULL; // ATSC event index<br/>             char *arg = NULL;<br/> //            wchar_t *myargv[APPL_MAX_ARGS];<br/>             //wchar_t *myargv;<br/>             wchar_t *exeName;<br/>             //char *exeName;<br/>             DWORD exitCode;<br/>             int pExitValue;<br/>             int waitid;<br/>         <br/>             STARTUPINFO si;<br/>             PROCESS_INFORMATION pi;<br/>             int pid,cpid;<br/>             //wchar_t *exeName;                  <br/>             ZeroMemory( &amp;si, sizeof(si) );  // windows equivalent to memset<br/>             si.cb = sizeof(si);<br/>             ZeroMemory( &amp;pi, sizeof(pi) );<br/>             event_index = strtok_s (NULL,seps,&amp;next_token); <br/>             printf(&quot;test 3 \n&quot;);<br/>             //exeName = strtok_s (NULL,seps,&amp;next_token); <br/>             //exeName = _tcsdup(TEXT(&quot;\&quot;E:\\dLs\\Java\\jre-6u16-windows-i586-s\&quot;&quot;));<br/>             //exeName = _tcsdup(TEXT(&quot;\&quot;E:\\dLs\\Java\\jre-6u16-windows-i586-s\&quot;&quot;));<br/>             exeName = _tcsdup(TEXT(&quot;\&quot;c:\\WINDOWS\\notepad.exe\&quot;&quot;));<br/>             //exeName = &quot;c:\\WINDOWS\\notepad.exe&quot;;<br/>             //exeName = _tcsdup(TEXT(&quot;\&quot;D:\\mypgms\\Daemon_pgms\\sockclient\\Debug\\sockclient\&quot;&quot;));<br/>             //exeName =(wchar_t *) &quot;notepad&quot;;<br/>             printf(&quot;test 4 \n&quot;);<br/>             /*for(k=0; k&lt;APPL_MAX_ARGS; k++)<br/>             {<br/>                 myargv[k] = (wchar_t *)NULL;<br/>             } */<br/> <br/>              // Start the child process. <br/>             //*********************************************************************************<br/>     aThread = CreateThread( <br/>                      NULL,       // default security attributes<br/>                      0,          // default stack size<br/>                      (LPTHREAD_START_ROUTINE) waitpid, <br/>                      NULL,       // no thread function arguments<br/>                      0,          // default creation flags<br/>                      &amp;ThreadID); // receive thread identifier<br/> <br/>         if( aThread == NULL )<br/>         {<br/>             printf(&quot;CreateThread error: %d\n&quot;, GetLastError());<br/>             return;<br/>         }<br/> //********************************************************************************<br/>             if(( cpid=CreateProcess( NULL,   // No module name (use command line)<br/>                 (LPWSTR)exeName,        // Command line<br/>                 NULL,           // Process handle not inheritable<br/>                 NULL,           // Thread handle not inheritable<br/>                 FALSE,          // Set handle inheritance to FALSE<br/>                 0,              // No creation flags<br/>                 NULL,           // Use parent's environment block<br/>                 NULL,           // Use parent's starting directory <br/>                 &amp;si,            // Pointer to STARTUPINFO structure<br/>                 &amp;pi )           // Pointer to PROCESS_INFORMATION structure<br/>             ) != NULL)<br/>             {<br/>                 pid = pi.dwProcessId;                <br/>                 printf( &quot;VMService: CreateProcess Successed for cmdStartApllication, CPID is: %d.\n&quot;, cpid );<br/>                 printf(&quot;System child process ID: %d \n&quot;, pid);<br/>                 eindex = atoi(event_index);<br/>                 addNode(pid, eindex, aSock);    <br/>                 printf(&quot;*********** After add NODE ******************\n&quot;);<br/>                 //closesocket(aSock);    /* No need to close the socket. */<br/>                 //return 0;<br/>             }<br/>             else<br/>             {<br/>                  printf( &quot;VMService: CreateProcess failed (%d).\n&quot;, GetLastError() );<br/>                 //return -1;<br/>             }<br/> <br/>             /* Wait until child process exits. */<br/>             printf(&quot; WaitForSingleObject() in cmdStartAppl called ... \n&quot;);<br/>              waitid = WaitForSingleObject( pi.hProcess, INFINITE );<br/>              sigchld_handler (pid);<br/>              switch (waitid) {<br/>                         case WAIT_FAILED:<br/>                             sigchld_handler (pid);<br/>                             printf(&quot;WAIT_FAILED&quot;);<br/>                             break;<br/>                         case WAIT_ABANDONED:<br/>                             sigchld_handler (pid);<br/>                             printf(&quot;WAIT_ABANDONED&quot;);<br/>                             break;<br/>                         case WAIT_OBJECT_0:<br/>                             printf(&quot;WAIT_OBJECT_0&quot;);<br/>                             break;<br/>                         case WAIT_TIMEOUT:<br/>                             sigchld_handler (pid);<br/>                             printf(&quot;WAIT_TIMEOUT&quot;);<br/>                             break;<br/>                         default:<br/>                             printf(&quot;...&quot;);<br/>                             break;<br/>                         }<br/> <br/>                 pExitValue = GetExitCodeProcess(pi.hProcess, &amp;exitCode);<br/>                 if (pExitValue != 0)<br/>                 {<br/>                     /*switch(exitCode)<br/>                     {<br/>                     case STILL_ACTIVE: printf(&quot;Process is still active\n&quot;);<br/>                     break;<br/>                     default: printf(&quot;Exit code = %d\n&quot;, exitCode);<br/>                     break;<br/>                     } */<br/> <br/>                     if (exitCode == STILL_ACTIVE)<br/>                     {<br/>                         printf(&quot;startCmdApplication is still running \n&quot;);<br/>                     }<br/>                     else<br/>                     {<br/>                         printf(&quot;startCmdApplication is exits \n&quot;);<br/>                     }<br/>                 }<br/>                 else{<br/>                     printf(&quot;GetExitCodeProcess() failed with erroe code: %d \n&quot;, GetLastError() );<br/>                 }<br/> <br/>             /* Close process and thread handles.  */<br/>             CloseHandle( pi.hProcess );<br/>             CloseHandle( pi.hThread );<br/>             continue;<br/>     }<br/>     else<br/>     {<br/>         printf(&quot;cmdStartApllication failed. \n&quot;);<br/>         //continue;<br/>     }<br/>     <br/> <br/>     //cmdStartServer<br/>     if (strcmp(cmdName,&quot;cmdStartServer&quot;) == 0)<br/>     {<br/>         printf(&quot;test 21 \n&quot;);<br/>             int i = 0;<br/> //            int k;            <br/>             int eindex;            <br/>             char *event_index = NULL; // ATSC event index<br/>             char *arg = NULL;<br/>             //wchar_t *myargv[APPL_MAX_ARGS];<br/>             //wchar_t *myargv;<br/>             wchar_t *exeName;<br/>             //char *exeName;<br/>         <br/>             STARTUPINFO si;<br/>             PROCESS_INFORMATION pi;<br/>             int pid,cpid;<br/>             //wchar_t *exeName;                  <br/>             ZeroMemory( &amp;si, sizeof(si) );  // windows equivalent to memset<br/>             si.cb = sizeof(si);<br/>             ZeroMemory( &amp;pi, sizeof(pi) );<br/>             event_index = strtok_s (NULL,seps,&amp;next_token); <br/>             printf(&quot;test 3 \n&quot;);<br/>     //        exeName =strtok_s (NULL,seps,&amp;next_token); <br/>             //exeName = _tcsdup(TEXT(&quot;\&quot;E:\\dLs\\Java\\jre-6u16-windows-i586-s\&quot;&quot;));<br/>             //exeName = _tcsdup(TEXT(&quot;\&quot;E:\\dLs\\Java\\jre-6u16-windows-i586-s\&quot;&quot;));<br/>             exeName = _tcsdup(TEXT(&quot;\&quot;c:\\WINDOWS\\notepad\&quot;&quot;));<br/>             //exeName = _tcsdup(TEXT(&quot;\&quot;D:\\mypgms\\Daemon_pgms\\sockclient\\Debug\\sockclient\&quot;&quot;));<br/>         //    exeName =(wchar_t *) &quot;notepad&quot;;<br/>                 printf(&quot;test 4 \n&quot;);<br/>             /*for(k=0; k&lt;APPL_MAX_ARGS; k++)<br/>             {<br/>                 myargv[k] = (wchar_t *)NULL;<br/>             } */<br/> <br/>              // Start the child process. <br/>             if(( cpid=CreateProcess( NULL,   // No module name (use command line)<br/>                 (LPWSTR)exeName,        // Command line<br/>                 NULL,           // Process handle not inheritable<br/>                 NULL,           // Thread handle not inheritable<br/>                 FALSE,          // Set handle inheritance to FALSE<br/>                 0,              // No creation flags<br/>                 NULL,           // Use parent's environment block<br/>                 NULL,           // Use parent's starting directory <br/>                 &amp;si,            // Pointer to STARTUPINFO structure<br/>                 &amp;pi )           // Pointer to PROCESS_INFORMATION structure<br/>             ) != NULL)<br/>             {<br/>                 <br/>                 pid = pi.dwProcessId;<br/>                 printf( &quot;VMService: CreateProcess Successed for cmdStartServer, CPID is: %d.\n&quot;, cpid );<br/>                 printf(&quot;System process ID: %d \n&quot;, pid);<br/>                 eindex = atoi(event_index);<br/>                 addNode(pid, eindex, aSock);    <br/>                 //closesocket(aSock);    /* No need to close the socket. */<br/>                 //return 0;<br/>             }<br/>             else<br/>             {<br/>                  printf( &quot;VMService: CreateProcess failed (%d).\n&quot;, GetLastError() );<br/>                 //return -1;<br/>             }<br/> <br/>             /* Wait until child process exits. */<br/>             // WaitForSingleObject( pi.hProcess, INFINITE );<br/> <br/>             /* Close process and thread handles.  */<br/>             CloseHandle( pi.hProcess );<br/>             CloseHandle( pi.hThread );<br/>              continue;<br/>     }<br/>     else<br/>     {<br/>         printf(&quot;cmdStartApllication failed. \n&quot;);<br/>         //continue;<br/>     }<br/> <br/> continue;<br/>     <br/>     printf(&quot;while end \n&quot;);<br/>     }  // end of while()<br/> <br/> [\code]<br/> <br/> <br/> so any suggestion on getting child process termination indication without wait time ( that hangs the parent process.<br/> <br/> <br/> thank you.<br/> <br/> <br/> <br/> <br/> <br/> <br/>Sun, 15 Nov 2009 11:57:40 Z2009-11-27T15:29:27Zhttp://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/b09a27b7-7fa2-4b1b-ba89-c82af42d64e0http://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/b09a27b7-7fa2-4b1b-ba89-c82af42d64e0kapil rajakhttp://social.msdn.microsoft.com/Profile/zh-CN/?user=kapil%20rajakbuild failed<p>I am building my project at the end of build process, it shows:<br/><br/>========== Build: 122 succeeded, 1 failed, 0 up-to-date, 14 skipped ==========<br/><br/>there are  3 errors showing on the output of Debug Panel.<br/><br/>This three erors I can identify.<br/><br/>55&gt;Error: C:\Documents and Settings\guest1\Desktop\svn ref\libs\sounds\freeswitch-sounds-en-us-callie-8000-.tar.gz is not supported archive<br/>58&gt;Project : error PRJ0019: A tool returned an error code from &quot;Performing Post-Build Event...&quot;<br/>58&gt;8khz - 1 error(s), 0 warning(s)</p>Fri, 27 Nov 2009 11:13:17 Z2009-11-27T15:19:24Zhttp://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/9d925573-6a6a-48c7-9ea2-2d8a639231echttp://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/9d925573-6a6a-48c7-9ea2-2d8a639231eccpzaohttp://social.msdn.microsoft.com/Profile/zh-CN/?user=cpzaoSerial Port, events and timeoutsHello,<br/> <br/> I have been developping an application which will connect to a device using RS232.<br/> <br/> When the device sends a request, my application must respond (client/server).<br/> <br/> Initially, I had a thread which was always waiting for characters to appear. If they did not appear within the timeout, I flagged an error variable. As the client sends messages periodically, I could identify when the connection was lost. This was possible, because I was always waiting for characters to arrive.<br/> <br/> After reading some stuff and talking with some colleagues, I was advised to drop the thread and use events instead. When a message arrives, the event is raised and executes eveything I need, which is pretty nice, leaving all the threading stuff behind. But now, there's one thing I cannot do, which is to identify when the connection is lost.<br/> <br/> As I do not have a thread waiting for characters anymore, I cannot detect a timeout situation and I think I would need to create a thread just to do identify an excessive amount of time between ReadEvents detected. Am I right?<br/> <br/> Is there any other way how to do this?<br/> <br/> Best regards<br/> <br/> CarlosFri, 27 Nov 2009 13:14:47 Z2009-11-27T15:07:50Zhttp://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/043fbd38-30fc-4bd5-99e3-592862430515http://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/043fbd38-30fc-4bd5-99e3-592862430515MichaelWojcikhttp://social.msdn.microsoft.com/Profile/zh-CN/?user=MichaelWojcikOnInitialUpdate IssueHello<br/> <br/>   I been having a problem that is simple, but is a blocking issue.  When I make a MFC/C++ application, OnInitialUpdate calls for a while but randomly stops working after a few minutes to hours of development.<br/> <br/> The entry function where the problem occurs is in the *app class<br/> <br/> <span style="font-size:x-small"><br/> <span style="font-size:x-small"><span style="font-size:x-small"> </span> </span> <p><span style="color:#008000;font-size:x-small"><span style="color:#008000;font-size:x-small"> <pre>// Dispatch commands specified on the command line. Will return FALSE if<br/> // app was launched with /RegServer, /Register, /Unregserver or /Unregister.<br/> if (!ProcessShellCommand(cmdInfo))<br/> return FALSE;</pre> <span style="font-size:x-small"><span style="color:#008000;font-size:x-small"><span style="color:#008000;font-size:x-small"> </span> </span> </span> </span> </span></p> </span> <span style="font-size:x-small"> <pre>This began happening ever since I've been using VS2008. At first I had the trial version but I uninstalled it and installed my full edition but unfortunatly, the issue still persists. I am running this on an XP. I have tried this on my Windows7 Beta and it seems to behave properly. But are there any users who can make a MFC application with VS2008 on XP and not experience this issue? Any advice and ideas are more than welcomed as well. Help is Greatly appreciated. Thanks</pre> <br/> </span>Tue, 24 Nov 2009 10:29:11 Z2009-11-27T15:07:30Zhttp://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/26738f2a-5283-448f-a473-0492c6b22df6http://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/26738f2a-5283-448f-a473-0492c6b22df6Rahul Dhamechahttp://social.msdn.microsoft.com/Profile/zh-CN/?user=Rahul%20DhamechaDebug Assertion Failure in CTreeCtrlhi,<br/> I have a dialog(variable name is b1) in which I have created a TreeCtrl(m_bandtree) using the toolbox. I have also created a variable for the same using the class wizard. On a particular condition in my Dialog Based applicatoin this Dialog(b1) is opened. Now, I want to add 4 Tree Items into its TreeCtrl structure. I am unable to do the same. Please help me out.<br/> This is the code snippet.<br/> <br/> if(condition)<br/>   MultiBank *b1=new MultiBank;<br/> for(int i=0;i&lt;4;i++)<br/> <br/>         {<br/>            // AfxMessageBox(&quot;Hi&quot;);<br/>             band_tree_name=&quot;Band&quot;+i;<br/>             tvInsert.hParent=NULL;<br/>             tvInsert.hInsertAfter=TVI_LAST;<br/>             tvInsert.item.hItem=NULL;<br/>             tvInsert.item.iImage=0;<br/>             tvInsert.item.pszText=const_cast&lt;char*&gt;(band_tree_name.operator LPCTSTR());<br/>             b1-&gt;m_bandtree.InsertItem(&amp;tvInsert);//line where I am getting Debug Assertion Failed Error<br/> <br/>         } <br/> <br/> I have also referred to &quot;http://social.msdn.microsoft.com/forums/en-US/vcgeneral/thread/fdf5b6ba-5d0d-4cb3-a924-5cdc917ee895/&quot; but it has been of any help to me.<br/> <br/> Pls AdviceFri, 27 Nov 2009 12:10:12 Z2009-11-27T14:41:42Zhttp://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/73f1613b-fbff-48ea-a4d5-8423535d4fd8http://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/73f1613b-fbff-48ea-a4d5-8423535d4fd8pacheslehttp://social.msdn.microsoft.com/Profile/zh-CN/?user=pachesleurldownloadtofile hangs in Vista but not in XP when internet connection is downHi,<br/>I'm using URLDownloadToFile to download an upgrade for an application inside that application.<br/>I'm using IBindStatusCallback to get status updates with the OnProgress method.<br/>When the internet connection is lost, I warn the user and tell her to try it later.<br/>However, this works in XP but in Vista, it does not.<br/>In Vista, if you remove the ethernet cable, URLDownloadToFile seems to hang, does not return, and OnProgress is not called.<br/>Sometimes if you reconnect the cable, it can take up the download where it was left off, although this does not happen always.<br/>It seems in Windows 7, it is working properly. After you remove the cable, the URLDownloadToFile seems to hang,  but when you<br/>put it back on, OnProgress knows that binding has stopped. Is there a bug with URLDownloadToFile in Vista?<br/>This is also reported here:<br/><a href="http://msdn.microsoft.com/en-us/library/ms775123(VS.85).aspx">http://msdn.microsoft.com/en-us/library/ms775123(VS.85).aspx</a><br/>(a comment by a user: <div>Seems to hang when used under Vista and network connection is lost</div> <span><span style="color:#c0c0c0">Added by:</span></span><span><span style="color:#2178e0">BarnyJuno)<br/>Thanks and regards,<br/><br/>pau</span></span>Fri, 27 Nov 2009 13:34:42 Z2009-11-27T13:34:43Z