锘??xml version="1.0" encoding="utf-8" standalone="yes"?>国产精品一区免费观看,亚洲成人在线网,欧美日韩国产精品http://www.shnenglu.com/jacky2019/榪欎釜kisser涓嶅お鍐?/description>zh-cnMon, 15 Sep 2025 16:29:59 GMTMon, 15 Sep 2025 16:29:59 GMT60dxtrans.h missing in Microsoft DirectX SDK (November 2007)http://www.shnenglu.com/jacky2019/archive/2010/04/08/111974.htmlkkkkThu, 08 Apr 2010 08:31:00 GMThttp://www.shnenglu.com/jacky2019/archive/2010/04/08/111974.htmlhttp://www.shnenglu.com/jacky2019/comments/111974.htmlhttp://www.shnenglu.com/jacky2019/archive/2010/04/08/111974.html#Feedback0http://www.shnenglu.com/jacky2019/comments/commentRss/111974.htmlhttp://www.shnenglu.com/jacky2019/services/trackbacks/111974.html瑙e喅鍔炴硶錛堟潵鑷?http://social.msdn.microsoft.com/forums/en-US/windowssdk/thread/ed097d2c-3d68-4f48-8448-277eaaf68252/錛?br>
1.浣跨敤 August 2007 DirectX SDK.

2. 縐婚櫎鎵鏈夊拰dxtrans.h鏈夊叧鐨?br>
Remove anything to do with "dxtrans.h" and "IDXEffect" .

Say, for file "qedit.h"

//#include "dxtrans.h" -- Line 498 

// IDxtCompositor //: public IDXEffect -- Line 837
// IDxtAlphaSetter //: public IDXEffect -- Line 1151
// IDxtJpeg //: public IDXEffect -- Line 1345
// IDxtKey //: public IDXEffect -- Line 1735






kk 2010-04-08 16:31 鍙戣〃璇勮
]]>
c++ volatile鍏抽敭瀛?/title><link>http://www.shnenglu.com/jacky2019/archive/2010/04/01/111249.html</link><dc:creator>kk</dc:creator><author>kk</author><pubDate>Thu, 01 Apr 2010 02:54:00 GMT</pubDate><guid>http://www.shnenglu.com/jacky2019/archive/2010/04/01/111249.html</guid><wfw:comment>http://www.shnenglu.com/jacky2019/comments/111249.html</wfw:comment><comments>http://www.shnenglu.com/jacky2019/archive/2010/04/01/111249.html#Feedback</comments><slash:comments>7</slash:comments><wfw:commentRss>http://www.shnenglu.com/jacky2019/comments/commentRss/111249.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/jacky2019/services/trackbacks/111249.html</trackback:ping><description><![CDATA[<span style="WIDOWS: 2; TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: medium Simsun; WHITE-SPACE: normal; ORPHANS: 2; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" class=Apple-style-span>c++涓殑volatile鍏抽敭瀛椾竴鐩存病鏈変嬌鐢ㄨ繃銆傛渶榪戜嬌鐢ㄤ簡涓涓嬨傝鍏抽敭瀛楃殑鎰忔濆氨鏄憡璇夌紪璇戝櫒涓嶈瀵硅鍙橀噺榪涜浼樺寲錛屼嬌鐢ㄥ湴鍧瀵硅鍙橀噺榪涜鍙栧艱屼笉瑕佺洿鎺ヤ嬌鐢ㄨ鍙橀噺宸茬粡瀛樺湪cach/瀵勫瓨鍣ㄤ腑鐨勫箋?br><br>嫻嬭瘯浠g爜濡備笅錛?br> <div style="BORDER-BOTTOM: #cccccc 1px solid; BORDER-LEFT: #cccccc 1px solid; PADDING-BOTTOM: 4px; BACKGROUND-COLOR: #eeeeee; PADDING-LEFT: 4px; WIDTH: 98%; PADDING-RIGHT: 5px; FONT-SIZE: 13px; WORD-BREAK: break-all; BORDER-TOP: #cccccc 1px solid; BORDER-RIGHT: #cccccc 1px solid; PADDING-TOP: 4px"><span style="COLOR: #008080"> 1</span><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif"><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> volatile.cpp : Defines the entry point for the console application.<br></span><span style="COLOR: #008080"> 2</span><span style="COLOR: #008000"><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif"></span><span style="COLOR: #008000">//<br></span><span style="COLOR: #008080"> 3</span><span style="COLOR: #008000"><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif"></span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080"> 4</span><span style="COLOR: #000000"><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif">#include </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">stdafx.h</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080"> 5</span><span style="COLOR: #000000"><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif"><br></span><span style="COLOR: #008080"> 6</span><span style="COLOR: #000000"><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif"><br></span><span style="COLOR: #008080"> 7</span><span style="COLOR: #000000"><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif"></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> _tmain(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> argc, _TCHAR</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000"> argv[])<br></span><span style="COLOR: #008080"> 8</span><span style="COLOR: #000000"><img id=Codehighlighter1_134_292_Open_Image onclick="this.style.display='none'; Codehighlighter1_134_292_Open_Text.style.display='none'; Codehighlighter1_134_292_Closed_Image.style.display='inline'; Codehighlighter1_134_292_Closed_Text.style.display='inline';" align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockStart.gif"><img style="DISPLAY: none" id=Codehighlighter1_134_292_Closed_Image onclick="this.style.display='none'; Codehighlighter1_134_292_Closed_Text.style.display='none'; Codehighlighter1_134_292_Open_Image.style.display='inline'; Codehighlighter1_134_292_Open_Text.style.display='inline';" align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedBlock.gif"></span><span style="BORDER-BOTTOM: #808080 1px solid; BORDER-LEFT: #808080 1px solid; BACKGROUND-COLOR: #ffffff; DISPLAY: none; BORDER-TOP: #808080 1px solid; BORDER-RIGHT: #808080 1px solid" id=Codehighlighter1_134_292_Closed_Text><img src="http://www.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_134_292_Open_Text><span style="COLOR: #000000">{<br></span><span style="COLOR: #008080"> 9</span><span style="COLOR: #000000"><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">volatile int a = 1;</span><span style="COLOR: #008000"><br></span><span style="COLOR: #008080">10</span><span style="COLOR: #008000"><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif"></span><span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> a </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">;<br></span><span style="COLOR: #008080">11</span><span style="COLOR: #000000"><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    printf (</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">a = %d\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">, a);<br></span><span style="COLOR: #008080">12</span><span style="COLOR: #000000"><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif"><br></span><span style="COLOR: #008080">13</span><span style="COLOR: #000000"><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    __asm<br></span><span style="COLOR: #008080">14</span><span style="COLOR: #000000"><img id=Codehighlighter1_206_238_Open_Image onclick="this.style.display='none'; Codehighlighter1_206_238_Open_Text.style.display='none'; Codehighlighter1_206_238_Closed_Image.style.display='inline'; Codehighlighter1_206_238_Closed_Text.style.display='inline';" align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="DISPLAY: none" id=Codehighlighter1_206_238_Closed_Image onclick="this.style.display='none'; Codehighlighter1_206_238_Closed_Text.style.display='none'; Codehighlighter1_206_238_Open_Image.style.display='inline'; Codehighlighter1_206_238_Open_Text.style.display='inline';" align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedSubBlock.gif">    </span><span style="BORDER-BOTTOM: #808080 1px solid; BORDER-LEFT: #808080 1px solid; BACKGROUND-COLOR: #ffffff; DISPLAY: none; BORDER-TOP: #808080 1px solid; BORDER-RIGHT: #808080 1px solid" id=Codehighlighter1_206_238_Closed_Text><img src="http://www.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_206_238_Open_Text><span style="COLOR: #000000">{<br></span><span style="COLOR: #008080">15</span><span style="COLOR: #000000"><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">        mov DWORD ptr [ebp</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">4</span><span style="COLOR: #000000">], 10h // 淇敼a鐨勫間負0x10<br></span><span style="COLOR: #008080">16</span><span style="COLOR: #000000"><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif">    }</span></span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">17</span><span style="COLOR: #000000"><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif"><br></span><span style="COLOR: #008080">18</span><span style="COLOR: #000000"><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    printf (</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">a = %d\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">, a);<br></span><span style="COLOR: #008080">19</span><span style="COLOR: #000000"><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif"><br></span><span style="COLOR: #008080">20</span><span style="COLOR: #000000"><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    getchar();<br></span><span style="COLOR: #008080">21</span><span style="COLOR: #000000"><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif"><br></span><span style="COLOR: #008080">22</span><span style="COLOR: #000000"><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br></span><span style="COLOR: #008080">23</span><span style="COLOR: #000000"><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockEnd.gif">}</span></span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">24</span><span style="COLOR: #000000"><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif"><br></span><span style="COLOR: #008080">25</span><span style="COLOR: #000000"><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif"></span></div> </span><br>濡傛灉緙栬瘧鍣ㄦ病鏈変紭鍖栫殑璇濓紝鎵撳嵃鍑烘潵鐨勫煎簲璇ユ槸1鍜?6銆傚弽涔嬶紝濡傛灉娌℃湁浣跨敤volatile錛屼紭鍖栦箣鍚庡簲璇ユ墦鍗板嚭鏉ョ殑鏄?鍜?<br><br>鎴戝湪vc6鍜寁c2008涓嬫祴璇曚簡涓涓嬶細<br>-----------------------------------------------------------------------------------------<br><br>vc2008<br>-----------------------------------------------------------------------------------------<br>娌℃湁鍏抽敭瀛梫olatile<br>debug涓嬫墦鍗扮殑鏄?1 鍜?1 ---涓轟粈涔堜細琚紭鍖栦簡鍛紵鎴戠殑浼樺寲緙栬瘧閫夐」鏄痙isabled鐨?br>release涓嬫墦鍗扮殑鏄?1 鍜?1<br>鏈夊叧閿瓧volatile<br><font face=瀹嬩綋>debug涓嬫墦鍗扮殑鏄?1 鍜?1 --- 寰堝鎬紒<br>release涓嬫墦鍗扮殑鏄?1 鍜?16<br><br>鎴戞兂鍙兘鏄紪璇戝櫒瀵筪ebug涓嬩綔浜嗙壒孌婂鐞嗐傝屼笖璇ョ▼搴忛潪甯哥畝鍗?/font><br><br>vc6.0<br><font face=瀹嬩綋>-----------------------------------------------------------------------------------------<br>娌℃湁鍏抽敭瀛梫olatile<br><font face=瀹嬩綋>debug涓嬫墦鍗扮殑鏄?1 鍜?16<br>release涓嬫墦鍗扮殑鏄?1 鍜?1</font><br>鏈夊叧閿瓧volatile<br><font face=瀹嬩綋>debug涓嬫墦鍗扮殑鏄?1 鍜?16<br>release涓嬫墦鍗扮殑鏄?1 鍜?1 --- 寰堝鎬紒<br><br><br>灝忕粨錛?br>鍦ㄥ綰跨▼澶氭牳鐨勬儏鍐典笅錛岃闃叉琚紪璇戝櫒浼樺寲錛?/font></font> <img src ="http://www.shnenglu.com/jacky2019/aggbug/111249.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/jacky2019/" target="_blank">kk</a> 2010-04-01 10:54 <a href="http://www.shnenglu.com/jacky2019/archive/2010/04/01/111249.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>鐜艦緙撳啿http://www.shnenglu.com/jacky2019/archive/2010/04/01/111243.htmlkkkkThu, 01 Apr 2010 01:17:00 GMThttp://www.shnenglu.com/jacky2019/archive/2010/04/01/111243.htmlhttp://www.shnenglu.com/jacky2019/comments/111243.htmlhttp://www.shnenglu.com/jacky2019/archive/2010/04/01/111243.html#Feedback0http://www.shnenglu.com/jacky2019/comments/commentRss/111243.htmlhttp://www.shnenglu.com/jacky2019/services/trackbacks/111243.html鐜艦緙撳啿鏄彲浠ヤ笉鐢ㄥ姞閿佺殑銆備笅闈㈡槸涓涓疄鐜扮殑鐜艦緙撳啿銆備嬌鐢╟瀹炵幇錛屽彲鑳戒細鍑虹幇write婊℃儏鍐碉紝榪欑鎯呭喌瀵艱嚧鐨勭粨鏋滃氨鏄痺rite涓嶆垚鍔燂紝鏁版嵁娌″啓榪涘幓銆?/pre>
鎴戣繖閲屽彧鏄畝鍗曠殑涓簡銆?/pre>
  1 //
  2 
  3 #include "stdafx.h"
  4 #include <windows.h>
  5 #include <time.h>
  6 #include <stdlib.h>
  7 
  8 #define MAX_BUF_LEN 20        // buf len // 蹇呴』瑕佸ぇ浜?
  9 int nRead = 0;                // read pos
 10 int nWrite = 0;                // write pos
 11 int buf[MAX_BUF_LEN] = {0}; // loop buf
 12 
 13 #define NN 20000
 14 __int64 sum = 0;
 15 __int64 lose = 0;
 16 __int64 total = (__int64)(1+NN)*(__int64)NN/2;
 17 bool bWriteFinished = false;
 18 
 19 void WriteBuf(int n)
 20 {
 21     int rpos = nRead;
 22     int wpos = nWrite;
 23     wpos++;
 24     // buf婊★紙鍗硍rite鍙堣拷涓婁簡read錛? 娉ㄤ負浜嗛伩鍏嶄笌鍒濆鐘舵侀噸澶嶅垽鏂?br> 25     // 鎵浠ヨ繖閲屾渶鍚庝竴涓猙uf娌℃湁鍐欏氨璁や負宸茬粡婊′簡銆傛墍浠AX_BUF_LEN涓嶈兘涓?
 26     // 榪欓噷錛岀洿鎺ヤ涪寮冭buf
 27     if (wpos % MAX_BUF_LEN == rpos % MAX_BUF_LEN)
 28     {
 29         lose += n;
 30         return;
 31     }
 32 
 33     buf[nWrite] = n;
 34     nWrite++;
 35     if (nWrite == MAX_BUF_LEN)
 36         nWrite = 0;
 37 }
 38 
 39 int ReadBuf()
 40 {
 41     if (nWrite == nRead)
 42         return -1;
 43 
 44     int n = buf[nRead];
 45     nRead++;
 46     if (nRead == MAX_BUF_LEN)
 47         nRead = 0;
 48     return n;
 49 }
 50 
 51 DWORD WINAPI ReadThread(LPVOID lpParameter)
 52 {
 53     int tmp = 0;
 54     int count = 0;
 55     while (true)
 56     {
 57         //printf("ReadThread = %d\n", ReadBuf());
 58         tmp = ReadBuf();
 59         if (-1 != tmp)
 60         {
 61             count++;
 62             sum += tmp;
 63             if (count == NN)
 64             {
 65                 printf ("ReadThread finished!\n");
 66                 break;
 67             }
 68         }
 69         else if (bWriteFinished)
 70         {
 71             printf ("ReadThread finished222!\n");
 72             break;
 73         }
 74 
 75         Sleep(rand() % 10);
 76     }
 77     return 0;
 78 }
 79 
 80 DWORD WINAPI WriteThread(LPVOID lpParameter)
 81 {
 82     int n = 0;
 83     while (true)
 84     {
 85         n++;
 86         WriteBuf(n);
 87         if (n == NN)
 88         {
 89             printf ("WriteThread finished!\n");
 90             bWriteFinished = true;
 91             break;
 92         }
 93 
 94         Sleep(rand() % 10);
 95     }
 96     return 0;
 97 }
 98 
 99 int main(int argc, char* argv[])
100 {
101     srand(time(NULL));
102 //     for (int i = 0; i < 10; i++)
103 //     {
104 //         printf ("rand = %d\n", rand() % 10);
105 //     }
106 
107     DWORD threadid[2= {0};
108     HANDLE hThread[2= {0};
109     int param = 0;
110     hThread[0= CreateThread(NULL, 0, ReadThread, &param, CREATE_SUSPENDED, &threadid[0]);
111     ResumeThread(hThread[0]);
112     hThread[1= CreateThread(NULL, 0, WriteThread, &param, CREATE_SUSPENDED, &threadid[1]);
113     ResumeThread(hThread[1]);
114 
115     getchar();
116 
117     printf ("total = %lld\n", total);
118     printf ("lose = %lld\n", lose);
119     printf ("sum = %lld\n", sum);
120 
121     if (total == lose + sum)
122     {
123         printf ("loop buf works well!\n");
124     }
125     else
126     {
127         printf ("loop buf works wrong!\n");
128     }
129 
130     return 0;
131 }
132 
涓婇潰鏄姞浜嗘祴璇曚唬鐮佺殑錛屾垜嫻嬭瘯浜嗕竴涓嬩技涔庢病闂銆?/pre>
娉ㄦ剰錛氳繖閲屽彧鍏佽涓涓嚎紼嬭錛屼竴涓嚎紼嬪啓銆傚鏋滄槸澶氫釜綰跨▼璇誨啓鐨勮瘽錛岄渶瑕侀攣錛?/pre>
鍙﹀錛屽緢澶氱粏鑺傞兘娌¤冭檻榪涘幓


kk 2010-04-01 09:17 鍙戣〃璇勮
]]>浜虹敓鏈楂樺鐣?/title><link>http://www.shnenglu.com/jacky2019/archive/2008/12/19/69790.html</link><dc:creator>kk</dc:creator><author>kk</author><pubDate>Fri, 19 Dec 2008 00:07:00 GMT</pubDate><guid>http://www.shnenglu.com/jacky2019/archive/2008/12/19/69790.html</guid><wfw:comment>http://www.shnenglu.com/jacky2019/comments/69790.html</wfw:comment><comments>http://www.shnenglu.com/jacky2019/archive/2008/12/19/69790.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/jacky2019/comments/commentRss/69790.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/jacky2019/services/trackbacks/69790.html</trackback:ping><description><![CDATA[浜虹敓鏈楂樺鐣岋細<br>銆銆銆銆鎷挎矙鐗瑰伐璧勶紝浣忚嫳鍥芥埧瀛愶紝鐢ㄧ憺鍏告墜鏈猴紝鎴寸憺澹墜琛紝濞墮煩鍥藉コ浜猴紝鍖呮棩鏈簩濂訛紝鍋氭嘲鍥芥寜鎽╋紝寮寰峰浗杞胯濺錛屽潗緹庡浗椋炴満錛屽枬娉曞浗綰㈤厭錛屽悆婢蟲床嫻烽矞錛屾娊鍙ゅ反闆寗錛岀┛鎰忓ぇ鍒╃毊闉嬶紝鐜╄タ鐝墮濂抽儙錛岀湅濂ュ湴鍒╂瓕鍓э紝涔頒縿緗楁柉鍒錛岄泧鑿插緥瀹懼コ浣o紝閰嶄互鑹插垪淇濋晼錛屾礂鍦熻沖叾妗戞嬁錛屽綋涓浗騫查儴.<br> <img src ="http://www.shnenglu.com/jacky2019/aggbug/69790.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/jacky2019/" target="_blank">kk</a> 2008-12-19 08:07 <a href="http://www.shnenglu.com/jacky2019/archive/2008/12/19/69790.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>瀛樺偍榪囩▼ stored procedurehttp://www.shnenglu.com/jacky2019/archive/2007/11/06/35937.htmlkkkkTue, 06 Nov 2007 02:37:00 GMThttp://www.shnenglu.com/jacky2019/archive/2007/11/06/35937.htmlhttp://www.shnenglu.com/jacky2019/comments/35937.htmlhttp://www.shnenglu.com/jacky2019/archive/2007/11/06/35937.html#Feedback0http://www.shnenglu.com/jacky2019/comments/commentRss/35937.htmlhttp://www.shnenglu.com/jacky2019/services/trackbacks/35937.html 

瀹氫箟錛?br>        灝嗗父鐢ㄧ殑鎴栧緢澶嶆潅鐨勫伐浣滐紝棰勫厛鐢⊿QL璇彞鍐欏ソ騫剁敤涓涓寚瀹氱殑鍚嶇О瀛樺偍璧鋒潵,   閭d箞浠ュ悗瑕佸彨鏁版嵁搴?/font>鎻愪緵涓庡凡瀹氫箟濂界殑瀛樺偍榪囩▼鐨勫姛鑳界浉鍚岀殑鏈嶅姟鏃?鍙渶璋冪敤execute,鍗沖彲鑷姩瀹屾垚鍛戒護銆?br>        璁插埌榪欓噷,鍙兘鏈変漢瑕侀棶錛氳繖涔堣瀛樺偍榪囩▼灝辨槸涓鍫哠QL璇彞鑰屽凡鍟婏紵
        Microsoft鍏徃涓轟粈涔堣繕瑕佹坊鍔犺繖涓妧鏈憿?
        閭d箞瀛樺偍榪囩▼涓庝竴鑸殑SQL璇彞鏈変粈涔堝尯鍒憿?

        瀛樺偍榪囩▼鐨勪紭鐐癸細
          1.瀛樺偍榪囩▼鍙湪鍒涢犳椂榪涜緙栬瘧錛屼互鍚庢瘡嬈℃墽琛屽瓨鍌ㄨ繃紼嬮兘涓嶉渶鍐嶉噸鏂扮紪璇戯紝鑰屼竴鑸琒QL璇彞姣忔墽琛屼竴嬈″氨緙栬瘧涓嬈?鎵浠ヤ嬌鐢ㄥ瓨鍌ㄨ繃紼嬪彲鎻愰珮鏁版嵁搴撴墽琛岄熷害銆?br>          2.褰撳鏁版嵁搴撹繘琛屽鏉傛搷浣滄椂(濡傚澶氫釜琛ㄨ繘琛孶pdate,Insert,Query,Delete鏃訛級錛屽彲灝嗘澶嶆潅鎿嶄綔鐢ㄥ瓨鍌ㄨ繃紼嬪皝瑁呰搗鏉ヤ笌鏁版嵁搴撴彁渚涚殑浜嬪姟澶勭悊緇撳悎涓璧蜂嬌鐢ㄣ?br>          3.瀛樺偍榪囩▼鍙互閲嶅浣跨敤,鍙噺灝戞暟鎹簱寮鍙戜漢鍛樼殑宸ヤ綔閲?br>          4.瀹夊叏鎬ч珮,鍙瀹氬彧鏈夋煇姝ょ敤鎴鋒墠鍏鋒湁瀵規寚瀹氬瓨鍌ㄨ繃紼嬬殑浣跨敤鏉?br>        瀛樺偍榪囩▼鐨勭綾伙細
          1.緋葷粺瀛樺偍榪囩▼錛氫互sp_寮澶?鐢ㄦ潵榪涜緋葷粺鐨勫悇欏硅瀹?鍙栧緱淇℃伅.鐩稿叧綆$悊宸ヤ綔,
          濡?nbsp;  sp_help灝辨槸鍙栧緱鎸囧畾瀵硅薄鐨勭浉鍏充俊鎭?br>          2.鎵╁睍瀛樺偍榪囩▼   浠P_寮澶?鐢ㄦ潵璋冪敤鎿嶄綔緋葷粺鎻愪緵鐨勫姛鑳?br>          exec   master..xp_cmdshell   'ping   10.8.16.1'
          3.鐢ㄦ埛鑷畾涔夌殑瀛樺偍榪囩▼,榪欐槸鎴戜滑鎵鎸囩殑瀛樺偍榪囩▼
          甯哥敤鏍煎紡
          Create   procedure   procedue_name
          [@parameter   data_type][output]
          [with]{recompile|encryption}
          as
          sql_statement
        瑙i噴:  
        output錛氳〃紺烘鍙傛暟鏄彲浼犲洖鐨?br>        with   {recompile|encryption}
        recompile:琛ㄧず姣忔鎵ц姝ゅ瓨鍌ㄨ繃紼嬫椂閮介噸鏂扮紪璇戜竴嬈?br>        encryption:鎵鍒涘緩鐨勫瓨鍌ㄨ繃紼嬬殑鍐呭浼氳鍔犲瘑
        濡?
          琛╞ook鐨勫唴瀹瑰涓?br>          緙栧彿   涔﹀悕   浠鋒牸
          001   C璇█鍏ラ棬   $30
          002   PowerBuilder鎶ヨ〃寮鍙?nbsp;  $52
          瀹炰緥1:鏌ヨ琛˙ook鐨勫唴瀹圭殑瀛樺偍榪囩▼
          create   proc   query_book
          as  
          select   *   from   book
          go
          exec   query_book
          瀹炰緥2:鍔犲叆涓絎旇褰曞埌琛╞ook,騫舵煡璇㈡琛ㄤ腑鎵鏈変功綾嶇殑鎬婚噾棰?br>          Create   proc   insert_book
          @param1   char(10),@param2   varchar(20),@param3   money,@param4   money   output
          with   encryption   ---------鍔犲瘑
          as
          insert   book(緙栧彿,涔﹀悕錛屼環鏍鹼級   Values(@param1,@param2,@param3)
          select   @param4=sum(浠鋒牸)   from   book
          go
          鎵ц渚嬪瓙:  
          declare   @total_price   money  
          exec   insert_book   '003','Delphi   鎺т歡寮鍙戞寚鍗?,$100,@total_price
          print   '鎬婚噾棰濅負'+convert(varchar,@total_price)
          go
       
瀛樺偍榪囩▼鐨?縐嶄紶鍥炲?
          1.浠eturn浼犲洖鏁存暟
          2.浠utput鏍煎紡浼犲洖鍙傛暟
          3.Recordset
        浼犲洖鍊肩殑鍖哄埆:
          output鍜宺eturn閮藉彲鍦ㄦ壒嬈$▼寮忎腑鐢ㄥ彉閲忔帴鏀?鑰宺ecordset鍒欎紶鍥炲埌鎵ц鎵規鐨勫鎴風涓?nbsp; 
        瀹炰緥3錛氳鏈変袱涓〃涓篜roduct,Order,鍏惰〃鍐呭濡備笅錛?br>          Product
          浜у搧緙栧彿   浜у搧鍚嶇О   瀹㈡埛璁㈡暟  
          001   閽㈢瑪   30  
          002   姣涚瑪   50  
          003   閾呯瑪   100  
          Order  
          浜у搧緙栧彿   瀹㈡埛鍚?nbsp;  瀹㈡埛璁㈤噾
          001   鍗楀北鍖?nbsp;  $30
          002   緗楁箹鍖?nbsp;  $50
          003   瀹濆畨鍖?nbsp;  $4
        璇峰疄鐜版寜緙栧彿涓鴻繛鎺ユ潯浠?灝嗕袱涓〃榪炴帴鎴愪竴涓復鏃惰〃,璇ヨ〃鍙惈緙栧彿.浜у搧鍚?瀹㈡埛鍚?璁㈤噾.鎬婚噾棰?
        鎬婚噾棰?璁㈤噾*璁㈡暟,涓存椂琛ㄦ斁鍦ㄥ瓨鍌ㄨ繃紼嬩腑
        浠g爜濡備笅:
          Create   proc   temp_sale
          as
          select   a.浜у搧緙栧彿,a.浜у搧鍚嶇О,b.瀹㈡埛鍚?b.瀹㈡埛璁㈤噾,a.瀹㈡埛璁㈡暟*   b.瀹㈡埛璁㈤噾   as鎬婚噾棰?br>          into   #temptable   from   Product   a   inner   join   Order   b   on   a.浜у搧緙栧彿=b.浜у搧緙栧彿
          if   @@error=0  
          print   'Good'
          else
          print   'Fail'
          go

--------------------------------------------------------------------------------------------------------------------

瀛樺偍榪囩▼浠嬬粛  

涓銆佸厛浠嬬粛涓涓嬩粈涔堟槸瀛樺偍榪囩▼  
瀛樺偍榪囩▼鏄埄鐢⊿QL   Server鎵鎻愪緵鐨凾ranact-SQL璇█鎵緙栧啓鐨勭▼搴忋俆ranact-SQL璇█鏄疭QL   Server鎻愪緵涓撲負璁捐鏁版嵁搴撳簲鐢ㄧ▼搴忕殑璇█錛屽畠鏄簲鐢ㄧ▼搴忓拰SQL   Server鏁版嵁搴撻棿鐨勪富瑕佺▼搴忓紡璁捐鐣岄潰銆傚畠濂芥瘮Oracle鏁版嵁搴撶郴緇熶腑鐨凱ro-SQL鍜孖nformix鐨勬暟鎹簱緋葷粺鑳藉涓殑Informix-4GL璇█涓鏍楓傝繖綾昏璦涓昏鎻愪緵浠ヤ笅鍔熻兘錛岃鐢ㄦ埛鍙互璁捐鍑虹鍚堝紩鐢ㄩ渶姹傜殑紼嬪簭錛?nbsp; 
1)銆佸彉閲忚鏄?nbsp; 
2)銆丄NSI鍏煎鐨凷QL鍛戒護(濡係elect,Update….)  
3)銆佷竴鑸祦紼嬫帶鍒跺懡浠?if…else…銆亀hile….)  
4)銆佸唴閮ㄥ嚱鏁?nbsp; 

浜屻佸瓨鍌ㄨ繃紼嬬殑涔﹀啓鏍煎紡  

CREATE   PROCEDURE   [鎷ユ湁鑰?]瀛樺偍榪囩▼鍚峓;紼嬪簭緙栧彿]  
[(鍙傛暟#1,…鍙傛暟#1024)]  
[WITH  
{RECOMPILE   |   ENCRYPTION   |   RECOMPILE,   ENCRYPTION}  
]  
[FOR   REPLICATION]  
AS   紼嬪簭琛?nbsp; 

鍏朵腑瀛樺偍榪囩▼鍚嶄笉鑳借秴榪?28涓瓧銆傛瘡涓瓨鍌ㄨ繃紼嬩腑鏈澶氳瀹?024涓弬鏁?nbsp; 
(SQL   Server   7.0浠ヤ笂鐗堟湰),鍙傛暟鐨勪嬌鐢ㄦ柟娉曞涓?  

@鍙傛暟鍚?nbsp;  鏁版嵁綾誨瀷   [VARYING]   [=鍐呭畾鍊糫   [OUTPUT]  

姣忎釜鍙傛暟鍚嶅墠瑕佹湁涓涓?#8220;@”絎﹀彿,姣忎竴涓瓨鍌ㄨ繃紼嬬殑鍙傛暟浠呬負璇ョ▼搴忓唴閮ㄤ嬌鐢?鍙傛暟鐨勭被鍨嬮櫎浜咺MAGE澶栵紝鍏朵粬SQL   Server鎵鏀寔鐨勬暟鎹被鍨嬮兘鍙嬌鐢ㄣ?nbsp; 
[=鍐呭畾鍊糫鐩稿綋浜庢垜浠湪寤虹珛鏁版嵁搴撴椂璁懼畾涓涓瓧孌電殑榛樿鍊鹼紝榪欓噷鏄負榪欎釜鍙傛暟璁懼畾榛樿鍊箋俒OUTPUT]鏄敤鏉ユ寚瀹氳鍙傛暟鏄棦鏈夎緭鍏ュ張鏈夎緭鍑哄肩殑錛屼篃灝辨槸鍦ㄨ皟鐢ㄤ簡榪欎釜瀛樺偍榪囩▼鏃訛紝濡傛灉鎵鎸囧畾鐨勫弬鏁板兼槸鎴戜滑闇瑕佽緭鍏ョ殑鍙傛暟錛屽悓鏃朵篃闇瑕佸湪緇撴灉涓緭鍑虹殑錛屽垯璇ラ」蹇呴』涓篛UTPUT錛岃屽鏋滃彧鏄仛杈撳嚭鍙傛暟鐢紝鍙互鐢–URSOR錛屽悓鏃跺湪浣跨敤璇ュ弬鏁版椂錛屽繀欏繪寚瀹歏ARYING鍜孫UTPUT榪欎袱涓鍙ャ?nbsp; 

渚嬪瓙:  
CREATE   PROCEDURE   order_tot_amt   @o_id   int,@p_tot   int   output   AS  
SELECT   @p_tot   =   sum(Unitprice*Quantity)  
FROM   orderdetails  
WHERE   艒rdered=@o_id  

渚嬪瓙璇存槑:  
璇ヤ緥瀛愭槸寤虹珛涓涓畝鍗曠殑瀛樺偍榪囩▼order_tot_amt,榪欎釜瀛樺偍榪囩▼鏍規嵁鐢ㄦ埛杈撳叆鐨勫畾鍗旾D鍙風爜(@o_id),鐢卞畾鍗曟槑緇嗚〃(orderdetails)涓綆楄瀹氬崟閿鍞婚[鍗曚環(Unitprice)*鏁伴噺(Quantity)],榪欎竴閲戦閫氳繃@p_tot榪欎竴鍙傛暟杈撳嚭緇欒皟鐢ㄨ繖涓瀛樺偍榪囩▼鐨勭▼搴?nbsp; 

涓夈佸湪SQL   Server涓墽琛屽瓨鍌ㄨ繃紼?/strong>  

鍦⊿QL   Server鐨勬煡璇㈠垎鏋愬櫒涓紝杈撳叆浠ヤ笅浠g爜:  
declare   @tot_amt   int  
execute   order_tot_amt   1,@tot_amt   output  
select   @tot_amt  

浠ヤ笂浠g爜鏄墽琛宱rder_tot_amt榪欎竴瀛樺偍榪囩▼錛屼互璁$畻鍑哄畾鍗曠紪鍙蜂負1鐨勫畾鍗曢攢鍞噾棰濓紝鎴戜滑瀹氫箟@tot_amt涓鴻緭鍑哄弬鏁幫紝鐢ㄦ潵鎵挎帴鎴戜滑鎵瑕佺殑緇撴灉



kk 2007-11-06 10:37 鍙戣〃璇勮
]]>
姹夊瓧緙栫爜闂http://www.shnenglu.com/jacky2019/archive/2007/11/01/35693.htmlkkkkThu, 01 Nov 2007 06:53:00 GMThttp://www.shnenglu.com/jacky2019/archive/2007/11/01/35693.htmlhttp://www.shnenglu.com/jacky2019/comments/35693.htmlhttp://www.shnenglu.com/jacky2019/archive/2007/11/01/35693.html#Feedback0http://www.shnenglu.com/jacky2019/comments/commentRss/35693.htmlhttp://www.shnenglu.com/jacky2019/services/trackbacks/35693.htmlhttp://www.css8.cn/css8_document/gb2312.htm

鐢變簬甯稿父瑕佸拰姹夊瓧澶勭悊鎵撲氦閬擄紝鍥犳錛屾垜甯稿父鍙楀埌姹夊瓧緙栫爜闂鐨勫洶鎵般傚湪涓嶆柇鐨勬墦鍑諱笌鍧氭寔涓紝涔熺Н绱簡涓鐐規眽瀛楃紪鐮佹柟闈㈢殑緇忛獙錛屾兂鍜屽ぇ瀹朵竴璧峰垎浜?/font>

涓銆佹眽瀛楃紪鐮佺殑縐嶇被

    姹夊瓧緙栫爜涓幇鍦ㄤ富瑕佺敤鍒扮殑鏈変笁綾伙紝鍖呮嫭GBK錛?span lang=EN-US>GB2312鍜?span lang=EN-US>Big5銆?/span>

    1銆?span lang=EN-US>GB2312鍙堢О鍥芥爣鐮侊紝鐢卞浗瀹舵爣鍑嗘誨眬鍙戝竷錛?/span>1981騫?/span>5鏈?/span>1鏃ュ疄鏂斤紝閫氳浜庡ぇ闄嗐傛柊鍔犲潯絳夊湴涔熶嬌鐢ㄦ緙栫爜銆傚畠鏄竴涓畝鍖栧瓧鐨勭紪鐮佽鑼冿紝褰撶劧涔熷寘鎷叾浠栫殑絎﹀彿銆佸瓧姣嶃佹棩鏂囧亣鍚嶇瓑錛屽叡7445涓浘褰㈠瓧絎︼紝鍏朵腑姹夊瓧鍗?/span>6763涓傛垜浠鉤鏃惰6768涓眽瀛楋紝瀹為檯涓婇噷杈規湁5涓紪鐮佷負絀虹櫧錛屾墍浠ユ誨叡鏈?/span>6763涓眽瀛椼?/span>

      GB2312瑙勫畾“瀵逛換鎰忎竴涓浘褰㈠瓧絎﹂兘閲囩敤涓や釜瀛楄妭琛ㄧず錛屾瘡涓瓧鑺傚潎閲囩敤涓冧綅緙栫爜琛ㄧず”錛屼範鎯笂縐扮涓涓瓧鑺備負“楂樺瓧鑺?#8221;錛岀浜屼釜瀛楄妭涓?#8220;浣庡瓧鑺?#8221;銆?/span>GB2312涓眽瀛楃殑緙栫爜鑼冨洿涓猴紝絎竴瀛楄妭0xB0-0xF7(瀵瑰簲鍗佽繘鍒朵負176-247)錛岀浜屼釜瀛楄妭0xA0-0xFE錛堝搴斿崄榪涘埗涓?span lang=EN-US>160-254錛夈?/span>

    GB2312灝嗕唬鐮佽〃鍒嗕負94涓尯錛屽搴旂涓瀛楄妭錛?/span>0xa1-0xfe錛夛紱姣忎釜鍖?/span>94涓綅錛?/span>0xa1-0xfe錛夛紝瀵瑰簲絎簩瀛楄妭錛屼袱涓瓧鑺傜殑鍊煎垎鍒負鍖哄彿鍊煎拰浣嶅彿鍊煎姞32錛?/span>2OH錛夛紝鍥犳涔熺О涓哄尯浣嶇爜銆?/span>01-09鍖轟負絎﹀彿銆佹暟瀛楀尯錛?/span>16-87鍖轟負姹夊瓧鍖猴紙0xb0-0xf7錛夛紝10-15鍖恒?/span>88-94鍖烘槸鏈夊緟榪涗竴姝ユ爣鍑嗗寲鐨勭┖鐧藉尯銆?/span>

 

       2銆?/span>Big5鍙堢О澶т簲鐮侊紝涓昏涓洪娓笌鍙版咕浣跨敤錛屽嵆鏄竴涓箒浣撳瓧緙栫爜銆?/span>姣忎釜姹夊瓧鐢變袱涓瓧鑺傛瀯鎴愶紝絎竴涓瓧鑺傜殑鑼冨洿浠?/span>0X81錛?/span>0XFE錛堝嵆129-255錛夛紝鍏?/span>126縐嶃傜浜屼釜瀛楄妭鐨勮寖鍥翠笉榪炵畫錛屽垎鍒負0X40錛?/span>0X7E錛堝嵆64-126錛夛紝0XA1錛?/span>0XFE錛堝嵆161-254錛夛紝鍏?/span>157縐嶃?/span>

 

    3銆?span lang=EN-US>GBK鏄?span lang=EN-US>GB2312鐨勬墿灞曪紝鏄悜涓婂吋瀹圭殑錛屽洜姝?span lang=EN-US>GB2312涓殑姹夊瓧鐨勭紪鐮佷笌GBK涓眽瀛楃殑鐩稿悓銆傚彟澶栵紝GBK涓繕鍖呭惈綣佷綋瀛楃殑緙栫爜錛屽畠涓?span lang=EN-US>Big5緙栫爜涔嬮棿鐨勫叧緋繪垜榪樻病鏈夊紕鏄庣櫧錛屽ソ鍍忔槸涓嶄竴鑷寸殑銆?span lang=EN-US>GBK涓瘡涓眽瀛椾粛鐒跺寘鍚袱涓瓧鑺傦紝絎竴涓瓧鑺傜殑鑼冨洿鏄?span lang=EN-US>0x81-0xFE錛堝嵆129-254錛夛紝絎簩涓瓧鑺傜殑鑼冨洿鏄?span lang=EN-US>0x40-0xFE錛堝嵆64-254錛夈?span lang=EN-US>GBK涓湁鐮佷綅23940涓紝鍖呭惈姹夊瓧21003涓?/span>

                                    

                                   琛?span lang=EN-US>1 姹夊瓧緙栫爜鑼冨洿

鍚嶇О

絎竴瀛楄妭

絎簩瀛楄妭

GB2312

0xB0-0xF7(176-247)

0xA0-0xFE錛?/span>160-254錛?/span>

GBK

0x81-0xFE錛?/span>129-254錛?/span>

0x40-0xFE錛?/span>64-254錛?/span>

Big5

0x81-0xFE錛?/span>129-255錛?/span>

0x40-0x7E錛?/span>64-126錛?/span>

0xA1錛?/span>0xFE錛?/span>161-254錛?/span>

 

 

浜屻佸姹夊瓧榪涜hash

    涓轟簡澶勭悊姹夊瓧鐨勬柟渚匡紝鍦ㄦ煡鎵炬眽瀛楃殑鏃跺欙紝鎴戜滑閫氬父浼氱敤鍒?span lang=EN-US>hash鐨勬柟娉曪紝閭f庝箞鏉ョ‘瀹氫竴涓眽瀛椾綅緗憿錛熻繖灝卞拰姣忕緙栫爜鐨勬帓鍒楁湁鍏充簡錛岃繖閲屼富瑕佺粰鍑轟竴縐?span lang=EN-US>hash鍑芥暟鐨勭瓥鐣ャ?/span>

    瀵逛簬GB2312緙栫爜錛岃杈撳叆鐨勬眽瀛椾負GBword錛屾垜浠彲浠ラ噰鐢ㄥ叕寮?span lang=EN-US>(C1-176)*94 + (C2-161)紜畾GBindex銆傚叾涓紝C1琛ㄧず絎竴瀛楄妭錛?span lang=EN-US>C2琛ㄧず絎簩瀛楄妭銆傚叿浣撳涓嬶細

    GBindex = ((unsigned char)GBword.at(0)-176)*94 + (unsigned char)GBword.at(1) - 161;

    涔嬫墍浠ョ敤unsigned char綾誨瀷錛屾槸鍥犱負char鏄竴涓瓧鑺傦紝濡傛灉鐢?span lang=EN-US>unsigend int錛屽洜涓?span lang=EN-US>int鏄?span lang=EN-US>4涓瓧鑺傜殑錛屾墍浠ヤ細閫犳垚鎵╁睍錛屽鑷撮敊璇?/span>

       瀵逛簬GBK緙栫爜錛岃杈撳叆鐨勬眽瀛椾負GBKword錛屽垯鍙互閲囩敤鍏紡   index=(ch1-0x81)*190+(ch2-0x40)-(ch2/128)錛屽叾涓?span lang=EN-US>ch1鏄涓瀛楄妭錛?span lang=EN-US>ch2鏄浜屽瓧鑺傘?/span>

    鍏蜂綋鐨勶紝

    GBKindex = ((unsigned char)GBKword[0]-129)*190 +

               ((unsigned char)GBKword[1]-64) - (unsigned char)GBKword[1]/128;

 

涓夈佹庢牱鍒ゆ柇涓涓眽瀛楃殑鏄粈涔堢紪鐮?/span>

鐩存帴鏍規嵁姹夊瓧鐨勭紪鐮佽寖鍥村垽鏂紝瀵逛簬GB2312鍜?span lang=EN-US>GBK鍙敤涓嬮潰涓や釜紼嬪簭瀹炵幇銆?/span>

1銆佸垽鏂槸鍚︽槸GB2312

bool isGBCode(const string& strIn)

{

    unsigned char ch1;

    unsigned char ch2;

   

    if (strIn.size() >= 2)

    {

        ch1 = (unsigned char)strIn.at(0);

        ch2 = (unsigned char)strIn.at(1);

        if (ch1>=176 && ch1<=247 && ch2>=160 && ch2<=254)

            return true;

        else return false;

    }

    else return false;

}

2銆佸垽鏂槸鍚︽槸GBK緙栫爜

bool isGBKCode(const string& strIn)

{

    unsigned char ch1;

    unsigned char ch2;

   

    if (strIn.size() >= 2)

    {

        ch1 = (unsigned char)strIn.at(0);

        ch2 = (unsigned char)strIn.at(1);

        if (ch1>=129 && ch1<=254 && ch2>=64 && ch2<=254)

            return true;

        else return false;

    }

    else return false;

}

 

3銆佸浜?span lang=EN-US>Big5

    瀹冪殑鑼冨洿涓猴細楂樺瓧鑺備粠0xA0鍒?span lang=EN-US>0xFE錛屼綆瀛楄妭浠?span lang=EN-US>0x40鍒?span lang=EN-US>0x7E錛屽拰0xA1鍒?span lang=EN-US>0xFE涓ら儴鍒嗐傚垽鏂竴涓眽瀛楁槸鍚︽槸BIG5緙栫爜錛屽彲浠ュ涓婂瀛楃鐨勭紪鐮佽寖鍥村垽鏂嵆鍙傚浣曞畾浣嶅憿錛熼偅涔堜篃鎯寵薄鎵鏈夌紪鐮佹帓鍒椾負涓涓簩緇村潗鏍囷紝綰靛潗鏍囨槸楂樺瓧鑺傦紝妯潗鏍囨槸浣庡瓧鑺傘傝繖鏍蜂竴琛屼笂鐨勬眽瀛椾釜鏁幫細(0x7E-0x40+1)+(0xFE-0xA1+1)錛?span lang=EN-US>157銆傞偅涔堝畾浣嶇畻娉曞垎涓ゅ潡錛屼負:  

    if 0x40<=ch2<=0x7E: #is big5 char

    index=((ch1-0xA1)*157+(ch2-0x40))*2

    elif 0xA1<=ch2<=0xFE: #is big5 char

    index=((ch1-0xA1)*157+(ch2-0xA1+63))*2

 

瀵逛簬絎簩鍧楋紝璁$畻鍋忕Щ閲忔椂鍥犱負鏈変袱鍧楁暟鍊鹼紝鎵浠ュ湪璁$畻鍚庨潰涓孌靛兼椂錛屼笉瑕佸繕浜嗗墠闈㈣繕鏈変竴孌靛箋?span lang=EN-US>0x7E-0x40+1=63銆?/span>

 

鍥涖佸鏋滃垽鏂竴涓瓧絎︽槸瑗挎枃瀛楃榪樻槸涓枃瀛楃

    澶у鐭ラ亾瑗挎枃瀛楃涓昏鏄寚ASCII鐮侊紝瀹冪敤涓涓瓧鑺傝〃紺恒備笖榪欎釜瀛楃杞崲鎴愭暟瀛椾箣鍚庯紝璇ユ暟瀛楁槸澶т簬0鐨勶紝鑰屾眽瀛楁槸涓や釜瀛楄妭鐨勶紝絎竴涓瓧鑺傜殑杞寲涓烘暟瀛椾箣鍚庡簲璇ユ槸灝忎簬0鐨勶紝鍥犳鍙互鏍規嵁姣忎釜瀛楄妭杞寲涓烘暟瀛椾箣鍚庢槸鍚﹀皬浜?span lang=EN-US>0錛屽垽鏂畠鏄惁鏄眽瀛椼?/span>

    渚嬪錛岃杈撳叆瀛椾負strin錛屽垯錛?/span>

     If (strin.at(0) < 0)

       cout << ”鏄眽瀛?span lang=EN-US>” << endl;

     else cout << ”涓嶆槸姹夊瓧” << endl;



kk 2007-11-01 14:53 鍙戣〃璇勮
]]>
甯哥敤鏁版嵁綾誨瀷浣跨敤杞崲璇﹁Вhttp://www.shnenglu.com/jacky2019/archive/2007/11/01/35657.htmlkkkkThu, 01 Nov 2007 01:30:00 GMThttp://www.shnenglu.com/jacky2019/archive/2007/11/01/35657.htmlhttp://www.shnenglu.com/jacky2019/comments/35657.htmlhttp://www.shnenglu.com/jacky2019/archive/2007/11/01/35657.html#Feedback0http://www.shnenglu.com/jacky2019/comments/commentRss/35657.htmlhttp://www.shnenglu.com/jacky2019/services/trackbacks/35657.htmlhttp://www.vckbase.com/study/article/data_convert.htm




甯哥敤鏁版嵁綾誨瀷浣跨敤杞崲璇﹁В
浣滆咃細紼嬩僵鍚?/p>


璇昏呭眰嬈★細鍒濆

鍒氭帴瑙C緙栫▼鐨勬湅鍙嬪線寰瀵硅澶氭暟鎹被鍨嬬殑杞崲鎰熷埌榪鋒儜涓嶈В錛屾湰鏂囧皢浠嬬粛涓浜涘父鐢ㄦ暟鎹被鍨嬬殑浣跨敤銆?br>
鎴戜滑鍏堝畾涔変竴浜涘父瑙佺被鍨嬪彉閲忓熶互璇存槑

int i = 100;
long l = 2001;
float f=300.2;
double d=12345.119;
char username[]="紼嬩僵鍚?;
char temp[200];
char *buf;
CString str;
_variant_t v1;
_bstr_t v2;

涓銆佸叾瀹冩暟鎹被鍨嬭漿鎹負瀛楃涓?/strong>

  • 鐭暣鍨?int)
    itoa(i,temp,10);///灝唅杞崲涓哄瓧絎︿覆鏀懼叆temp涓?鏈鍚庝竴涓暟瀛楄〃紺哄崄榪涘埗
    itoa(i,temp,2); ///鎸変簩榪涘埗鏂瑰紡杞崲
  • 闀挎暣鍨?long)
    ltoa(l,temp,10);
  • 嫻偣鏁?float,double)
    鐢╢cvt鍙互瀹屾垚杞崲,榪欐槸MSDN涓殑渚嬪瓙:
    int decimal, sign;
    char *buffer;
    double source = 3.1415926535;
    buffer = _fcvt( source, 7, &decimal, &sign );
    榪愯緇撴灉:source: 3.1415926535 buffer: '31415927' decimal: 1 sign: 0
    decimal琛ㄧず灝忔暟鐐圭殑浣嶇疆,sign琛ㄧず絎﹀彿:0涓烘鏁幫紝1涓鴻礋鏁?
  • CString鍙橀噺
    str = "2008鍖椾含濂ヨ繍";
    buf = (LPSTR)(LPCTSTR)str;
  • BSTR鍙橀噺
    BSTR bstrValue = ::SysAllocString(L"紼嬪簭鍛?);
    char * buf = _com_util::ConvertBSTRToString(bstrValue);
    SysFreeString(bstrValue);
    AfxMessageBox(buf);
    delete(buf);
  • CComBSTR鍙橀噺
    CComBSTR bstrVar("test");
    char *buf = _com_util::ConvertBSTRToString(bstrVar.m_str);
    AfxMessageBox(buf);
    delete(buf);
  • _bstr_t鍙橀噺
    _bstr_t綾誨瀷鏄BSTR鐨勫皝瑁咃紝鍥犱負宸茬粡閲嶈澆浜?鎿嶄綔絎︼紝鎵浠ュ緢瀹規槗浣跨敤
    _bstr_t bstrVar("test");
    const char *buf = bstrVar;///涓嶈淇敼buf涓殑鍐呭
    AfxMessageBox(buf);

  • 閫氱敤鏂規硶(閽堝闈濩OM鏁版嵁綾誨瀷)
    鐢╯printf瀹屾垚杞崲
    char  buffer[200];
                    char  c = '1';
                    int   i = 35;
                    long  j = 1000;
                    float f = 1.7320534f;
                    sprintf( buffer, "%c",c);
                    sprintf( buffer, "%d",i);
                    sprintf( buffer, "%d",j);
                    sprintf( buffer, "%f",f);
                    

浜屻佸瓧絎︿覆杞崲涓哄叾瀹冩暟鎹被鍨?/font>
strcpy(temp,"123");

  • 鐭暣鍨?int)
    i = atoi(temp);
  • 闀挎暣鍨?long)
    l = atol(temp);
  • 嫻偣(double)
    d = atof(temp);
  • CString鍙橀噺
    CString name = temp;
  • BSTR鍙橀噺
    BSTR bstrValue = ::SysAllocString(L"紼嬪簭鍛?);
    ...///瀹屾垚瀵筨strValue鐨勪嬌鐢?br>SysFreeString(bstrValue);
  • CComBSTR鍙橀噺
    CComBSTR綾誨瀷鍙橀噺鍙互鐩存帴璧嬪?br>CComBSTR bstrVar1("test");
    CComBSTR bstrVar2(temp);
  • _bstr_t鍙橀噺
    _bstr_t綾誨瀷鐨勫彉閲忓彲浠ョ洿鎺ヨ祴鍊?br>_bstr_t bstrVar1("test");
    _bstr_t bstrVar2(temp);

涓夈佸叾瀹冩暟鎹被鍨嬭漿鎹㈠埌CString
浣跨敤CString鐨勬垚鍛樺嚱鏁癋ormat鏉ヨ漿鎹?渚嬪:

  • 鏁存暟(int)
    str.Format("%d",i);
  • 嫻偣鏁?float)
    str.Format("%f",i);
  • 瀛楃涓叉寚閽?char *)絳夊凡緇忚CString鏋勯犲嚱鏁版敮鎸佺殑鏁版嵁綾誨瀷鍙互鐩存帴璧嬪?br>str = username;
  • 瀵逛簬Format鎵涓嶆敮鎸佺殑鏁版嵁綾誨瀷錛屽彲浠ラ氳繃涓婇潰鎵璇寸殑鍏充簬鍏跺畠鏁版嵁綾誨瀷杞寲鍒癱har *鐨勬柟娉曞厛杞埌char *錛岀劧鍚庤祴鍊肩粰CString鍙橀噺銆?br>

鍥涖丅STR銆乢bstr_t涓嶤ComBSTR

  • CComBSTR 鏄疉TL瀵笲STR鐨勫皝瑁咃紝_bstr_t鏄疌++瀵笲STR鐨勫皝瑁?BSTR鏄?2浣嶆寚閽?浣嗗茍涓嶇洿鎺ユ寚鍚戝瓧涓茬殑緙撳啿鍖恒?br>char *杞崲鍒癇STR鍙互榪欐牱:
    BSTR b=_com_util::ConvertStringToBSTR("鏁版嵁");///浣跨敤鍓嶉渶瑕佸姞涓奵omutil.h鍜宑omsupp.lib
    SysFreeString(bstrValue);
    鍙嶄箣鍙互浣跨敤
    char *p=_com_util::ConvertBSTRToString(b);
    delete p;
    鍏蜂綋鍙互鍙傝冧竴錛屼簩孌佃惤閲岀殑鍏蜂綋璇存槑銆?br>
    CComBSTR涓巁bstr_t瀵瑰ぇ閲忕殑鎿嶄綔絎﹁繘琛屼簡閲嶈澆錛屽彲浠ョ洿鎺ヨ繘琛?,!=,==絳夋搷浣滐紝鎵浠ヤ嬌鐢ㄩ潪甯告柟渚褲?br>鐗瑰埆鏄痏bstr_t,寤鴻澶у浣跨敤瀹冦?br>

 

浜斻乂ARIANT 銆乢variant_t 涓?COleVariant

  • VARIANT鐨勭粨鏋勫彲浠ュ弬鑰冨ご鏂囦歡VC98\Include\OAIDL.H涓叧浜庣粨鏋勪綋tagVARIANT鐨勫畾涔夈?br>瀵逛簬VARIANT鍙橀噺鐨勮祴鍊鹼細棣栧厛緇檝t鎴愬憳璧嬪鹼紝鎸囨槑鏁版嵁綾誨瀷錛屽啀瀵硅仈鍚堢粨鏋勪腑鐩稿悓鏁版嵁綾誨瀷鐨勫彉閲忚祴鍊鹼紝涓句釜渚嬪瓙錛?br>VARIANT va;
    int a=2001;
    va.vt=VT_I4;///鎸囨槑鏁村瀷鏁版嵁
    va.lVal=a; ///璧嬪?br>
    瀵逛簬涓嶉┈涓婅祴鍊肩殑VARIANT錛屾渶濂藉厛鐢╒oid VariantInit(VARIANTARG FAR* pvarg);榪涜鍒濆鍖?鍏舵湰璐ㄦ槸灝唙t璁劇疆涓篤T_EMPTY,涓嬭〃鎴戜滑鍒椾婦vt涓庡父鐢ㄦ暟鎹殑瀵瑰簲鍏崇郴:

    Byte bVal; // VT_UI1.
    Short iVal; // VT_I2.
    long lVal; // VT_I4.
    float fltVal; // VT_R4.
    double dblVal; // VT_R8.
    VARIANT_BOOL boolVal; // VT_BOOL.
    SCODE scode; // VT_ERROR.
    CY cyVal; // VT_CY.
    DATE date; // VT_DATE.
    BSTR bstrVal; // VT_BSTR.
    DECIMAL FAR* pdecVal // VT_BYREF|VT_DECIMAL.
    IUnknown FAR* punkVal; // VT_UNKNOWN.
    IDispatch FAR* pdispVal; // VT_DISPATCH.
    SAFEARRAY FAR* parray; // VT_ARRAY|*.
    Byte FAR* pbVal; // VT_BYREF|VT_UI1.
    short FAR* piVal; // VT_BYREF|VT_I2.
    long FAR* plVal; // VT_BYREF|VT_I4.
    float FAR* pfltVal; // VT_BYREF|VT_R4.
    double FAR* pdblVal; // VT_BYREF|VT_R8.
    VARIANT_BOOL FAR* pboolVal; // VT_BYREF|VT_BOOL.
    SCODE FAR* pscode; // VT_BYREF|VT_ERROR.
    CY FAR* pcyVal; // VT_BYREF|VT_CY.
    DATE FAR* pdate; // VT_BYREF|VT_DATE.
    BSTR FAR* pbstrVal; // VT_BYREF|VT_BSTR.
    IUnknown FAR* FAR* ppunkVal; // VT_BYREF|VT_UNKNOWN.
    IDispatch FAR* FAR* ppdispVal; // VT_BYREF|VT_DISPATCH.
    SAFEARRAY FAR* FAR* pparray; // VT_ARRAY|*.
    VARIANT FAR* pvarVal; // VT_BYREF|VT_VARIANT.
    void FAR* byref; // Generic ByRef.
    char cVal; // VT_I1.
    unsigned short uiVal; // VT_UI2.
    unsigned long ulVal; // VT_UI4.
    int intVal; // VT_INT.
    unsigned int uintVal; // VT_UINT.
    char FAR * pcVal; // VT_BYREF|VT_I1.
    unsigned short FAR * puiVal; // VT_BYREF|VT_UI2.
    unsigned long FAR * pulVal; // VT_BYREF|VT_UI4.
    int FAR * pintVal; // VT_BYREF|VT_INT.
    unsigned int FAR * puintVal; //VT_BYREF|VT_UINT.

  • _variant_t鏄疺ARIANT鐨勫皝瑁呯被錛屽叾璧嬪煎彲浠ヤ嬌鐢ㄥ己鍒剁被鍨嬭漿鎹紝鍏舵瀯閫犲嚱鏁頒細鑷姩澶勭悊榪欎簺鏁版嵁綾誨瀷銆?br>浣跨敤鏃墮渶鍔犱笂#include <comdef.h>
    渚嬪錛?br>long l=222;
    ing i=100;
    _variant_t lVal(l);
    lVal = (long)i;

  • COleVariant鐨勪嬌鐢ㄤ笌_variant_t鐨勬柟娉曞熀鏈竴鏍鳳紝璇峰弬鑰冨涓嬩緥瀛愶細
    COleVariant v3 = "瀛楃涓?, v4 = (long)1999;
    CString str =(BSTR)v3.pbstrVal;
    long i = v4.lVal;

鍏佸叾瀹冧竴浜汣OM鏁版嵁綾誨瀷

  • 鏍規嵁ProgID寰楀埌CLSID
    HRESULT CLSIDFromProgID( LPCOLESTR lpszProgID,LPCLSID pclsid);
    CLSID clsid;
    CLSIDFromProgID( L"MAPI.Folder",&clsid);
  • 鏍規嵁CLSID寰楀埌ProgID
    WINOLEAPI ProgIDFromCLSID( REFCLSID clsid,LPOLESTR * lplpszProgID);
    渚嬪鎴戜滑宸茬粡瀹氫箟浜?CLSID_IApplication,涓嬮潰鐨勪唬鐮佸緱鍒癙rogID
    LPOLESTR pProgID = 0;
    ProgIDFromCLSID( CLSID_IApplication,&pProgID);
    ...///鍙互浣跨敤pProgID
    CoTaskMemFree(pProgID);//涓嶈蹇樿閲婃斁

涓冦丄NSI涓嶶nicode
Unicode縐頒負瀹藉瓧絎﹀瀷瀛椾覆,COM閲屼嬌鐢ㄧ殑閮芥槸Unicode瀛楃涓層?/p>

  • 灝咥NSI杞崲鍒癠nicode
    (1)閫氳繃L榪欎釜瀹忔潵瀹炵幇錛屼緥濡? CLSIDFromProgID( L"MAPI.Folder",&clsid);
    (2)閫氳繃MultiByteToWideChar鍑芥暟瀹炵幇杞崲,渚嬪:
    char *szProgID = "MAPI.Folder";
    WCHAR szWideProgID[128];
    CLSID clsid;
    long lLen = MultiByteToWideChar(CP_ACP,0,szProgID,strlen(szProgID),szWideProgID,sizeof(szWideProgID));
    szWideProgID[lLen] = '\0';
    (3)閫氳繃A2W瀹忔潵瀹炵幇,渚嬪:
    USES_CONVERSION;
    CLSIDFromProgID( A2W(szProgID),&clsid);
  • 灝哢nicode杞崲鍒癆NSI
    (1)浣跨敤WideCharToMultiByte,渚嬪:
    // 鍋囪宸茬粡鏈変簡涓涓猆nicode 涓?wszSomeString...
    char szANSIString [MAX_PATH];
    WideCharToMultiByte ( CP_ACP, WC_COMPOSITECHECK, wszSomeString, -1, szANSIString, sizeof(szANSIString), NULL, NULL );
    (2)浣跨敤W2A瀹忔潵瀹炵幇,渚嬪:
    USES_CONVERSION;
    pTemp=W2A(wszSomeString);

鍏佸叾瀹?/strong>

  • 瀵規秷鎭殑澶勭悊涓垜浠粡甯擱渶瑕佸皢WPARAM鎴朙PARAM絳?2浣嶆暟鎹紙DWORD)鍒嗚В鎴愪袱涓?6浣嶆暟鎹紙WORD),渚嬪錛?br>LPARAM lParam;
    WORD loValue = LOWORD(lParam);///鍙栦綆16浣?br>WORD hiValue = HIWORD(lParam);///鍙栭珮16浣?br>
  • 瀵逛簬16浣嶇殑鏁版嵁(WORD)鎴戜滑鍙互鐢ㄥ悓鏍風殑鏂規硶鍒嗚В鎴愰珮浣庝袱涓?浣嶆暟鎹?BYTE),渚嬪:
    WORD wValue;
    BYTE loValue = LOBYTE(wValue);///鍙栦綆8浣?br>BYTE hiValue = HIBYTE(wValue);///鍙栭珮8浣?br>
  • 涓や釜16浣嶆暟鎹紙WORD錛夊悎鎴?2浣嶆暟鎹?DWORD,LRESULT,LPARAM,鎴朩PARAM)
    LONG MAKELONG( WORD wLow, WORD wHigh );
    WPARAM MAKEWPARAM( WORD wLow, WORD wHigh );
    LPARAM MAKELPARAM( WORD wLow, WORD wHigh );
    LRESULT MAKELRESULT( WORD wLow, WORD wHigh );

  • 涓や釜8浣嶇殑鏁版嵁(BYTE)鍚堟垚16浣嶇殑鏁版嵁(WORD)
    WORD MAKEWORD( BYTE bLow, BYTE bHigh );

  • 浠嶳(red),G(green),B(blue)涓夎壊寰楀埌COLORREF綾誨瀷鐨勯鑹插?br>COLORREF RGB( BYTE byRed,BYTE byGreen,BYTE byBlue );
    渚嬪COLORREF bkcolor = RGB(0x22,0x98,0x34);

  • 浠嶤OLORREF綾誨瀷鐨勯鑹插煎緱鍒癛GB涓変釜棰滆壊鍊?br>BYTE Red = GetRValue(bkcolor); ///寰楀埌綰㈤鑹?br>BYTE Green = GetGValue(bkcolor); ///寰楀埌緇塊鑹?br>BYTE Blue = GetBValue(bkcolor); ///寰楀埌鍏伴鑹?br>

涔濄佹敞鎰忎簨欏?/strong>
鍋囧闇瑕佷嬌鐢ㄥ埌ConvertBSTRToString姝ょ被鍑芥暟,闇瑕佸姞涓婂ご鏂囦歡comutil.h,騫跺湪setting涓姞鍏omsupp.lib鎴栬呯洿鎺ュ姞涓?pragma comment( lib, "comsupp.lib" )

鍚庤錛氭湰鏂囧寙鍖嗗啓鎴愶紝閿欒涔嬪鍦ㄦ墍闅懼厤錛屾榪庢寚姝?



kk 2007-11-01 09:30 鍙戣〃璇勮
]]>
鈥滀紤鎭濅簡鍗婂勾http://www.shnenglu.com/jacky2019/archive/2007/10/29/35443.htmlkkkkMon, 29 Oct 2007 05:34:00 GMThttp://www.shnenglu.com/jacky2019/archive/2007/10/29/35443.htmlhttp://www.shnenglu.com/jacky2019/comments/35443.htmlhttp://www.shnenglu.com/jacky2019/archive/2007/10/29/35443.html#Feedback0http://www.shnenglu.com/jacky2019/comments/commentRss/35443.htmlhttp://www.shnenglu.com/jacky2019/services/trackbacks/35443.html

浜虹敓灝卞儚榫熷厰璧涜窇銆備竴寮濮嬮鍏堜笉浠h〃浣犱細涓鐩撮鍏堛傚悓鏍鳳紝涓寮濮嬭惤鍚庝笉浠h〃浣犱細涓鐩磋惤鍚庛備絾鏄鏋滀綘涓嬩笉浜嗗喅蹇冿紝涓嶅彲鑳藉姫鍔涳紝娌℃湁鑷埗鍔涳紝娌℃瘏鍔涚殑璇濓紝浣犺偗瀹氫笉浼氶鍏堢殑銆?br>
涔愯錛屽紑鏈楋紝縐瀬鐨勬佸害銆傚ソ闀挎椂闂存病鏈変綋浼氬埌棰嗗厛甯︾粰鎴戠殑涔愯叮浜嗭紱濂介暱鏃墮棿娌℃湁浣撲細鍒板涔犳妧鏈甫緇欐垜鐨勫揩涔愪簡銆傝閲嶆柊褰掗槦錛屽ソ濂藉涔狅紝濂藉ソ宸ヤ綔浜嗐?br>
搴熻瘽涓嶅璇達紝寮宸ャ?img height=20 src="http://www.shnenglu.com/Emoticons/QQ/12.gif" width=20 border=0>

kk 2007-10-29 13:34 鍙戣〃璇勮
]]>
python涓巆++浜や簰瀛︿範鍏ラ棬涔?http://www.shnenglu.com/jacky2019/archive/2007/06/06/25662.htmlkkkkWed, 06 Jun 2007 08:25:00 GMThttp://www.shnenglu.com/jacky2019/archive/2007/06/06/25662.htmlhttp://www.shnenglu.com/jacky2019/comments/25662.htmlhttp://www.shnenglu.com/jacky2019/archive/2007/06/06/25662.html#Feedback7http://www.shnenglu.com/jacky2019/comments/commentRss/25662.htmlhttp://www.shnenglu.com/jacky2019/services/trackbacks/25662.html榪欐璁茶錛屽浣曟墿灞昪++搴撱傞氳繃boost.python鎶奵++搴撶紪璇戞垚python鑳藉璋冪敤鐨刣ll銆?/p>


閫氳繃涓婁竴嬈$殑鏁欑▼鍚庯紝澶у閮藉簲璇ヤ細浣跨敤boost.python浜嗐傛妸c++紼嬪簭緙栬瘧鎴恜yd鏂囦歡銆傜敱浜巆++鏈夊緢澶氱壒鎬э紝鎵浠ワ紝濡傛灉浣犵殑紼?/p>

搴忕敤浜嗗緢澶氱殑c++鐗規х殑璇濓紝閭d箞浣犲繀欏誨仛寰堝宸ヤ綔浜嗐傚儚铏氭嫙鍑芥暟錛屽嚱鏁伴噸杞斤紝緇ф壙錛岄粯璁ゅ肩瓑絳夈傚叿浣撳浣曡漿鍖栵紝璇峰弬

boost.python鐨勬枃妗d簡銆?/p>


榪欏嚑澶╁皾璇曠潃鎶奵++紼嬪簭搴撶紪璇戞垚python鍙皟鐢ㄧ殑dll錛屼笉鐭ラ亾涓轟粈涔堜竴鐩翠笉鍙敤銆傘傚緢鏄儊闂楓傝佹槸鏄劇ず濡備笅鐨勯敊璇細

Traceback (most recent call last):
  File "<pyshell#3>", line 1, in <module>
    import pydll
ImportError: No module named pydll

鎰忔濇槸璇存壘涓嶅埌dll銆傛垜鎶奷ll閮絚opy鍒皃ython/dlls涓嬩簡榪樻槸涓嶈錛岃屼笖鎴戠‘瀹歱ython鐨剆ys.path鍖呭惈浜唒ython/dlls鐩綍浜嗐?/p>

寰堟槸涓嶈В銆傜綉涓婁篃寰堥毦鎵懼埌璧勬枡錛実oogle浜嗗緢闀挎椂闂存壘涓嶅埌鏈夌敤鐨勮祫鏂欙紝濂藉儚涓枃鏂歸潰鐨勮祫鏂欏緢灝戠殑銆備粖澶╁皾璇曚簡涓涓媑oogle

鑻辨枃璧勬枡錛岀粓浜庢湁浜嗘柊鐨勫彂鐜幫細
http://mail.python.org/pipermail/c++-sig/2007-February/011971.html
You are using Python2.5. In this version of Python you have to have
file extension
to be "pyd" - sge.pyd

--
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/

鏈変漢紕板埌鐨勯棶棰樿窡鎴戠殑鏄竴鏍風殑銆傚悗闈㈤偅涓猂oman鍥炵瓟浜嗕竴涓嬶紝鏄枃浠舵墿灞曞悕鐨勯棶棰橈紒錛侊紒涓轟粈涔堜笉鏀寔dll鍛紵涓嶈В銆傚洖鍘昏瘯

浜嗕竴涓嬫妸鍚庣紑鍚嶆敼浜嗗氨鎴愬姛浜嗐傘傘倃hy???


涓嬮潰鏉ョ湅涓涓嬫垜鐨勯偅涓畝鍗曠殑渚嬪瓙錛?br>榪欎釜渚嬪瓙鏉ヨ嚜浜庣綉涓婏紝
http://www.vckbase.com/document/viewdoc/?id=1540
C++ 鎵╁睍鍜屽祵鍏?Python
浣滆咃細鑳¢噾灞?br>婧愮爜涓嬭澆鍦板潃錛?a >http://www.vckbase.com/code/downcode.asp?id=2777


榪欐槸涓涓潪甯哥畝鍗曠殑dll宸ョ▼銆傜粰python鎻愪緵浜嗕竴涓嚱鏁皊tatic PyObject* Recognise(PyObject *self, PyObject *args)銆?/p>


1銆佷笉浣跨敤boost.python搴撴潵鐩存帴鏋勫緩dll
鎺ヤ笅鏉ワ紝鎴戜滑鏉ョ敤C++涓篜ython緙栧啓鎵╁睍妯″潡(鍔ㄦ侀摼鎺ュ簱)錛屽茍鍦≒ython紼嬪簭涓皟鐢–++寮鍙戠殑鎵╁睍鍔熻兘鍑芥暟銆傜敓鎴愪竴涓彇鍚嶄負

pyUtil鐨刉in32 DLL宸ョ▼錛岄櫎浜唒yUtil.cpp鏂囦歡浠ュ錛屼粠宸ョ▼涓Щ闄ゆ墍鏈夊叾瀹冩枃浠訛紝騫跺~鍏ュ涓嬬殑浠g爜錛?

// pyUtil.cpp
#ifdef PYUTIL_EXPORTS
#define PYUTIL_API __declspec(dllexport)
#else
#define PYUTIL_API __declspec(dllimport)
#endif

#include<windows.h>
#include<string>
#include<Python.h>
BOOL APIENTRY DllMain( HANDLE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
        )
{
    switch (ul_reason_for_call)
    {
    case DLL_PROCESS_ATTACH:
    case DLL_THREAD_ATTACH:
    case DLL_THREAD_DETACH:
    case DLL_PROCESS_DETACH:
        break;
    }
    return TRUE;
}
std::string Recognise_Img(const std::string url)
{
    //榪斿洖緇撴灉
    return "浠巇ll涓繑鍥炵殑鏁版嵁... : " +url;
}
static PyObject* Recognise(PyObject *self, PyObject *args)
{
    const char *url;
    std::string sts;
    if (!PyArg_ParseTuple(args, "s", &url))
        return NULL;
    sts = Recognise_Img(url);
    return Py_BuildValue("s", sts.c_str() );
}
static PyMethodDef AllMyMethods[] = {
    {"Recognise",  Recognise, METH_VARARGS},//鏆撮湶緇橮ython鐨勫嚱鏁?br>    {NULL,      NULL}        /* Sentinel */
};
extern "C" PYUTIL_API void initpyUtil()
{
    PyObject *m, *d;
    m = Py_InitModule("pyUtil", AllMyMethods); //鍒濆鍖栨湰妯″潡錛屽茍鏆撮湶鍑芥暟
    d = PyModule_GetDict(m);
}

鍦≒ython浠g爜涓皟鐢ㄨ繖涓姩鎬侀摼鎺ュ簱錛?(璁板緱鎶奷ll鐨勬墿灞曞悕鏀逛負.pyd錛屽彟澶杁ll鐨勮礬寰勮鑳藉琚绱㈠埌)
import pyUtil
result = pyUtil.Recognise("input url of specific data")
print "the result is: "+ result

 

2銆佷嬌鐢╞oost.python搴撴潵鏋勫緩dll
鐢–++涓篜ython鍐欐墿灞曟椂錛屽鏋滄偍鎰挎剰浣跨敤Boost.Python搴撶殑璇濓紝寮鍙戣繃紼嬩細鍙樺緱鏇村紑蹇僇錛岃緙栧啓涓涓笌涓婅堪pyUtil鍚屾牱鍔熻兘

鐨勫姩鎬侀摼鎺ュ簱錛屽彧闇鎶婃枃浠跺唴瀹規浛鎹負涓嬮潰鐨勪唬鐮併傚綋鐒訛紝緙栬瘧闇瑕乥oost_python.lib鏀寔錛岃繍琛岄渶瑕乥oost_python.dll鏀寔

銆?
#include<string>
#include <boost/python.hpp>
using namespace boost::python;
#pragma comment(lib, "boost_python.lib")
std::string strtmp;
char const* Recognise(const char* url)
{
    strtmp ="浠巇ll涓繑鍥炵殑鏁版嵁... : ";
    strtmp+=url;
    return strtmp.c_str();
}
BOOST_PYTHON_MODULE(pyUtil)
{
    def("Recognise", Recognise);
}

鍙互闈炲父鏄庢樉鍦扮湅鍒幫紝鐢ㄤ簡boost.python搴撲箣鍚庯紝綆鍗曚簡寰堝銆傚洜涓篵oost.python涓轟綘鍋氫簡寰堝鐨勪簨鎯呫傘傛仼銆?/p>

 

濂藉儚娌℃湁璁插緢澶氭湁鐢ㄧ殑涓滆タ錛屽厜欏劇潃璁蹭簡錛屽懙鍛點傘傘傛垜涔熻繕鍦ㄧ戶緇涔犱箣涓備笅嬈″啓鐐逛粈涔堝憿錛熺戶緇涔犱簡鍝?/p>

 



kk 2007-06-06 16:25 鍙戣〃璇勮
]]>
c++涓祵鍏ython鍏ラ棬4 涔?Boost.Pythonhttp://www.shnenglu.com/jacky2019/archive/2007/06/01/25254.htmlkkkkFri, 01 Jun 2007 02:32:00 GMThttp://www.shnenglu.com/jacky2019/archive/2007/06/01/25254.htmlhttp://www.shnenglu.com/jacky2019/comments/25254.htmlhttp://www.shnenglu.com/jacky2019/archive/2007/06/01/25254.html#Feedback5http://www.shnenglu.com/jacky2019/comments/commentRss/25254.htmlhttp://www.shnenglu.com/jacky2019/services/trackbacks/25254.html鍧忓python25 + vs2005 (2005鐪熻楄祫婧愰樋銆傘傘?

鏈変竴孌墊椂闂存病鍐檅log浜嗐傝繖鍑犲ぉ閮藉湪鐮旂┒鎬庝箞灝佽c++錛岃python鍙互鐢╟++鐨勫簱銆傚湪緗戜笂鍙戠幇浜哹oost.python榪欎釜濂藉挌鍜氥備笉

榪囧湪浣跨敤榪囩▼涓鍒頒竴鐐歸棶棰樸傛湰鏂囨暀澶у濡備綍鎶?/p>

char const* greet()
{
   return "hello, world";
}

灝佽鎴恜ython銆傚疄闄呬笂榪欐槸python鏁欑▼閲岄潰鐨勫挌鍜氥?/p>


棣栧厛涓嬭澆Boost錛?a >www.boost.org銆俠oost.python鍦╞oost閲岄潰浜嗐傚湪visual studio 2005 command prompt涓璶avigation鍒?/p>

boost\boost_1_34_0\涓嬨傝寰椾竴瀹氳鐢╲isual studio 2005 command prompt榪欎釜vs2005甯︾殑tools錛屼笉瑕佺敤cmd.exe錛屽惁鍒欎細

紕板埌寰堝閿欒鐨勩傜劧鍚庡氨鏄妸bjam.exe鎷瘋礉鍒頒竴涓兘琚壘鍒扮殑鐩綍涓嬶紝鎴栬呯洿鎺ヤ篃鎷瘋礉鍒癰oost\boost_1_34_0\涓嬪嵆鍙傜劧鍚庯紝

璁劇疆python鐨勬牴鐩綍鍜宲ython鐨勭増鏈紝涔熷彲鐩存帴鎶婂畠浠姞鍒板潖澧冪洰褰曚腑錛岄偅鏍峰氨涓嶇敤姣忔閮借緗竴涓嬨?br>set PYTHON_ROOT=c:/python25
set PYTHON_VERSION=2.5

鎺ョ潃灝卞彲浠ョ洿鎺ヨ繍琛屼簡錛宐jam -sTOOLS=vc-8_0
鏁翠釜緙栬瘧榪囩▼瑕佸緢闀挎椂闂淬傘傘?/p>

鎴愬姛涔嬪悗錛屽氨浼氭湁濂藉涓猙oost_python-vc80-****.dll,.lib鐨勶紝鎶婁粬浠兘鎷瘋礉鍒頒竴涓兘琚郴緇熸壘鍒扮殑鐩綍錛屼笉濡ㄧ洿鎺ユ妸浠栦滑閮?/p>

鎵斿埌c:\windows\system32涓嬨?/p>

鎺ョ潃錛屾垜浠紑濮嬬紪璇慼ello銆俷avigation鍒癰oost\boost_1_34_0\libs\python\example\tutorial涓嬶紝bjam -sTOOLS=vc-8_0榪愯

錛屽湪bin鐨勭洰褰曚笅鍗充細鐢熸垚hello.pyd銆傝繖涓嬪氨鍩烘湰鎴愬姛浜嗭紝濡傛灉娌℃垚鍔熺殑璇濓紝check涓涓嬩笂闈oost_python鐨勯偅浜沝ll鑳藉惁琚郴

緇熸壘鍒般傚彟澶栵紝榪欓噷鏈塸ython25鐨勪竴涓猙ug銆傘傘傛垜鑺變簡寰堥暱鏃墮棿鎵嶅湪python鐨刴ail lists涓壘鍒頒簡銆傚瘨銆傘傘?/p>

閿欒濡備笅鎵紺猴細
D:\Learn\Python\boost\boost_1_34_0\libs\python\example\tutorial>bjam
Jamroot:17: in modules.load
rule python-extension unknown in module Jamfile</D:/Learn/Python/boost/boost_1_3
4_0/libs/python/example/tutorial>.
D:/Learn/Python/boost/boost_1_34_0/tools/build/v2/build\project.jam:312: in load
-jamfile
D:/Learn/Python/boost/boost_1_34_0/tools/build/v2/build\project.jam:68: in load
D:/Learn/Python/boost/boost_1_34_0/tools/build/v2/build\project.jam:170: in proj
ect.find
D:/Learn/Python/boost/boost_1_34_0/tools/build/v2\build-system.jam:237: in load
D:\Learn\Python\boost\boost_1_34_0\libs\python\example\..\..\..\tools\build\v2/k
ernel\modules.jam:261: in import
D:\Learn\Python\boost\boost_1_34_0\libs\python\example\..\..\..\tools\build\v2/k
ernel/bootstrap.jam:132: in boost-build
D:\Learn\Python\boost\boost_1_34_0\libs\python\example\boost-build.jam:7: in mod
ule scope

瑙e喅鍔炴硶濡備笅錛?br>鍦╞oost\boost_1_34_0\tools\build\v2\鐩綍涓嬫壘鍒皍ser-config.jam鏂囦歡錛屾墦寮鍦?br>import toolset : using ;
涓嬮潰鍔犱竴琛屼唬鐮侊細
using python ;
鍐嶉噸鏂扮紪璇戜竴涓媌oost錛岀劧鍚庡氨娌¢棶棰樹簡銆倀utorial閲岄潰鐨刪ello鑳介『鍒╃紪璇戦氳繃銆俻s.榪欎釜闂鍥版壈浜嗘垜濂介暱鏃墮棿銆傘俿igh銆傘?/p>

銆?/p>

緙栬瘧鎴愬姛鍚庝細浜х敓涓涓猦ello.pyd錛屽湪bin鐨勭洰褰曚笅闈€?/p>


鏈夊ソ澶氬姙娉曟祴璇曟hello.pyd鏄惁鍙互鐢ㄣ?br>鏂規硶涓錛屾妸瀹冩嫹璐濆埌python25\dlls涓嬶紝鎵撳紑IDLE錛?br>>>> import hello
>>> hello.greet()
'hello, world'
>>>
鏂規硶浜岋紝鐩存帴鍦ㄥ綋鍓嶇洰褰曚笅鍐欎竴涓猵ython鏂囦歡錛岀劧鍚庣洿鎺ヨ皟鐢╤ello.pyd鍗沖彲銆傛諱箣錛宧ello.pyd灝辨槸涓涓猵ython鏂囦歡浜嗐傘傚棷

銆傛搷浣渉ello.pyd鏍瑰叾浠杙ython鏂囦歡鏄竴鏍風殑銆?br>榪欐牱灝辨垚鍔熶簡銆?/p>

濡傛灉紕板埌濡備笅閿欒錛屾槸鍥犱負緋葷粺鎵句笉鍒癰oost_python鐨刣ll銆傚己鐑堝緩璁妸浠栦滑閮芥墧鍒皊ystem32涓嬶紒銆?/p>

>>> import hello

Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    import hello
ImportError: DLL load failed: 鎵句笉鍒版寚瀹氱殑妯″潡銆?br>>>>


璇存槑錛宧ello.cpp鍦╞oost\boost_1_34_0\libs\python\example\tutorial鐩綍涓嬨傞噷闈㈢殑鍐呭鏄細

//  Copyright Joel de Guzman 2002-2004. Distributed under the Boost
//  Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt
//  or copy at http://www.boost.org/LICENSE_1_0.txt)
//  Hello World Example from the tutorial
//  [Joel de Guzman 10/9/2002]

char const* greet()
{
   return "hello, world";
}

#include <boost/python/module.hpp>
#include <boost/python/def.hpp>
using namespace boost::python;

BOOST_PYTHON_MODULE(hello)
{
    def("greet", greet);
}


鍏朵腑
BOOST_PYTHON_MODULE(hello)
{
    def("greet", greet);
}
鏄greet浠巆++鍚憄ython鐨勪竴涓皝瑁呭0鏄庡惂錛岃鎹㈠氨浜ょ粰boost浜嗐?/p>

 

鍏堝啓鍒拌繖閲屼簡銆備笅嬈″啀鍐欍傘傚棷



kk 2007-06-01 10:32 鍙戣〃璇勮
]]>
絎旇鏈富鏉垮潖浜?/title><link>http://www.shnenglu.com/jacky2019/archive/2007/05/31/25203.html</link><dc:creator>kk</dc:creator><author>kk</author><pubDate>Thu, 31 May 2007 07:58:00 GMT</pubDate><guid>http://www.shnenglu.com/jacky2019/archive/2007/05/31/25203.html</guid><wfw:comment>http://www.shnenglu.com/jacky2019/comments/25203.html</wfw:comment><comments>http://www.shnenglu.com/jacky2019/archive/2007/05/31/25203.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.shnenglu.com/jacky2019/comments/commentRss/25203.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/jacky2019/services/trackbacks/25203.html</trackback:ping><description><![CDATA[閮侀椃錛屾瀬搴﹂儊闂楓傘傘? <img src ="http://www.shnenglu.com/jacky2019/aggbug/25203.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/jacky2019/" target="_blank">kk</a> 2007-05-31 15:58 <a href="http://www.shnenglu.com/jacky2019/archive/2007/05/31/25203.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>c++涓祵鍏ython鍏ラ棬3http://www.shnenglu.com/jacky2019/archive/2007/05/17/24286.htmlkkkkThu, 17 May 2007 07:16:00 GMThttp://www.shnenglu.com/jacky2019/archive/2007/05/17/24286.htmlhttp://www.shnenglu.com/jacky2019/comments/24286.htmlhttp://www.shnenglu.com/jacky2019/archive/2007/05/17/24286.html#Feedback3http://www.shnenglu.com/jacky2019/comments/commentRss/24286.htmlhttp://www.shnenglu.com/jacky2019/services/trackbacks/24286.html榪欐涓昏璁茶鎬庝箞鎶妏ython涓殑class宓屽叆鍒癱++涓幓銆?br>欏轟究璁茶鍏冪粍鐨勬搷浣滃拰鎬庝箞緙栬瘧python婧愪唬鐮併?/p>

1. 棣栧厛璁茶鍏冪粍鐨勬搷浣?br>鐢變簬鍙傛暟鏄氳繃鍏冪粍浼犺繘鍘葷殑錛屾墍浠ユ垜浠笉鑳借佹槸閫氳繃Py_BuildValue榪欎釜鍑芥暟鏉ユ搷浣滃厓緇勶紝閭f牱澶笉鏂逛究浜嗐?br>Python鎻愪緵浜嗗厓緇勭浉鍏崇殑鎿嶄綔錛屼笅闈㈣繖涓緥瀛愭紨紺轟簡濡備綍鎿嶄綔銆備富瑕佹槸涓嬮潰鍑犱釜鍑芥暟錛?br>//new涓涓厓緇勶紝浼犲叆size
pArgs = PyTuple_New(argc - 3); 
//set鍏冪粍鐨勭洿錛岀涓涓負鍏冪粍錛岀浜屼釜涓篿ndex錛堜粠0寮濮嬶級錛岀涓変釜涓簐alue
PyTuple_SetItem(pArgs,0,Py_BuildValue("i",2000) );
PyTuple_SetItem(pArgs,1,Py_BuildValue("i",8) );

鏉ヨ嚜python doc鐨勪竴涓緥瀛?/p>

#include <Python.h>
int
main(int argc, char *argv[])
{
    PyObject *pName, *pModule, *pDict, *pFunc;
    PyObject *pArgs, *pValue;
    int i;

    if (argc < 3) {
        fprintf(stderr,"Usage: call pythonfile funcname [args]\n");
        return 1;
    }

    Py_Initialize();
    pName = PyString_FromString(argv[1]);
    /* Error checking of pName left out */

    pModule = PyImport_Import(pName);
    Py_DECREF(pName);

    if (pModule != NULL) {
        pFunc = PyObject_GetAttrString(pModule, argv[2]);
        /* pFunc is a new reference */

        if (pFunc && PyCallable_Check(pFunc)) {
            pArgs = PyTuple_New(argc - 3);
            for (i = 0; i < argc - 3; ++i) {
                pValue = PyInt_FromLong(atoi(argv[i + 3]));
                if (!pValue) {
                    Py_DECREF(pArgs);
                    Py_DECREF(pModule);
                    fprintf(stderr, "Cannot convert argument\n");
                    return 1;
                }
                /* pValue reference stolen here: */
                PyTuple_SetItem(pArgs, i, pValue);
            }
            pValue = PyObject_CallObject(pFunc, pArgs);
            Py_DECREF(pArgs);
            if (pValue != NULL) {
                printf("Result of call: %ld\n", PyInt_AsLong(pValue));
                Py_DECREF(pValue);
            }
            else {
                Py_DECREF(pFunc);
                Py_DECREF(pModule);
                PyErr_Print();
                fprintf(stderr,"Call failed\n");
                return 1;
            }
        }
        else {
            if (PyErr_Occurred())
                PyErr_Print();
            fprintf(stderr, "Cannot find function \"%s\"\n", argv[2]);
        }
        Py_XDECREF(pFunc);
        Py_DECREF(pModule);
    }
    else {
        PyErr_Print();
        fprintf(stderr, "Failed to load \"%s\"\n", argv[1]);
        return 1;
    }
    Py_Finalize();
    return 0;
}


2. class鎿嶄綔
鎶婁笅闈㈠姞鍏ュ埌test2.py涓幓銆傚畾涔変簡涓涓緢綆鍗曠殑綾伙紝鏈変竴涓猲ame鎴愬憳鍙橀噺錛屼竴涓猵rintName鎴愬憳鍑芥暟
class TestClass:
    def __init__(self,name):
        self.name = name

    def printName(self):
        print self.name

cpp鏂囦歡
#include <python.h>
int main()
{
 Py_Initialize();

 PyObject * pModule = NULL;
 PyObject * pFunc   = NULL;
 PyObject * pArg    = NULL;
 PyObject * pClass  = NULL;
 PyObject * pObject = NULL;

 pModule = PyImport_ImportModule("test2");
 pClass  = PyObject_GetAttrString(pModule, "TestClass");//寰楀埌閭d釜綾?br> pArg = PyTuple_New(1);
 PyTuple_SetItem(pArg, 0, Py_BuildValue("s", "Jacky"));
 pObject = PyEval_CallObject(pClass, pArg);//鐢熸垚涓涓璞★紝鎴栬呭彨浣滃疄渚?/p>

 pFunc = PyObject_GetAttrString(pObject, "printName");//寰楀埌璇ュ疄渚嬬殑鎴愬憳鍑芥暟
 PyEval_CallObject(pFunc, NULL);//鎵ц璇ュ疄渚嬬殑鎴愬憳鍑芥暟

 Py_Finalize();

 return 0;
}


娌℃湁浠涔堣祫鏂欙紝灝卞厛鍐欏埌榪欓噷浜嗐備笅闈粙緇嶄竴涓嬫庝箞build python25鐨勬簮浠g爜

3. 緙栬瘧python婧愪唬鐮?br>涓轟粈涔堣緙栬瘧鍛紵鍥犱負娌℃湁python25_d.lib錛佸懙鍛點傞『渚垮彲浠ヤ簡瑙d竴涓嬩唬鐮佺粨鏋勩?br>瑙e帇緙╁悗錛屾湁濂藉鐩綍錛屽叾涓璸cbuild鍜宲cbuild8鏄垜浠鐨勩俻cbuild瀵瑰簲鐫vc7.1鐨?pcbuild8瀵瑰簲鐫vc8.0鐨?br>鍥犱負鍦ㄧ敤vc7.1錛屼篃灝辨槸2003浜嗐傛墍浠ユ垜灝辮璇存庝箞鐢?003鏉ョ紪璇戝惂銆備簨瀹炰笂鏄粠涓浣嶇墰浜洪偅閲屽鏉ョ殑

http://blog.donews.com/lemur/archive/2005/12/17/660973.aspx錛岄偅浣嶅ぇ鍝ュぇ姒備竴騫村崐鍓嶅氨鍦ㄨВ鍓杙ython浜嗭紝鍘夊

闃褲傜湅鏉ユ垜鍙兘鍚庢潵灞呬笂浜嗭紝濞冨搱鍝堛傛垜鎸夌収浠栬鐨勮瘯浜嗕竴涓嬶紝緙栬瘧鎴愬姛錛?/p>

涓嶈繃閬囧埌涓鐐瑰皬闂錛岀敤vc2003鎵撳紑閭d釜solution鐨勬椂鍊欙紝鍙戠幇浣滆呮病鏈夋妸source code control鍘繪帀錛岄儊闂鳳紒瀹崇殑鎴?/p>

浠墦寮鐨勬椂鍊欎竴鍫唌essagebox銆備笉榪囦笉鐢ㄧ瀹冨氨濂戒簡錛屼竴鐩寸‘瀹氥傛渶鍚庤瘯浜嗕竴涓嬮偅涓猵ython25_d.lib錛屾病闂銆備笉榪囪

寰楁妸python25_d.dll copy鍒頒竴涓兘琚壘鍒扮殑鐩綍錛屾瘮濡傝c:\windows\system32\涓嬮潰銆俻ython25.dll涔熷湪榪欎釜鐩綍涓?/p>

闈€俹ver銆傛仼銆?/p>

 



kk 2007-05-17 15:16 鍙戣〃璇勮
]]>
c++涓祵鍏ython鍏ラ棬2http://www.shnenglu.com/jacky2019/archive/2007/05/17/24276.htmlkkkkThu, 17 May 2007 03:28:00 GMThttp://www.shnenglu.com/jacky2019/archive/2007/05/17/24276.htmlhttp://www.shnenglu.com/jacky2019/comments/24276.htmlhttp://www.shnenglu.com/jacky2019/archive/2007/05/17/24276.html#Feedback0http://www.shnenglu.com/jacky2019/comments/commentRss/24276.htmlhttp://www.shnenglu.com/jacky2019/services/trackbacks/24276.html1. 涓涓湁涓涓弬鏁扮殑渚嬪瓙

python鏂囦歡
#Filename test2.py

def Hello(s):
    print "Hello, world!"
    print s

cpp鏂囦歡
#include <python.h>
int main()
{
 Py_Initialize();

 PyObject * pModule = NULL;
 PyObject * pFunc   = NULL;
 PyObject * pArg    = NULL;

 pModule = PyImport_ImportModule("test2");
 pFunc   = PyObject_GetAttrString(pModule, "Hello");
 pArg    = Py_BuildValue("(s)", "function with argument");

 PyEval_CallObject(pFunc, pArg);

 Py_Finalize();

 return 0;
}

娉ㄦ剰錛屽弬鏁拌浠uple鍏冪粍褰㈠紡浼犲叆銆傚洜涓鴻繖涓嚱鏁板彧瑕佷竴涓弬鏁幫紝鎵浠ユ垜浠洿鎺ヤ嬌鐢?s)鏋勯犱竴涓厓緇勪簡銆?/p>

2. 涓涓湁涓や釜鍙傛暟鐨勪緥瀛?/p>

python鏂囦歡涓姞鍏ヤ互涓嬩唬鐮侊紝涓涓姞鍑芥暟
def Add(a, b):
    print "a+b=", a+b

cpp鏂囦歡錛屽彧鏀逛簡涓よ錛屾湁娉ㄩ噴鐨勯偅涓よ
#include <python.h>
int main()
{
 Py_Initialize();

 PyObject * pModule = NULL;
 PyObject * pFunc   = NULL;
 PyObject * pArg    = NULL;

 pModule = PyImport_ImportModule("test2");
 pFunc   = PyObject_GetAttrString(pModule, "Add");//緇堜簬鍛婂埆hello world浜嗭紝寮濮嬩嬌鐢ㄦ柊鐨勫嚱鏁?br> pArg    = Py_BuildValue("(i,i)", 10, 15);//鏋勯犱竴涓厓緇?/p>

 PyEval_CallObject(pFunc, pArg);

 Py_Finalize();

 return 0;
}

鍏跺畠鐨勫氨綾諱技浜嗐傘傘傚熀鏈笂錛屾垜浠煡閬撲簡鎬庝箞鍦╟++涓嬌鐢╬ython涓殑鍑芥暟銆傛帴涓嬫潵瀛︿範涓涓嬪浣曚嬌鐢╬ython涓殑

class銆?/p>

闄勶細Py_BuildValue鐨勪嬌鐢ㄤ緥瀛愶紝鏉ヨ嚜python documentation錛?/p>

    Py_BuildValue("")                        None
    Py_BuildValue("i", 123)                  123
    Py_BuildValue("iii", 123, 456, 789)      (123, 456, 789)
    Py_BuildValue("s", "hello")              'hello'
    Py_BuildValue("ss", "hello", "world")    ('hello', 'world')
    Py_BuildValue("s#", "hello", 4)          'hell'
    Py_BuildValue("()")                      ()
    Py_BuildValue("(i)", 123)                (123,)
    Py_BuildValue("(ii)", 123, 456)          (123, 456)
    Py_BuildValue("(i,i)", 123, 456)         (123, 456)
    Py_BuildValue("[i,i]", 123, 456)         [123, 456]
    Py_BuildValue("{s:i,s:i}",
                  "abc", 123, "def", 456)    {'abc': 123, 'def': 456}
    Py_BuildValue("((ii)(ii)) (ii)",
                  1, 2, 3, 4, 5, 6)          (((1, 2), (3, 4)), (5, 6))



kk 2007-05-17 11:28 鍙戣〃璇勮
]]>
c++涓祵鍏ython鍏ラ棬1http://www.shnenglu.com/jacky2019/archive/2007/05/17/24269.htmlkkkkThu, 17 May 2007 03:03:00 GMThttp://www.shnenglu.com/jacky2019/archive/2007/05/17/24269.htmlhttp://www.shnenglu.com/jacky2019/comments/24269.htmlhttp://www.shnenglu.com/jacky2019/archive/2007/05/17/24269.html#Feedback6http://www.shnenglu.com/jacky2019/comments/commentRss/24269.htmlhttp://www.shnenglu.com/jacky2019/services/trackbacks/24269.html鏈漢鏄敤vc2003+python2.5瀛︿範鐨勶紝鍏跺畠鐨勪篃搴旇宸笉浜嗗灝?/p>

0. 鍧忓璁劇疆
鎶妏ython鐨刬nclude/libs鐩綍鍒嗗埆鍔犲埌vc鐨刬nclude/lib directories涓幓銆傚彟澶栵紝鐢變簬python娌℃湁鎻愪緵debug lib錛屼綋鍦拌錛屽氨鏄病鏈夋彁渚沺ython25_d.lib浜嗐備綘鍙互鑷繁緙栬瘧python鐨勬簮浠g爜鏉ュ緱鍒皃ython25_d.lib鐨勶紝鍋惰繕娌¤瘯榪囷紝鍛靛懙銆傝屼笖緗戜笂鎵句簡涓涓嬩篃娌′笅杞藉埌銆傛墍浠ワ紝濡傛灉浣犳兂瑕佸湪debug涓嬭繍琛岀▼搴忕殑璇濓紝浣犺鎶妏yconfig.h錛堝湪python25/include/鐩綍涓嬶級鐨勫ぇ姒傛槸鍦?83琛岋紝鎶妏ragma comment(lib,"python25_d.lib")鏀規垚pragma comment(lib,"python25.lib")錛岃python閮戒嬌鐢ㄩ潪debug lib.

1. 寮濮嬬紪紼嬩簡
#include <python.h>
絎竴姝ュ氨鏄寘鍚玴ython鐨勫ご鏂囦歡

2. 鐪嬩竴涓緢綆鍗曠殑渚嬪瓙
1)python鏂囦歡test.py錛屽緢綆鍗曠殑瀹氫箟浜嗕竴涓嚱鏁?/p>

#Filename test.py
def Hello():
    print "Hello, world!"

榪欎釜搴旇鑳界湅鎳傜殑鍚э紵鍚﹀垯鐨勮瘽錛屽洖鍘誨啀緇冪粌python鍚э紝鍛靛懙銆傘婄畝鏄嶱ython鏁欑▼銆婼waroop, C. H. 钁椼傛矆媧佸厓  璇戙?/p>


2)cpp鏂囦歡

#include <python.h> //鍖呭惈澶存枃浠訛紝鍦╟++涓祵鍏ython錛岃繖鏄繀欏葷殑
int main()
{
 Py_Initialize();

 PyObject * pModule = NULL;
 PyObject * pFunc   = NULL;

 pModule = PyImport_ImportModule("test");
 pFunc   = PyObject_GetAttrString(pModule, "Hello");
 PyEval_CallObject(pFunc, NULL);

 Py_Finalize();

 return 0;
}

絎竴姝ヨ繕鏄寘鍚ご鏂囦歡

絎簩姝ワ紝浣跨敤python涔嬪墠錛岃璋冪敤Py_Initialize();榪欎釜鍑芥暟榪涜鍒濆鍖栥?br>甯姪鏂囨。涓鏄錛?br>The basic initialization function is Py_Initialize(). This initializes the table of loaded modules, and creates the fundamental modules __builtin__, __main__, sys, and exceptions. It also initializes the module search path (sys.path).

鍙嶆錛屼竴寮濮嬩綘涓瀹氳璋冪敤銆?/p>

絎笁姝ワ紝澹版槑涓浜汸ython鐨勫彉閲忥紝PyObject綾誨瀷鐨勩傚叾瀹炲0鏄庝篃鍙斁鍦ㄥ墠闈紝榪欎釜鍊掓槸鏃犳墍璋撶殑銆?/p>

絎洓姝ワ紝import module錛屼篃灝辨槸浣犵殑鑴氭湰鍚嶅瓧錛屼笉闇瑕佸姞鍚庣紑鍚嶏紝鍚﹀垯浼氬嚭閿欑殑銆?/p>

絎簲姝ワ紝浠庝綘import榪涙潵鐨刴odule涓緱鍒頒綘瑕佺殑鍑芥暟
 pFunc   = PyObject_GetAttrString(pModule, "Hello");
涓婇潰鐨勪緥瀛愬凡緇忓娓呮鐨勪簡錛屾渶鍚庝竴涓槸浣犺寰楀埌鐨勫嚱鏁扮殑鍚嶅瓧

絎叚姝ワ紝璋冪敤PyEval_CallObject鏉ユ墽琛屼綘鐨勫嚱鏁幫紝絎簩涓弬鏁頒負鎴戜滑瑕佽皟鐢ㄧ殑鍑芥暟鐨勫嚱鏁幫紝鏈緥瀛愪笉鍚弬鏁幫紝鎵浠ヨ緗負NULL銆?/p>

絎竷姝ワ紝璋冪敤Py_Finalize錛岃繖涓牴Py_Initialize鐩稿搴旂殑銆備竴涓湪鏈鍓嶉潰錛屼竴涓湪鏈鍚庨潰銆?/p>

 

絎竴嬈″啓鏁欑▼銆傝繖涓緥瀛愰潪甯哥畝鍗曪紝鏈漢涔熻繕鍦ㄥ涔犲綋涓樋錛屽彧鑳戒繚璇佸ぇ瀹惰兘澶熸妸榪欎釜渚嬪瓙榪愯璧鋒潵銆傚緩璁ぇ瀹跺幓鐪媝ython鐨刣ocumentaion錛岄噷闈㈡湁璁叉庝箞embedding python鐨勩傚厛鍐欏埌榪欓噷錛屽叾瀹炵洰鍓嶄篃鍙鍒拌繖涔堝錛屽懙鍛點備笅嬈″浜嗘洿澶氫互鍚庡啀鍐欍侽ver銆傛仼銆?/p>

 



kk 2007-05-17 11:03 鍙戣〃璇勮
]]>
sighhttp://www.shnenglu.com/jacky2019/archive/2007/05/08/23647.htmlkkkkTue, 08 May 2007 13:14:00 GMThttp://www.shnenglu.com/jacky2019/archive/2007/05/08/23647.htmlhttp://www.shnenglu.com/jacky2019/comments/23647.htmlhttp://www.shnenglu.com/jacky2019/archive/2007/05/08/23647.html#Feedback0http://www.shnenglu.com/jacky2019/comments/commentRss/23647.htmlhttp://www.shnenglu.com/jacky2019/services/trackbacks/23647.html

kk 2007-05-08 21:14 鍙戣〃璇勮
]]>
The difference between GetDC and GetWindowDChttp://www.shnenglu.com/jacky2019/archive/2007/04/21/22467.htmlkkkkSat, 21 Apr 2007 04:54:00 GMThttp://www.shnenglu.com/jacky2019/archive/2007/04/21/22467.htmlhttp://www.shnenglu.com/jacky2019/comments/22467.htmlhttp://www.shnenglu.com/jacky2019/archive/2007/04/21/22467.html#Feedback0http://www.shnenglu.com/jacky2019/comments/commentRss/22467.htmlhttp://www.shnenglu.com/jacky2019/services/trackbacks/22467.htmlGetDC

The GetDC function retrieves a handle of a display device context (DC) for the client area of the specified window. The display device context can be used in subsequent GDI functions to draw in the client area of the window.

This function retrieves a common, class, or private device context depending on the class style specified for the specified window. For common device contexts, GetDC assigns default attributes to the device context each time it is retrieved. For class and private device contexts, GetDC leaves the previously assigned attributes unchanged.

HDC GetDC(

    HWND hWnd                 // handle of window 

   );         

Parameters

hWnd

Identifies the window whose device context is to be retrieved.

 

GetWindowDC

The GetWindowDC function retrieves the device context (DC) for the entire window, including title bar, menus, and scroll bars. A window device context permits painting anywhere in a window, because the origin of the device context is the upper-left corner of the window instead of the client area.

GetWindowDC assigns default attributes to the window device context each time it retrieves the device context. Previous attributes are lost.

HDC GetWindowDC(

    HWND hWnd                 // handle of window 

   );         

Parameters

hWnd

Identifies the window with a device context that is to be retrieved.



kk 2007-04-21 12:54 鍙戣〃璇勮
]]>
姹俷!鐨勭粨鏋滀腑鏈熬0鐨勪釜鏁?/title><link>http://www.shnenglu.com/jacky2019/archive/2007/04/19/22306.html</link><dc:creator>kk</dc:creator><author>kk</author><pubDate>Thu, 19 Apr 2007 07:30:00 GMT</pubDate><guid>http://www.shnenglu.com/jacky2019/archive/2007/04/19/22306.html</guid><wfw:comment>http://www.shnenglu.com/jacky2019/comments/22306.html</wfw:comment><comments>http://www.shnenglu.com/jacky2019/archive/2007/04/19/22306.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.shnenglu.com/jacky2019/comments/commentRss/22306.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/jacky2019/services/trackbacks/22306.html</trackback:ping><description><![CDATA[<p><span>緇堜簬鎮熷埌浜嗐?/span></p> <p><span>棣栧厛錛屽緢瀹規槗鎯沖埌鐨勫氨鏄紝姹?/span>0<span>鐨勪釜鏁幫紝灝辨槸姹?/span>5<span>鐨勪釜鏁幫紙濡傛灉榪欎釜浣犻兘鎯充笉鏄庣櫧鐨勮瘽錛岄偅灝便傘傘傚啀濂藉ソ鎯蟲兂鍚э紝鍛靛懙錛夛紱</span></p> <p><span>鎺ヤ笅鏉ワ紝濡備綍姹?/span>5<span>鐨勪釜鏁板憿錛熷鏋滈亶鍘嗕竴閬嶇殑璇濓紝閭f樉鐒舵槸澶參浜嗭紒鍥犱負榪欑璁$畻棰樺お鏈夎寰嬩簡錛佹兂浜嗗ソ涔咃紝緇堜簬鎯沖嚭鏉ヤ簡錛?/span></p> <p>Result = 0; // <span>鏈鍚庣殑緇撴灉</span></p> <p>while ( N >= 5 )</p> <p>{</p> <p> N /= 5;</p> <p> Result += N;</p> <p>}</p> <p>// <span>緇撴潫浜嗐?/span></p> <p> </p> <p><span>娌¢敊錛屽氨鏄繖涔堢畝鍗曪紒涓嬮潰綆鍗曡璇翠負浠涔堣繖鏍峰瓙鍋氭槸瀵圭殑錛堝伓灝忚瘯浜嗕竴涓嬶紝娌¢棶棰橈紝鍛靛懙錛夛細</span></p> <p><span>絎竴嬈¢櫎浠?/span>5<span>琛ㄧず</span>5<span>鐨勫嶆暟鐨勪釜鏁幫紝</span></p> <p><span>絎簩嬈¢櫎浠?/span>5<span>琛ㄧず</span>5<span>鐨勫鉤鏂圭殑鍊嶆暟鐨勪釜鏁幫紝錛堟樉鐒訛紝</span>5<span>鐨勫鉤鏂規殫鍚簡涓や釜</span>0<span>錛?/span></p> <p><span>銆傘傘備緷姝ょ被鎺?/span></p> <p><span>鏈鍚庡綋</span>N<5<span>浜嗭紝緇撴潫銆?/span></p> <p> </p> <p><span>灝忓皬鐨勯獙璇佷竴涓嬶細</span></p> <p>26<span>錛?/span></p> <p>26/5 = 5<span>錛?/span> 5/5 = 1<span>錛岄偅涔堟渶鍚?/span>0<span>鐨勪釜鏁板氨鏄?/span>6<span>浜嗐傜敤</span>Google<span>綆椾簡涓涓嬶紝緇撴灉</span>G<span>澶у彅鐩存帴鐢ㄦ湁鏁堟暟瀛楄〃紺轟簡錛?/span>@$%$%@$%<span>銆傘傘備笉榪囧簲璇ユ槸娌¢敊浜嗐傛仼銆?/span></p> <p>Sigh<span>錛岀煡閬撶粨鏋滃悗鎵嶇煡閬撳師鏉ヨ繖涔堢畝鍗曠殑闃匡紝鍋跺湡浜嗐?/span></p> <img src ="http://www.shnenglu.com/jacky2019/aggbug/22306.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/jacky2019/" target="_blank">kk</a> 2007-04-19 15:30 <a href="http://www.shnenglu.com/jacky2019/archive/2007/04/19/22306.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>48 Ways to Wisdom - Way 4, Introduce Yourself to Yourselfhttp://www.shnenglu.com/jacky2019/archive/2007/04/18/22222.htmlkkkkWed, 18 Apr 2007 08:22:00 GMThttp://www.shnenglu.com/jacky2019/archive/2007/04/18/22222.htmlhttp://www.shnenglu.com/jacky2019/comments/22222.htmlhttp://www.shnenglu.com/jacky2019/archive/2007/04/18/22222.html#Feedback4http://www.shnenglu.com/jacky2019/comments/commentRss/22222.htmlhttp://www.shnenglu.com/jacky2019/services/trackbacks/22222.htmlDid you ever get on a train going somewhere, only to find that you're headed in the wrong direction?

The same thing happens in life. We set goals and make plans - and sometimes discover that we're on "the wrong train."

Bi-vinat ha-lave literally means "understanding the heart." The heart is the seat of emotions. We say: "My heart is heavy, my heart is lifted, my heart is broken," etc. To understand your heart is to understand your true inner self.

Many people go through life making assumptions about who they are. They never take time to "meet" themselves. Don't be afraid of discovering that the "real you" may be different than the "current you."

Often a crisis hits at midlife when people ask: "What's my life about? Is this all worth it?" We've heard stories of people who suddenly change direction, quitting their job and getting divorced. You know, like the successful doctor who decides he never wanted to go into medicine in the first place -- so he drops it and becomes an artist.

Knowing yourself is the essence of being alive. If you don't know yourself, you are not living. If you don't know what makes you tick, you're a robot, a puppet, a zombie.

So don't wait for a crisis. Life is too short to take wrong trains.

GETTING STARTED

Think of someone you'd be fascinated to meet, someone you'd really like to find out what makes him tick.

Now realize the most fascinating person you could ever meet is ... yourself.

Sit down, say hello, and introduce yourself to yourself. Become familiar with yourself as if you'd just met a long-lost cousin. Interview yourself. Ask questions about your life and the direction you're going. Search out your dreams -- both the ones you're fulfilling and the ones you've pushed to the back of your mind.

Get down to basics. You want to be rich. You want to be famous. You want to be good. You want to accomplish. You want meaning. You want to be creative. But why do you want all this? What's driving you? What you really want out of life?

The process of self-discovery involves asking a series of questions, always probing deeper until the underlying truth emerges. Ask yourself 10 questions that you would ask an intimate friend. Then wait for answers. Don't worry, no one is going to poke fun at you.

  1. What is the purpose of life?
  2. What is my goal in life?
  3. Why did I choose this career?
  4. How do I spend my spare time?
  5. What is my motivation for doing what I do?
  6. What really makes me happy?
  7. Am I as happy as I want to be?
  8. Is it more important to be rich or to be happy?
  9. What are my future plans? Why?
  10. What are my secret dreams and ambitions?

Don't be surprised if the answers aren't immediate. This process can take many months. Stick with it and find out what makes you tick. The answers are hiding in there. After all, you have a fascinating partner.

Finally, the most important question to ask is:

"What am I living for?"

It sounds like a simple question, but many are embarrassed to ask it. A voice inside us says, "Nah, why ask such a basic question?" We're resistant because we know this requires a lot of difficult soul-searching. And when you thoroughly know yourself, then you have changed. You've changed your relationship with yourself and the world.

CONFIDENCE IN DECISION-MAKING

People often avoid making decisions out of fear of making a mistake.

Actually, the failure to make decisions is one of life's biggest mistakes.

Imagine the beggar who receives a letter saying that he's inherited a million dollars. If he doesn't read the letter, is he rich ... or not?

Similarly, God gave us the free will to make choices in life and achieve greatness. But if we're not aware of our free will, then we don't really have it. And then we wind up blaming others when things go wrong -- even though we know the decision is really up to us.

If you're not using your potential, it wears away at your confidence. Do you know what your potential is? Have you tried to use it? You have to tackle life. You haven't given up yet, have you? Let's get on with the game, with the business of really living, of not just "going through the motions."

Know the difference between "making decisions" and just floating, falling into place. Did you choose to go to college? Or perhaps you had nothing to do with the decision. Was it something you just did because you graduated high school and everybody else was doing it? Did you think it through and actually make a decision?

Imagine this private conversation of a college student:

Why am I going to college?
To get a degree.
Why?
Because I want to get into a good graduate school.
Why?
So I'll get a good job.
Why?
So I can pay back my college loans!

Through the process of questioning, he reveals a logical fault in his motivation. Really, the primary reason for going to college should be to acquire wisdom, knowledge and information. In other words, to get an education!

Now try the process yourself, using this example:

Why do I want to get married?

Don't accept pat answers. Keep asking "Why, why why?" Be frank. It's yourself. Ask any question you like. Be patient and persistent. Eventually you'll get an answer.

When you thoroughly analyze an issue, then you can make wise decisions with confidence.

Identify where you lack confidence. What makes you nervous? What situations inhibit you from being yourself? Why can't you make decisions? Is it that you don't know how to make decisions? Or that you doubt your decisions after they're made? Or you just don't feel like making decisions?

Enjoy making decisions. Deal with the world you live in. That's loving the dynamics of life.

ISOLATE YOUR BLOCKS

Anytime you find it difficult to achieve a goal, figure out what's holding you back.

Everyone has problems. Being aware of these problems is the key to getting in touch with yourself. Because as long as you don't face problems, they fester and bug you from behind.

Write your "blocks" on a piece of paper. That's a good step in the right direction. By isolating specific obstacles, you turn them into concrete challenges that require solutions.

Ask yourself:

  • Am I lazy? Why?
  • Am I disorganized? Why?
  • Do I get angry? When?
  • Why do ever I get defensive? About what?
  • What makes me jealous?
  • What makes me arrogant?
  • Do I have trouble making decisions? Why?
  • Do I lack self-discipline?
  • Do I lack self-confidence?
  • Why don't I take more initiative?

Negative character traits are the roots of our problems. Make a list of your negative traits, and identify when they affect you the most. Then analyze what triggers these reactions in you. Finally, formulate an effective counter-approach.

Working through this takes time. But do you have anything better to be doing right now?

READ YOUR EMOTIONS

Get in touch with your emotional state. Take a reading of how you feel. Happy? Angry? Tense? Sad? Emotions are a measuring stick for what's going on below the surface. It's like taking your temperature. If you're sick, you need to be aware so you can fix the problem.

Find out why you're upset. Who or what is pressuring you? Is it an internal or an external problem? Identify it.

Let's say you are irritated. Why?

Because the boss chewed me out.
So why am I irritated?
Because I resent him.
So what? Why does that bother me?
Because I feel I am no good.
I'm no good? He's nuts!

Get out of yourself and track it down. If you don't, it's just irritation. And the next thing you know, you'll go home and yell at your kids.

Once you've identified what causes negative feelings, adjust yourself to minimize the impact. Either avoid these situations, or prepare yourself to handle them when they arise.

Further, root out negative motivations that corrupt your behavior. Let's say that you give charity. Why? One motivation is to help humanity. Another is the pleasure of being constructive. A third is the desire to do the right thing. These are all positive motivations. A negative motivation for giving charity is: "I want people to admire me." That's corruptive.

The next time you give charity, do so anonymously. Eliminate the wrong reasons. They are destructive.

The same goes with the positive emotions. Be aware of how your emotional state affects decisions. For example, don't buy a new stereo when you're in a euphoric mood. Wait. Think it over. You are susceptible.

Pinpoint what makes you happy. You can have more joy on a daily basis by formulating some practical applications. You got up in the morning, it's a gorgeous day and you feet great. You're energized. Now take that feeling and teach yourself how to get up on the right side -- every day!

Another example: You did a good job and got the boss's compliment. Now focus: Do you need the boss to tell you did a good job? No! Create your own pleasure out of doing a good job.

GET IN TOUCH WITH YOUR TWO SIDES

Everyone has an urge for greatness. We want self respect, power, fame. We want to accomplish, to be strong, to do the right thing, to even save the world.

Yet at the same time, we have a counter-urge to run away from responsibility, to get into bed and crawl under the covers.

Someone may say, "Life is beautiful," but he doesn't feel it. His emotions hold him back and he walks around going, "Ugh, life is a burden."

Recognize the volcano of conflict within you: What you truly "want," versus what you "feel" like. This is the conflict between body and soul.

Once you appreciate the dichotomy, you can identify at any moment whether your body or soul is talking. This makes it possible to live with sanity and choose the right thing.

The next step is to make peace between your two sides. The easiest way is to squash your drive to be great. But life is not about taking the easy way out. Just because you feel uncomfortable about an idea doesn't mean it's wrong for you. It's hard to break habits, and growth can be frightening.

For example, would you rather be happy or rich? Okay, you'd rather be happy. Now imagine this exchange:

"Come on, I'll teach you how to be happy. All it requires is effort and change."

"Oh, I'd love to, but I can't right now. It's impossible. I've got a flight to catch."

"Really? I'll pay you $10,000 a week to work on happiness."

"Sure! Where do I sign up?"

"Oh, but I thought you can't right now..."

We conceal our problems with rationalization: "I'll wreck my mind thinking about what life is about! Nobody really knows what life is about. It's not going to work. Nothing can be done about it anyway. I don't really care. It's not worth the time!"

The Sages say that a person only makes a mistake when overcome by a moment of insanity. So realize that you are fighting "insanity." It is not logical. You've got to be on guard. Because if you get off track, you'll pay for it down the road.

So ... do you want to change? What have you got against it? Feel the antipathy of the body. We are so darn lazy. The body just wants to sleep. "Aaaah ... I don't want to change. I'm happy enough. I'm comfortable in my niche of misery." Are you rich enough? No! So are you happy enough?

You see the importance of tracking that down? You have to identify the animal you are fighting. "The dread of change."

If you're alert, you see the enemy. You can fight it. You may lose a struggle with the body, but at least you have your confidence. "I know what I am doing."

COAX THE BODY

Get in touch with your spiritual core. Know what is driving you. Don't let free will be a subconscious thing. You want greatness. But the body says that's too much effort.

To try to convince the body, try to identify the tangible benefit. "Why is it necessary? What will it do for me?" You have to bring it home to emotional realization. "What do I lose?" What do I gain?" Only then will the idea have power. And you'll get out there and do it.

Here's the secret formula: Identify with your intellect, and coax your heart along. For example, if you're emotionally convinced of the benefit of getting into shape, then even when you break out in a cold sweat and your heart is doing palpitations, you will keep going. Because you have decided, "I want this," you know it is important.

To avoid negative backlash, your emotions have to feel comfortable with the changes you make. Learn to relax and reassure the body. Cajole the body and say, "It won't be so bad. Remember the last time you made an effort, how great you felt!" Be encouraging and reward yourself for success.

Don't say it doesn't work. You haven't made the effort. Don't give up on your intuition and perception. Just realize you haven't yet brought it home to actualization.

Consider how the basic human drives affect you: security, self-respect, honor, passions, social pressure, and possessions. Pay particularly close attention to how you accept responsibility. Let's say that you made a mistake. You want to apologize in a full and forthright manner. Yet you feel like forgetting the whole thing, hiding, running away and saying "it's not my fault."

This is the volcano. We want to be tough, dedicated and powerful -- yet we feel like being marshmallows. Choosing the path of the soul doesn't come naturally. It takes a lot of time and hard work.

KNOW WHAT YOU KNOW

Don't think that just because you understand something, you are living with it. It is possible to believe one way, and yet act another. It happens to us all the time. You can believe it's important to eat healthy food, yet gorge yourself on French fries and chocolate cake.

Our actions are determined by our level of clarity. If we understand an idea on just a superficial level, then we'll have difficulty sticking to it when the going gets tough.

Next time you go to a funeral, watch carefully. When they remove the body from the chapel, the mourners start to cry. Are they crying because they want to body to stay there?! No. All of a sudden there is a realization of death, that he won't be coming back. At the cemetery, they lower the casket into the ground and the mourners cry again. It's the emotional realization that death is final now.

Until you align your feelings with reality, you are in dreamland. Growth begins in the mind, but your heart has to buy into everything your mind discovers. Only then will you integrate these ideas into day-to-day life.

A lot of people believe in God. There are very few people who live with God. Does that make sense? You have to assimilate something that you've accepted as true. It has to become part of you.

FIVE-FINGER CLARITY

You've got to know yourself cold, just like you know your hand has five fingers. How do you know you are on the right path? How do you know you're not making a mistake right now?

To develop this clarity, articulate the important principles that guide your life. For example, in Judaism we say that love is an obligation. Is this reasonable? Work the issue through with yourself:

"Ridiculous. You can't obligate me to love."
"But if I have children, will I love them?"
"Of course I'm going to love my kids!"
"How do I know? I don't know what kind of kids I'm going to have. Maybe they'll be brats and I won't love them."
"I will. I'm obligated to love my children."

Do you see the contradiction? On an intuitive level, you know that love is an obligation. But the concept is not so clear that you can articulate it.

Take your time. Sort out the basic aspects of living. Ask yourself important questions about life's global and spiritual issues.

--?What is the meaning of existence?
--?What's good about living?
--?How do I feel about humanity?
--?What is the afterlife?
--?How do I understand good versus evil?
--?Do I have free will? How do I activate it?
--?What makes me sad? Is it okay to be sad?
--?How do I feel about God?
--?Am I proud to be a Jew?
--?How do I understand the Holocaust?

Some of these topics may be unpleasant to think about. If so, why is it unpleasant? Track it down.

Don't just use slogans to parrot things that you heard. Know why you are doing what you are doing. Otherwise, it's just society talking. You may have adopted part of society without analyzing its validity. Check it out.

Work through all the issues until you have "five-finger clarity." A human being who knows what he wants will get there. By hook or by crook. It's like a homing mechanism on a missile. If you program it right, you will get there.

WHY IS "KNOWING YOURSELF" AN INGREDIENT IN WISDOM?

  • You can know truth if you look honestly into yourself.
  • Emotions are powerful forces of greatness. Know them. Harness them.
  • Identify your problems. It's the beginning of solving them.
  • If you don't get it straight now, you're bound to make some bad mistakes.
  • Don't be afraid of finding out who you really are.
  • Use your free will as a conscious tool for better living.
  • If you're angry or upset, track it down. What's the root?
  • If you're acting illogically, at least acknowledge that to yourself!
  • The key to sanity is letting truth into the body.
  • You can't afford to wait too long to get to know yourself. Because you are the most fascinating person you'll ever meet.

 



kk 2007-04-18 16:22 鍙戣〃璇勮
]]>
鍔ㄦ佽璦http://www.shnenglu.com/jacky2019/archive/2007/04/16/22034.htmlkkkkMon, 16 Apr 2007 10:15:00 GMThttp://www.shnenglu.com/jacky2019/archive/2007/04/16/22034.htmlhttp://www.shnenglu.com/jacky2019/comments/22034.htmlhttp://www.shnenglu.com/jacky2019/archive/2007/04/16/22034.html#Feedback1http://www.shnenglu.com/jacky2019/comments/commentRss/22034.htmlhttp://www.shnenglu.com/jacky2019/services/trackbacks/22034.html鎵璋撳姩鎬佽璦錛屼篃鍙剼鏈璦錛屽氨鏄涓縐嶅湪鎵ц鏈熼棿鎵嶅幓鍙戠幇鏁版嵁綾誨瀷鐨勭▼搴忚璁¤璦錛屼富瑕佸垱寤轟竴浜涢渶瑕?/strong>緇忓父鏇存柊鐨勫姩鎬佺郴緇熴?/span>甯歌鐨勬湁Python, Lua, Perl, PHP絳夈?/span>

浠ュ線錛屾垜浠墍浣跨敤鐨勮璦錛屾瘮濡?/span>C錛?/span>C++絳夌瓑錛岄兘縐頒負闈欐佽璦銆備粈涔堟槸闈欐佽璦鍛紵灝辨槸璇達紝鍦ㄤ嬌鐢ㄦ暟鎹箣鍓嶏紝鎴戜滑蹇呴』棣栧厛瀹氫箟鏁版嵁綾誨瀷錛岃繖浜涙暟鎹被鍨嬪寘鎷?/span>int, float, double絳夌瓑銆傚氨鐩稿綋浜庡湪浣跨敤瀹冧滑涔嬪墠錛岄鍏堣涓哄畠浠垎閰嶅ソ鍐呭瓨絀洪棿錛涜屽姩鎬佽璦灝卞垰鍒氭槸鐩稿弽鐨勶紝瀹冩槸鍦ㄥ緱鍒版暟鎹被鍨嬩箣鍚庯紝鍐嶄負瀹冨垎閰嶅唴瀛樼┖闂淬?/span>

“鑴氭湰璇█闄や簡鎺ヨ繎鍙h鍖栫殑璁捐澶栵紝鍙﹀姞涓婄畝鍖栧悗鐨勮娉曘傦紙闄や簡鍐呭緩鐨勫懡浠ゅ錛岄氬父浠呴渶綆鍗曠殑閫昏緫鍒ゆ柇涓庢暟鍊艱綆楀嵆鍙儨浠伙級鍥犳鐢ㄨ剼鏈璦鍒朵綔娓告垙錛屼笉鍐嶆槸闈炵▼搴忓憳涓嶅彲鐨勫伐浣滐紙闄や簡緋葷粺鏈韓鐨勪慨璁級錛屼紒鐢諱漢鍛樹篃鍙互寰堝揩鍦拌繘鍏ョ姸鎬併傚彟澶栵紝濡傛灉灝嗘潵闇瑕佸皢娓告垙縐繪鍒板叾浠栧鉤鍙版椂錛屾瘮璧風▼搴忎笌璧勬枡鐨勭洏鏍歸敊鑺傜殑璁捐錛屽埄鐢ㄨ剼鏈璦鏉ュ紑鍙戠殑娓告垙錛屽彧闇瑕佷慨鏀圭郴緇熸湰韜紝鑴氭湰璇█閮ㄥ垎鏈韓姣嬮』鏇村姩錛岀浉褰箣涓嬪嚭鐜伴棶棰樼殑鏈轟細涓庤寖鍥村氨緙╁皬浜嗗緢澶氥?/span>



kk 2007-04-16 18:15 鍙戣〃璇勮
]]>
鍚嶈█http://www.shnenglu.com/jacky2019/archive/2007/04/13/21808.htmlkkkkFri, 13 Apr 2007 08:42:00 GMThttp://www.shnenglu.com/jacky2019/archive/2007/04/13/21808.htmlhttp://www.shnenglu.com/jacky2019/comments/21808.htmlhttp://www.shnenglu.com/jacky2019/archive/2007/04/13/21808.html#Feedback0http://www.shnenglu.com/jacky2019/comments/commentRss/21808.htmlhttp://www.shnenglu.com/jacky2019/services/trackbacks/21808.html

kk 2007-04-13 16:42 鍙戣〃璇勮
]]>
Intel.VTune.Performance.Analyzer.v8.0.014.ISO涓嬭澆http://www.shnenglu.com/jacky2019/archive/2007/04/13/21797.htmlkkkkFri, 13 Apr 2007 08:07:00 GMThttp://www.shnenglu.com/jacky2019/archive/2007/04/13/21797.htmlhttp://www.shnenglu.com/jacky2019/comments/21797.htmlhttp://www.shnenglu.com/jacky2019/archive/2007/04/13/21797.html#Feedback2http://www.shnenglu.com/jacky2019/comments/commentRss/21797.htmlhttp://www.shnenglu.com/jacky2019/services/trackbacks/21797.htmlhttp://down.gogobox.com.tw/kisser/7ir3
涓嬭澆鐨勬椂鍊欒瀹夎涓涓狝ctiveX鎻掍歡鐨勩?br>

kk 2007-04-13 16:07 鍙戣〃璇勮
]]>
Finding crash information using the MAP file 2http://www.shnenglu.com/jacky2019/archive/2007/04/10/21584.htmlkkkkTue, 10 Apr 2007 03:27:00 GMThttp://www.shnenglu.com/jacky2019/archive/2007/04/10/21584.htmlhttp://www.shnenglu.com/jacky2019/comments/21584.htmlhttp://www.shnenglu.com/jacky2019/archive/2007/04/10/21584.html#Feedback0http://www.shnenglu.com/jacky2019/comments/commentRss/21584.htmlhttp://www.shnenglu.com/jacky2019/services/trackbacks/21584.htmlFinding crash information using the MAP file
http://www.shnenglu.com/jacky2019/archive/2007/04/09/21527.html
涓婃枃涓殑鍏充簬灝忚鏄庣殑絎?/span>2鐐規槸鏈夐棶棰樼殑

鍋跺張璇曚簡涓嬈★紝鍙戠幇lines number鍙兘鏄湁闂鐨勶紝鑰屼笖涔熶笉鏄垜鐨勯偅縐嶇畻娉曘備笉榪囧嚱鏁板悕鑲畾鏄鐨?br>
鍦╲ckbase涓張鍙戠幇涓綃囧ソ鏂囷紝鎵浠ュ氨鍙堣創榪囨潵浜嗐備笉榪囧彲鎯滅殑鏄紝榪樻槸娌¤兘瑙e喅dll鐨勫湴鍧鏄犲皠闂錛屾棤娉晅rack鍒癲ll鍐呯殑淇℃伅錛屽彲鎯滀簡銆?br>

瀵?#8220;浠呴氳繃宕╂簝鍦板潃鎵懼嚭婧愪唬鐮佺殑鍑洪敊琛?#8221;涓鏂囩殑琛ュ厖涓庢敼榪?/strong>

浣滆咃細涓婃搗浼熷姛閫氫俊 roc

涓嬭澆婧愪唬鐮?/font>

銆銆璇諱簡鑰佺綏鐨?#8220;浠呴氳繃宕╂簝鍦板潃鎵懼嚭婧愪唬鐮佺殑鍑洪敊琛?/font>”(涓嬬О"緗楁枃")涓鏂囧悗錛屾劅瑙夎鏂囪繕鏄彲浠ュ鍒頒笉灝戜笢瑗跨殑銆備笉榪囨枃涓皻瀛樺湪鏈変簺璇存硶涓嶅Ε錛屼互鍙婃湁浜涙搷浣滃お綣佺悙鐨勫湴鏂?銆備負姝わ紝鏈漢鍦ㄥ涔犱簡姝ゆ枃鍚庯紝鍦ㄥ嬈″疄楠屽疄璺靛熀紜涓婏紝鎶婅鏂囦腑鐨勪竴浜涘唴瀹硅繘琛岃ˉ鍏呬笌鏀硅繘錛屽笇鏈涘澶у璋冭瘯紼嬪簭錛屽挨鍏舵槸release鐗堟湰鐨勭▼搴忔湁甯姪 銆傛榪庡悇浣嶆湅鍙嬫壒璇勬寚姝c?br>

涓銆佽鏂規硶閫傜敤鐨勮寖鍥?/strong>
銆銆鍦╳indows紼嬪簭涓犳垚紼嬪簭宕╂簝鐨勫師鍥犲緢澶氾紝鑰屾枃涓墍榪扮殑鏂規硶浠呴傜敤涓?鐢變竴鏉¤鍙ュ綋鍗沖紩璧風殑紼嬪簭宕╂簝銆傚鍘熸枃涓婦鐨勯櫎鏁頒負闆剁殑宕╂簝渚嬪瓙銆傝岀瑪鑰呭湪瀹為檯宸ヤ綔涓鍒版洿澶氱殑鎯呭喌鏄?鎸囬拡鎸囧悜涓闈炴硶鍦板潃 錛岀劧鍚庡鎸囬拡鐨勫唴瀹硅繘琛屼簡錛岃鎴栧啓鐨勬搷浣溿備緥濡傦細

void Crash1()
{
char * p =(char*)100;
*p=100;
}

銆銆榪欎簺鍘熷洜閫犳垚鐨勫穿婧冿紝鏃犺鏄痙ebug鐗堟湰錛岃繕鏄痳elease鐗堟湰鐨勭▼搴忥紝浣跨敤璇ユ柟娉曢兘鍙壘鍒伴犳垚宕╂簝鐨勫嚱鏁版垨瀛愮▼搴忎腑鐨勮鍙ヨ錛屽叿浣撴柟娉曠殑涓嬮潰榪樹細琛ュ厖璇存槑銆?鍙﹀錛屽疄璺典腑鍙︿竴縐嶅父瑙佺殑閫犳垚紼嬪簭宕╂簝鐨勫師鍥?鍑芥暟鎴栧瓙紼嬪簭涓眬閮ㄥ彉閲忔暟緇勮秺鐣屼粯鍊鹼紝閫犳垚鍑芥暟鎴栧瓙紼嬪簭榪斿洖鍦板潃閬鐩栵紝浠庤岄犳垚鍑芥暟鎴栧瓙紼嬪簭榪斿洖鏃跺穿婧冦備緥濡?

#include 
void Crash2();
int main(int argc,char* argv[])
{
Crash2();
return 0;
}
void Crash2()
{
char p[1];
strcpy(p,"0123456789");
}

鍦╲c涓紪璇戣繍琛屾紼嬪簭鐨剅elease鐗堟湰錛屼細璺沖嚭濡備笅鐨勫嚭閿欐彁紺烘銆?


鍥句竴 涓婇潰渚嬪瓙榪愯緇撴灉

銆銆榪欓噷鏄劇ず鐨勫穿婧冨湴鍧涓?0x34333231銆傝繖縐嶇敱鍓嶉潰璇彞閫犳垚鐨勫穿婧冩牴婧愶紝鍦ㄥ悗緇▼搴忎腑鏂規墠鏄劇幇鍑烘潵鐨勬儏鍐碉紝鏄劇劧鐢ㄨ鏂囨墍榪扮殑鏂規硶灝辨棤鑳戒負鍔涗簡銆備笉榪囧湪姝や緥涓灝戣繕鏈変簺铔涗笣椹抗鍙鎵懼埌宕╂簝鐨勫師鍥?鍑芥暟Crash2涓殑灞閮ㄦ暟緇刾鍙湁涓涓瓧鑺傚ぇ灝?錛屾樉鐒舵嫹璐?0123456789"榪欎釜瀛楃涓蹭細鎶婅秴鍑洪暱搴︾殑瀛楃涓叉嫹璐濆埌鏁扮粍p鐨勫悗闈紝鍗?(p+1)=''1''錛?(p+2)=''2''錛?(p+3)=''3''錛?(p+4)=4銆傘傘傘傘傘傝屽瓧絎?'1''鐨凙SC鐮佺殑鍊間負0x31錛?'2''涓?x32錛?'3''涓?x33錛?'4''涓?x34銆傘傘傘傘傦紝鐢變簬intel鐨刢pu涓璱nt鍨嬫暟鎹槸浣庡瓧鑺備繚瀛樺湪浣庡湴鍧涓?錛屾墍浠ヤ繚瀛樺瓧絎︿覆''1234''鐨勫唴瀛橈紝鏄劇ず涓轟竴涓?瀛楄妭鐨刬nt鍨嬫暟鏃跺氨鏄?x34333231銆傛樉鐒舵嫹璐?0123456789"榪欎釜瀛楃涓叉椂錛?1234"榪欏嚑涓瓧絎︽妸鍑芥暟Crash2鐨勮繑鍥炲湴鍧緇欒鐩?錛屼粠鑰岄犳垚紼嬪簭宕╂簝銆傚浜庣被浼肩殑榪欑閫犳垚紼嬪簭宕╂簝鐨勯敊璇湅鍙嬩滑榪樻湁鍏朵粬鏂規硶鎺掗敊鐨勮瘽錛屾榪庝竴璧蜂氦嫻佽璁恒?br>

浜屻佽緗紪璇戜駭鐢焟ap鏂囦歡鐨勬柟娉?/strong>
銆銆璇ユ枃涓駭鐢焟ap鏂囦歡鐨勬柟娉曟槸鎵嬪伐娣誨姞緙栬瘧鍙傛暟鏉ヤ駭鐢焟ap鏂囦歡銆傚叾瀹炲湪vc6鐨処DE涓湁浜х敓map鏂囦歡鐨勯厤緗夐」鐨勩傛搷浣滃涓?鍏堢偣鍑昏彍鍗?Project"->"Settings銆傘傘?錛屽脊鍑虹殑灞炴ч〉涓変腑"Link"欏?錛岀‘淇濆湪"category"涓変腑"General"錛屾渶鍚庨変腑"Generate mapfile"鐨勫彲閫夐」銆傝嫢瑕佸湪鍦╩ap鏂囦歡涓樉紺篖ine numbers鐨勪俊鎭殑璇?錛岃繕闇鍦╬roject options 涓姞鍏?mapinfo:lines 銆侺ine numbers淇℃伅瀵逛簬"緗楁枃"鎵鐢ㄧ殑鏂規硶鏉ュ畾浣嶅嚭閿欐簮浠g爜琛屽緢閲嶈 錛屼絾絎旇呭悗闈細浠嬬粛鏇村姞濂界殑鏂規硶鏉ュ畾浣嶅嚭閿欎唬鐮佽錛岄偅縐嶆柟娉曚笉闇瑕丩ine numbers淇℃伅銆?


鍥句簩 璁劇疆浜х敓MAP鏂囦歡


涓夈佸畾浣嶅穿婧冭鍙ヤ綅緗殑鏂規硶
銆銆"緗楁枃"鎵榪扮殑瀹氫綅鏂規硶涓紝鎵懼埌浜х敓宕╂簝鐨勫嚱鏁頒綅緗殑鏂規硶鏄紜殑錛屽嵆鍦╩ap鏂囦歡鍒楀嚭鐨勬瘡涓嚱鏁扮殑璧峰鍦板潃涓紝鏈榪戠殑涓斾笉澶т簬宕╂簝鍦板潃鐨勫湴鍧鍗充負鍖呭惈宕╂簝璇彞鐨勫嚱鏁扮殑鍦板潃 銆備絾涔嬪悗鐨勫啀榪涗竴姝ョ殑瀹氫綅鍑洪敊璇彞琛岀殑鏂規硶涓嶆槸鏈濡ュ綋錛屽洜涓洪偅縐嶆柟娉曞墠鎻愭槸錛屽亣璁懼熀鍦板潃鐨勫兼槸 0x00400000 錛屼互鍙婁竴鑸殑 PE 鏂囦歡鐨勪唬鐮佹閮芥槸浠?0x1000鍋忕Щ寮濮嬬殑 銆傝櫧鐒惰繖縐嶆儏鍐靛緢鏅亶錛屼絾鍦╲c涓繕鏄彲浠ュ熀鍦板潃璁劇疆涓哄叾浠栨暟錛屾瘮濡傝緗負0x00500000錛岃繖鏃朵粛鏃у鐢?br>

 宕╂簝琛屽亸縐?= 宕╂簝鍦板潃 - 0x00400000 - 0x1000 

鐨勫叕寮忔樉鐒舵棤娉曟壘鍒板穿婧冭鍋忕Щ銆?鍏跺疄涓婅堪鍏紡鑻ユ敼涓?br>

宕╂簝琛屽亸縐?= 宕╂簝鍦板潃 - 宕╂簝鍑芥暟緇濆鍦板潃 + 鍑芥暟鐩稿鍋忕Щ

鍗沖彲閫氱敤浜嗐備粛浠?緗楁枃"涓殑渚嬪瓙涓轟緥:"緗楁枃"涓彁鍒扮殑鍦ㄥ叾宕╂簝紼嬪簭鐨勫搴攎ap鏂囦歡涓紝宕╂簝鍑芥暟鐨勭紪璇戠粨鏋滀負

0001:00000020 ?Crash@@YAXXZ 00401020 f CrashDemo銆俹bj 

瀵逛笌涓婅堪緇撴灉錛屽湪浣跨敤鎴戠殑鍏紡鏃?錛?宕╂簝鍑芥暟緇濆鍦板潃"鎸?0401020錛?鍑芥暟鐩稿鍋忕Щ鎸?00000020錛?褰撳穿婧冨湴鍧= 0x0040104a鏃訛紝 鍒?宕╂簝琛屽亸縐?= 宕╂簝鍦板潃 - 宕╂簝鍑芥暟璧峰鍦板潃+ 鍑芥暟鐩稿鍋忕Щ = 0x0040104a - 0x00401020 + 0x00000020= 0x4a錛岀粨鏋滀笌"緗楁枃"璁$畻緇撴灉鐩稿悓 銆備絾榪欎釜鍏紡鏇撮氱敤銆?br>

鍥涖佹洿濂界殑瀹氫綅宕╂簝璇彞浣嶇疆鐨勬柟娉曘?/strong>
銆銆鍏跺疄闄や簡渚濋潬map鏂囦歡涓殑Line numbers淇℃伅鏈緇堝畾浣嶅嚭閿欒鍙ヨ澶栵紝鍦╲c6涓垜浠繕鍙互閫氳繃緙栬瘧紼嬪簭浜х敓鐨勫搴旂殑姹囩紪璇彞錛屼簩榪涘埗鐮侊紝浠ュ強瀵瑰簲c/c++璇彞涓轟竴浣撶殑"cod"鏂囦歡鏉ュ畾浣嶅嚭閿欒鍙ヨ 銆傚厛浠嬬粛涓涓嬩駭鐢熻繖縐嶅寘鍚簡涓夌淇℃伅鐨?cod"鏂囦歡鐨勮緗柟娉?鍏堢偣鍑昏彍鍗?Project"->"Settings銆傘傘?錛屽脊鍑虹殑灞炴ч〉涓変腑"C/C++"欏?錛岀劧鍚庡湪"Category"涓夊垯"Listing Files"錛屽啀鍦?Listing file type"鐨勭粍鍚堟涓夋嫨"Assembly錛孧achine code錛?and source"銆傛帴涓嬪幓鍐嶉氳繃涓涓叿浣撶殑渚嬪瓙鏉ヨ鏄庤繖縐嶆柟娉曠殑鍏蜂綋鎿嶄綔銆?


鍥句笁 璁劇疆浜х敓"cod"鏂囦歡

鍑嗗姝ラ1)浜х敓宕╂簝鐨勭▼搴忓涓?

01 //****************************************************************
02 //鏂囦歡鍚嶇О錛歝rash銆俢pp
03 //浣滅敤:    婕旂ず閫氳繃宕╂簝鍦板潃鎵懼嚭婧愪唬鐮佺殑鍑洪敊琛屾柊鏂規硶
04 //浣滆咃細   浼熷姛閫氫俊 roc
05 //鏃ユ湡錛?  2005-5-16
06//****************************************************************
07 void Crash1();
08 int main(int argc,char* argv[])
09 {
10 Crash1();
11 return 0;
12 }
13
14 void Crash1()
15 {
16  char * p =(char*)100;
17  *p=100;
18 }

鍑嗗姝ラ2)鎸夋湰鏂囨墍榪拌緗駭鐢焟ap鏂囦歡(涓嶉渶瑕佷駭鐢烲ine numbers淇℃伅)銆?br>鍑嗗姝ラ3)鎸夋湰鏂囨墍榪拌緗駭鐢焎od鏂囦歡銆?br>鍑嗗姝ラ4)緙栬瘧銆傝繖閲屼互debug鐗堟湰涓轟緥(鑻ユ槸release鐗堟湰闇瑕佸皢緙栬瘧閫夐」鏀逛負涓嶈繘琛屼換浣曚紭鍖栫殑閫夐」錛屽惁鍒欎笂榪頒唬鐮佷細鍥犱負浼樺寲鏃剁湅浣滃簾浠g爜鑰屼笉琚紪璇戯紝浠庤岀湅涓嶅埌宕╂簝鐨勭粨鏋?錛岀紪璇戝悗浜х敓涓涓?exe"鏂囦歡 錛屼竴涓?map"鏂囦歡錛屼竴涓?cod"鏂囦歡銆?
榪愯姝ょ▼搴忥紝浜х敓濡備笅濡備笅宕╂簝鎻愮ず:


鍥懼洓 涓婇潰渚嬪瓙榪愯緇撴灉

鎺掗敊姝ラ1)瀹氫綅宕╂簝鍑芥暟銆傚彲浠ユ煡璇ap鏂囦歡鑾峰緱銆傛垜鐨勬満鍣ㄧ紪璇戜駭鐢熺殑map鏂囦歡鐨勯儴鍒嗗涓?

 Crash
Timestamp is 42881a01 (Mon May 16 11:56:49 2005)
Preferred load address is 00400000
Start Length Name Class
0001:00000000 0000ddf1H .text CODE
0001:0000ddf1 0001000fH .textbss CODE
0002:00000000 00001346H .rdata DATA
0002:00001346 00000000H .edata DATA
0003:00000000 00000104H .CRT$XCA DATA
0003:00000104 00000104H .CRT$XCZ DATA
0003:00000208 00000104H .CRT$XIA DATA
0003:0000030c 00000109H .CRT$XIC DATA
0003:00000418 00000104H .CRT$XIZ DATA
0003:0000051c 00000104H .CRT$XPA DATA
0003:00000620 00000104H .CRT$XPX DATA
0003:00000724 00000104H .CRT$XPZ DATA
0003:00000828 00000104H .CRT$XTA DATA
0003:0000092c 00000104H .CRT$XTZ DATA
0003:00000a30 00000b93H .data DATA
0003:000015c4 00001974H .bss DATA
0004:00000000 00000014H .idata$2 DATA
0004:00000014 00000014H .idata$3 DATA
0004:00000028 00000110H .idata$4 DATA
0004:00000138 00000110H .idata$5 DATA
0004:00000248 000004afH .idata$6 DATA
Address Publics by Value Rva+Base Lib:Object
0001:00000020 _main 00401020 f Crash.obj
0001:00000060 ?Crash1@@YAXXZ 00401060 f Crash.obj
0001:000000a0 __chkesp 004010a0 f LIBCD:chkesp.obj
0001:000000e0 _mainCRTStartup 004010e0 f LIBCD:crt0.obj
0001:00000210 __amsg_exit 00401210 f LIBCD:crt0.obj
0001:00000270 __CrtDbgBreak 00401270 f LIBCD:dbgrpt.obj
...

瀵逛簬宕╂簝鍦板潃0x00401082鑰岃█錛屽皬浜庢鍦板潃涓渶鎺ヨ繎鐨勫湴鍧(Rva+Base涓殑鍦板潃)涓?0401060錛屽叾瀵瑰簲鐨勫嚱鏁板悕涓?Crash1@@YAXXZ錛岀敱浜庢墍鏈変互闂彿寮澶寸殑鍑芥暟鍚嶇О閮芥槸 C++ 淇グ鐨勫悕縐?錛?@@YAXXZ"鍒欎負鍖哄埆閲嶈澆鍑芥暟鑰屽姞鐨勫悗緙錛屾墍浠?Crash1@@YAXXZ灝辨槸鎴戜滑鐨勬簮紼嬪簭涓紝Crash1() 榪欎釜鍑芥暟銆?br>鎺掗敊姝ラ2)瀹氫綅鍑洪敊琛屻傛墦寮緙栬瘧鐢熸垚鐨?cod"鏂囦歡錛屾垜鏈哄櫒涓婄敓鎴愮殑鏂囦歡鍐呭濡備笅:

 TITLE E:\Crash\Crash銆俢pp
.386P
include listing.inc
if @Version gt 510
.model FLAT
else
_TEXT SEGMENT PARA USE32 PUBLIC ''CODE''
_TEXT ENDS
_DATA SEGMENT DWORD USE32 PUBLIC ''DATA''
_DATA ENDS
CONST SEGMENT DWORD USE32 PUBLIC ''CONST''
CONST ENDS
_BSS SEGMENT DWORD USE32 PUBLIC ''BSS''
_BSS ENDS
$$SYMBOLS SEGMENT BYTE USE32 ''DEBSYM''
$$SYMBOLS ENDS
$$TYPES SEGMENT BYTE USE32 ''DEBTYP''
$$TYPES ENDS
_TLS SEGMENT DWORD USE32 PUBLIC ''TLS''
_TLS ENDS
; COMDAT _main
_TEXT SEGMENT PARA USE32 PUBLIC ''CODE''
_TEXT ENDS
; COMDAT ?Crash1@@YAXXZ
_TEXT SEGMENT PARA USE32 PUBLIC ''CODE''
_TEXT ENDS
FLAT GROUP _DATA錛?CONST, _BSS
ASSUME CS: FLAT, DS: FLAT, SS: FLAT
endif
PUBLIC ?Crash1@@YAXXZ     ; Crash1
PUBLIC _main
EXTRN __chkesp:NEAR
; COMDAT _main
_TEXT SEGMENT
_main PROC NEAR     ; COMDAT
; 9    : {
00000 55   push  ebp
00001 8b ec   mov  ebp錛?esp
00003 83 ec 40  sub  esp, 64   ; 00000040H
00006 53   push  ebx
00007 56   push  esi
00008 57   push  edi
00009 8d 7d c0  lea  edi, DWORD PTR [ebp-64]
0000c b9 10 00 00 00  mov  ecx錛?16   ; 00000010H
00011 b8 cc cc cc cc  mov  eax錛?-858993460  ; ccccccccH
00016 f3 ab   rep stosd
; 10   :  Crash1();
00018 e8 00 00 00 00  call  ?Crash1@@YAXXZ  ; Crash1
; 11   :  return 0;
0001d 33 c0   xor  eax錛?eax
; 12   : }
0001f 5f   pop  edi
00020 5e   pop  esi
00021 5b   pop  ebx
00022 83 c4 40  add  esp, 64   ; 00000040H
00025 3b ec   cmp  ebp, esp
00027 e8 00 00 00 00  call  __chkesp
0002c 8b e5   mov  esp, ebp
0002e 5d   pop  ebp
0002f c3   ret  0
_main ENDP
_TEXT ENDS
; COMDAT ?Crash1@@YAXXZ
_TEXT SEGMENT
_p$ = -4
?Crash1@@YAXXZ PROC NEAR    ; Crash1, COMDAT
; 15   : {
00000 55   push  ebp
00001 8b ec   mov  ebp, esp
00003 83 ec 44  sub  esp, 68   ; 00000044H
00006 53   push  ebx
00007 56   push  esi
00008 57   push  edi
00009 8d 7d bc  lea  edi, DWORD PTR [ebp-68]
0000c b9 11 00 00 00  mov  ecx, 17   ; 00000011H
00011 b8 cc cc cc cc  mov  eax, -858993460  ; ccccccccH
00016 f3 ab   rep stosd
; 16   :  char * p =(char*)100;
00018 c7 45 fc 64 00
00 00   mov  DWORD PTR _p$[ebp], 100 ; 00000064H
; 17   :  *p=100;
0001f 8b 45 fc  mov  eax, DWORD PTR _p$[ebp]
00022 c6 00 64  mov  BYTE PTR [eax], 100 ; 00000064H
; 18   : }
00025 5f   pop  edi
00026 5e   pop  esi
00027 5b   pop  ebx
00028 8b e5   mov  esp, ebp
0002a 5d   pop  ebp
0002b c3   ret  0
?Crash1@@YAXXZ ENDP     ; Crash1
_TEXT ENDS
END

鍏朵腑

?Crash1@@YAXXZ PROC NEAR    ; Crash1, COMDAT

涓篊rash1姹囩紪浠g爜鐨勮搗濮嬭銆備駭鐢熷穿婧冪殑浠g爜渚垮湪鍏跺悗鐨勬煇涓綅緗傛帴涓嬪幓鐨勪竴琛屼負:

; 15   : {

鍐掑彿鍚庣殑"{"琛ㄧず婧愭枃浠朵腑鐨勮鍙ワ紝鍐掑彿鍓嶇殑"15"琛ㄧず璇ヨ鍙ュ湪婧愭枃浠朵腑鐨勮鏁般?榪欎箣鍚庢樉紺鴻璇彞姹囩紪鍚庣殑鍋忕Щ鍦板潃錛屼簩榪涘埗鐮侊紝姹囩紪浠g爜銆傚

00000 55   push  ebp

鍏朵腑"0000"琛ㄧず鐩稿浜庡嚱鏁板紑濮嬪湴鍧鍚庣殑鍋忕Щ錛?55"涓虹紪璇戝悗鐨勬満鍣ㄤ唬鐮侊紝" push ebp"涓烘眹緙栦唬鐮併備粠"cod"鏂囦歡涓垜浠彲浠ョ湅鍑猴紝涓鏉?c/c++)璇彞閫氬父闇瑕佺紪璇戞垚鏁版潯姹囩紪璇彞 銆傛澶栨湁浜涙眹緙栬鍙ュお闀垮垯浼氬垎涓よ鏄劇ず濡?

00018 c7 45 fc 64 00
00 00   mov  DWORD PTR _p$[ebp], 100 ; 00000064H

鍏朵腑"0018"琛ㄧず鐩稿鍋忕Щ錛屽湪debug鐗堟湰涓紝榪欎釜鏁版嵁涓虹浉瀵逛簬鍑芥暟璧峰鍦板潃鐨勫亸縐?姝ゆ椂姣忎釜鍑芥暟絎竴鏉¤鍙ョ浉瀵瑰亸縐諱負0000)錛況elease鐗堟湰涓負鐩稿浜庝唬鐮佹絎竴鏉¤鍙ョ殑鍋忕Щ(鍗充唬鐮佹絎竴鏉¤鍙ョ浉瀵瑰亸縐諱負0000錛岃屼互鍚庣殑姣忎釜鍑芥暟絎竴鏉¤鍙ョ浉瀵瑰亸縐誨氨涓嶄負0000浜?銆?c7 45 fc 64 00 00 00 "涓虹紪璇戝悗鐨勬満鍣ㄤ唬鐮?錛?mov DWORD PTR _p$[ebp]錛?100"涓烘眹緙栦唬鐮侊紝 姹囩紪璇█涓?;"鍚庣殑鍐呭涓烘敞閲婏紝鎵浠?;00000064H"錛屾槸涓敞閲婅繖閲岀敤鏉ヨ鏄?00杞崲鎴?6榪涘埗鏃朵負"00000064H"銆?br>鎺ヤ笅鍘伙紝鎴戜滑寮濮嬫潵瀹氫綅浜х敓宕╂簝鐨勮鍙ャ?br>絎竴姝ワ紝璁$畻宕╂簝鍦板潃鐩稿浜庡穿婧冨嚱鏁扮殑鍋忕Щ錛屽湪鏈緥涓凡緇忕煡閬撲簡宕╂簝璇彞鐨勫湴鍧(0x00401082)錛屽拰瀵瑰簲鍑芥暟鐨勮搗濮嬪湴鍧(0x00401060)錛屾墍浠ュ穿婧冨湴鍧鐩稿鍑芥暟璧峰鍦板潃鐨勫亸縐誨氨寰堝鏄撹綆椾簡:

  宕╂簝鍋忕Щ鍦板潃 = 宕╂簝璇彞鍦板潃 - 宕╂簝鍑芥暟鐨勮搗濮嬪湴鍧 = 0x00401082 - 0x00401060 = 0x22銆?/pre>

絎簩姝ワ紝璁$畻鍑洪敊鐨勬眹緙栬鍙ュ湪cod鏂囦歡涓殑鐩稿鍋忕Щ銆傛垜浠彲浠ョ湅鍒板嚱鏁癈rash1()鍦╟od鏂囦歡涓殑鐩稿鍋忕Щ鍦板潃涓?000錛屽垯

宕╂簝璇彞鍦╟od鏂囦歡涓殑鐩稿鍋忕Щ =  宕╂簝鍑芥暟鍦╟od鏂囦歡涓浉瀵瑰亸縐?+ 宕╂簝鍋忕Щ鍦板潃 = 0x0000 + 0x22 = 0x22

絎笁姝ワ紝鎴戜滑鐪婥rash1鍑芥暟鍋忕Щ0x22闄ょ殑浠g爜鏄粈涔?緇撴灉濡備笅

 00022 c6 00 64  mov  BYTE PTR [eax], 100 ; 00000064H

榪欏彞姹囩紪璇彞琛ㄧず灝?00榪欎釜鏁頒繚瀛樺埌瀵勫瓨鍣╡ax鎵鎸囩殑鍐呭瓨鍗曞厓涓幓錛屼繚瀛樼┖闂村ぇ灝忎負1涓瓧鑺?byte)銆傜▼搴忔鏄墽琛岃繖鏉″懡浠ゆ椂浜х敓浜嗗穿婧冿紝鏄劇劧榪欓噷eax涓殑涓轟竴涓潪娉曞湴鍧 錛屾墍浠ョ▼搴忓穿婧冧簡!
絎洓姝ワ紝鍐嶆煡鐪嬭姹囩紪璇彞鍦ㄥ叾鍓嶉潰鍑犺鐨勫叾瀵瑰簲鐨勬簮浠g爜錛岀粨鏋滃涓?

; 17   :  *p=100;

鍏朵腑17琛ㄧず璇ヨ鍙ヤ綅浜庢簮鏂囦歡涓17琛岋紝鑰?#8220;*p=100;”榪欐鏄簮鏂囦歡涓駭鐢熷穿婧冪殑璇彞銆?br>鑷蟲鎴戜滑浠呬粠宕╂簝鍦板潃灝辨煡鎵懼嚭浜嗛犳垚宕╂簝鐨勬簮浠g爜璇彞鍜岃璇彞鎵鍦ㄦ簮鏂囦歡涓殑紜垏浣嶇疆錛岀敋鑷蟲煡鎵懼埌浜嗛犳垚宕╂簝鐨勭紪璇戝悗鐨勭‘鍒囨眹緙栦唬鐮?
鎬庝箞鏍鳳紝鏄笉鏄劅瑙夋洿鐖藉晩?


浜斻佸皬鑺?/strong>

1銆佹柊鏂規硶鍚屾牱瑕佹敞鎰忓彲浠ラ傜敤鐨勮寖鍥達紝鍗崇▼搴忕敱涓鏉¤鍙ュ綋鍗沖紩璧風殑宕╂簝銆傚彟澶栨垜涓嶇煡閬撻櫎浜哣C6澶栵紝鏄惁榪樻湁鍏朵粬鐨勭紪璇戝櫒鑳藉浜х敓綾諱技鐨?cod"鏂囦歡銆?br>2銆佹垜浠彲浠ラ氳繃姣旇緝 鏂版柟娉曚駭鐢熺殑debug鍜宺eleae鐗堟湰鐨?cod"鏂囦歡錛屾煡鎵鵑偅浜涗粎release鐗堟湰(鎴杁ebug鐗堟湰)鏈夊彟涓涓増鏈病鏈夌殑bug(鎴栧叾浠栨х姸)銆備緥濡?緗楁枃"涓墍涓劇殑閭d釜鐢ㄤ緥 錛屽彧瑕佹墦寮release鐗堟湰鐨?cod"鏂囦歡錛屽氨鏄庣櫧浜嗕負鍟ebug鐗堟湰浼氫駭鐢熷穿婧冭宺elease鐗堟湰鍗存病鏈?鍘熸潵release鐗堟湰涓駭鐢熷穿婧冪殑璇彞鍏跺疄鏍規湰閮芥病鏈夌紪璇?銆傚悓鏍鋒湰渚嬩腑鐨剅elease鐗堟湰瑕佺湅鍒板穿婧冪殑鏁堟灉錛岄渶瑕佸皢緙栬瘧閫夐」鏀逛負涓轟笉浼樺寲鐨勯厤緗?/p>

kk 2007-04-10 11:27 鍙戣〃璇勮
]]>DeinoMPIhttp://www.shnenglu.com/jacky2019/archive/2007/04/10/21578.htmlkkkkTue, 10 Apr 2007 02:57:00 GMThttp://www.shnenglu.com/jacky2019/archive/2007/04/10/21578.htmlhttp://www.shnenglu.com/jacky2019/comments/21578.htmlhttp://www.shnenglu.com/jacky2019/archive/2007/04/10/21578.html#Feedback0http://www.shnenglu.com/jacky2019/comments/commentRss/21578.htmlhttp://www.shnenglu.com/jacky2019/services/trackbacks/21578.htmlDeinoMPI is an implementation of MPI-2 for Microsoft Windows. 

DeinoMPI鏄井杞?/span>windows涓?/span>MPI-2鐨勪竴涓疄鐜般?/span>

娉細MPI-2鏄?/span>Message Passing Interface, http://www.mpi-forum.org/銆?/span>What is MPI? MPI is a library of functions and macros which is intended for use in programs that exploit the existence of multiple processors by message-passing. 涔熷氨鏄錛?/span>MPI鏄竴濂楄鑼冿紝瀹氫箟浜嗕竴浜涘嚱鏁板拰瀹忥紝瀹冭鐢ㄦ潵鍦ㄧ▼搴忎腑閫氳繃娑堟伅浼犻掓潵鍙戞尌澶氬鐞嗗櫒鐨勫鐞嗚兘鍔涖?/span>

DeinoMPI is an implementation of the MPI-2 standard for parallel computing or more generally it is system level middle-ware for high performance parallel computing on Microsoft Windows systems. It supports Win32 and Win64 machines.

DeinoMPI鏄?/span>MPI-2鐨勪竴涓疄鐜幫紝MPI-2鏄?/span>for騫惰璁$畻鐨勩傛洿閫氱敤鍦拌錛?/span>DeinoMPI鏄?/span>windows緋葷粺涓婄殑涓涓珮鎬ц兘騫惰璁$畻鐨勭郴緇?/span>level涓棿浠躲傚畠鏈変袱涓増鏈紝鍒嗗埆鏄?/span>for win32鍜?/span>for win64鐨勩?/span>

1) DeinoMPI provides the libraries necessary for software developers to write parallel applications that conform to the MPI-2 standard for parallel computing.  Software developers who wish to develop new parallel applications or wish to add parallel capabilities to existing software would benefit from using DeinoMPI.  The libraries provided support a wide range of C, C++ and Fortran compilers.

2) DeinoMPI also provides a process manager used to start processes on multiple machines in a cluster remotely.  Microsoft Windows does not provide native capability to start user applications on remote machines.  DeinoMPI provides a secure mechanism to do just that.  The primary purpose of the DeinoMPI process manager is to set up the environment and launch processes used in MPI jobs but it is not restricted to this functionality.  It can launch any application remotely on behalf of the user.

The following users will benefit from DeinoMPI: Businesses that develop software and wish to add parallel capabilities to increase the performance of their software.  Research institutions that have parallel software codes that they want to run on their Windows machines.  Universities or other educational institutions that teach courses on parallel computing.  University or research labs that run computationally intensive software and wish to use parallel versions of their software to better utilize their computer resources.  Students or hobbyists that wish to write parallel programs.

 



kk 2007-04-10 10:57 鍙戣〃璇勮
]]>
鍙彉鍙傛暟鐮旂┒http://www.shnenglu.com/jacky2019/archive/2007/04/10/21577.htmlkkkkTue, 10 Apr 2007 02:38:00 GMThttp://www.shnenglu.com/jacky2019/archive/2007/04/10/21577.htmlhttp://www.shnenglu.com/jacky2019/comments/21577.htmlhttp://www.shnenglu.com/jacky2019/archive/2007/04/10/21577.html#Feedback0http://www.shnenglu.com/jacky2019/comments/commentRss/21577.htmlhttp://www.shnenglu.com/jacky2019/services/trackbacks/21577.html涓錛?/span> 浣曡皳鍙彉鍙傛暟
int printf( const char* format, ...);
榪欐槸浣跨敤榪?/span>C璇█鐨勪漢鎵鍐嶇啛鎮変笉榪囩殑printf鍑芥暟鍘熷瀷錛屽畠鐨勫弬鏁頒腑灝辨湁鍥哄畾鍙傛暟format鍜屽彲鍙樺弬鏁幫紙鐢?/span>”…”琛ㄧず錛?/span>. 鑰屾垜浠張鍙互鐢ㄥ悇縐嶆柟寮忔潵璋冪敤printf,濡?/span>:
printf("%d",value);
printf("%s",str);
printf("the number is %d ,string is:%s", value, str);
浜?/span>.瀹炵幇鍘熺悊
C 璇█鐢ㄥ畯鏉ュ鐞嗚繖浜涘彲鍙樺弬鏁般傝繖浜涘畯鐪嬭搗鏉ュ緢澶嶆潅錛屽叾瀹炲師鐞嗘尯綆鍗曪紝灝辨槸鏍規嵁鍙傛暟鍏ユ爤鐨勭壒鐐逛粠鏈闈犺繎絎竴涓彲鍙樺弬鏁扮殑鍥哄畾鍙傛暟寮濮嬶紝渚濇鑾峰彇姣忎釜鍙彉鍙傛暟 鐨勫湴鍧銆備笅闈㈡垜浠潵鍒嗘瀽榪欎簺瀹忋傚湪VC涓殑stdarg.h澶存枃浠朵腑錛岄拡瀵逛笉鍚屽鉤鍙版湁涓嶅悓鐨勫畯瀹氫箟錛屾垜浠夊彇X86騫沖彴涓嬬殑瀹忓畾涔夛細
typedef char *va_list;
/*鎶?/span>va_list琚畾涔夋垚char*錛岃繖鏄洜涓哄湪鎴戜滑鐩墠鎵鐢ㄧ殑PC鏈轟笂錛屽瓧絎︽寚閽堢被鍨嬪彲浠ョ敤鏉ュ瓨鍌ㄥ唴瀛樺崟鍏冨湴鍧銆傝屽湪鏈夌殑鏈哄櫒涓?/span>va_list鏄瀹氫箟鎴?/span>void*鐨?/span>*/
#define _INTSIZEOF(n) ( (sizeof(n) + sizeof(int) - 1) & ~(sizeof(int) - 1) )
/*_INTSIZEOF (n)瀹忔槸涓轟簡鑰冭檻閭d簺鍐呭瓨鍦板潃闇瑕佸榻愮殑緋葷粺錛屼粠瀹忕殑鍚嶅瓧鏉ュ簲璇ユ槸璺?/span>sizeof(int)瀵歸綈銆備竴鑸殑sizeof(int)=4錛屼篃灝辨槸鍙傛暟鍦ㄥ唴瀛?/span> 涓殑鍦板潃閮戒負4鐨勫嶆暟銆傛瘮濡傦紝濡傛灉sizeof(n)鍦?/span>1錛?/span>4涔嬮棿錛岄偅涔?/span>_INTSIZEOF(n)錛?/span>4錛涘鏋?/span>sizeof(n)鍦?/span>5錛?/span>8涔嬮棿錛岄偅涔?/span> _INTSIZEOF(n)=8銆?/span>*/
#define va_start(ap,v)( ap = (va_list)&v + _INTSIZEOF(v) )
/*va_start 鐨勫畾涔変負 &v+_INTSIZEOF(v) ,榪欓噷&v鏄渶鍚庝竴涓浐瀹氬弬鏁扮殑璧峰鍦板潃錛屽啀鍔犱笂鍏跺疄闄呭崰鐢ㄥぇ灝忓悗錛屽氨寰楀埌浜嗙涓涓彲鍙樺弬鏁扮殑璧峰鍐呭瓨鍦板潃銆傛墍浠ユ垜浠繍琛?/span>va_start (ap, v)浠ュ悗,ap鎸囧悜絎竴涓彲鍙樺弬鏁板湪鐨勫唴瀛樺湴鍧*/
#define va_arg(ap,t) ( *(t *)((ap += _INTSIZEOF(t)) - _INTSIZEOF(t)) )
/*榪欎釜瀹忓仛浜嗕袱涓簨鎯咃紝
鈶犵敤鐢ㄦ埛杈撳叆鐨勭被鍨嬪悕瀵瑰弬鏁板湴鍧榪涜寮哄埗綾誨瀷杞崲錛屽緱鍒扮敤鎴鋒墍闇瑕佺殑鍊?/span>
鈶¤綆楀嚭鏈弬鏁扮殑瀹為檯澶у皬錛屽皢鎸囬拡璋冨埌鏈弬鏁扮殑緇撳熬錛屼篃灝辨槸涓嬩竴涓弬鏁扮殑棣栧湴鍧錛屼互渚垮悗緇鐞嗐?/span>*/
銆銆#define va_end(ap) ( ap = (va_list)0 )
/*x86 騫沖彴瀹氫箟涓?/span>ap=(char*)0;浣?/span>ap涓嶅啀 鎸囧悜鍫嗘爤,鑰屾槸璺?/span>NULL涓鏍?/span>.鏈変簺鐩存帴瀹氫箟涓?/span>((void*)0),榪欐牱緙栬瘧鍣ㄤ笉浼氫負va_end浜х敓浠g爜,渚嬪gcc鍦?/span>linux鐨?/span>x86騫沖彴灝辨槸榪?/span> 鏍峰畾涔夌殑. 鍦ㄨ繖閲屽ぇ瀹惰娉ㄦ剰涓涓棶棰?/span>:鐢變簬鍙傛暟鐨勫湴鍧鐢ㄤ簬va_start瀹?/span>,鎵浠ュ弬鏁頒笉鑳藉0鏄庝負瀵勫瓨鍣ㄥ彉閲忔垨浣滀負鍑芥暟鎴栨暟緇勭被鍨?/span>. */

浠ヤ笅鍐嶇敤鍥炬潵琛ㄧず:

鍦?/span>VC絳夌粷澶у鏁?/span>C緙栬瘧鍣ㄤ腑錛岄粯璁ゆ儏鍐典笅錛屽弬鏁拌繘鏍堢殑欏哄簭鏄敱鍙沖悜宸︾殑錛屽洜姝わ紝鍙傛暟榪涙爤浠ュ悗鐨勫唴瀛樻ā鍨嬪涓嬪浘鎵紺猴細鏈鍚庝竴涓浐瀹氬弬鏁扮殑鍦板潃浣嶄簬絎竴涓彲鍙樺弬鏁頒箣涓嬶紝騫朵笖鏄繛緇瓨鍌ㄧ殑銆?/span>
|鈥斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺攟
|鏈鍚庝竴涓彲鍙樺弬鏁?/span> | ->楂樺唴瀛樺湴鍧澶?/span>
|鈥斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺攟
...................
|鈥斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺攟
|絎?/span>N涓彲鍙樺弬鏁?/span> | ->va_arg(arg_ptr,int)鍚?/span>arg_ptr鎵鎸囩殑鍦版柟,
| | 鍗崇N涓彲鍙樺弬鏁扮殑鍦板潃銆?/span>
|鈥斺斺斺斺斺斺斺斺斺斺斺斺斺斺?|
………………………….
|鈥斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺攟
|絎竴涓彲鍙樺弬鏁?/span> | ->va_start(arg_ptr,start)鍚?/span>arg_ptr鎵鎸囩殑鍦版柟
| | 鍗崇涓涓彲鍙樺弬鏁扮殑鍦板潃
|鈥斺斺斺斺斺斺斺斺斺斺斺斺斺斺?|
|鈥斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺?鈥斺攟
| |
|鏈鍚庝竴涓浐瀹氬弬鏁?/span> | -> start鐨勮搗濮嬪湴鍧
|鈥斺斺斺斺斺斺斺斺斺斺斺斺斺?鈥攟 .................
|鈥斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺斺?|
| |
|鈥斺斺斺斺斺斺斺斺斺斺斺斺斺斺?|-> 浣庡唴瀛樺湴鍧澶?/span>

涓?/span>.printf鐮旂┒

涓嬮潰鏄竴涓畝鍗曠殑printf鍑芥暟鐨勫疄鐜幫紝鍙傝冧簡涓殑156欏電殑渚嬪瓙錛岃鑰呭彲浠ョ粨鍚堜功涓婄殑浠g爜涓庢湰鏂囧弬鐓с?/span>
#include "stdio.h"
#include "stdlib.h"
void myprintf(char* fmt, ...) //涓涓畝鍗曠殑綾諱技浜?/span>printf鐨勫疄鐜幫紝//鍙傛暟蹇呴』閮芥槸int 綾誨瀷
{
char* pArg=NULL; //絳変環浜庡師鏉ョ殑va_list
char c;

pArg = (char*) &fmt; //娉ㄦ剰涓嶈鍐欐垚p = fmt !!鍥犱負榪欓噷瑕佸//鍙傛暟鍙栧潃錛岃屼笉鏄彇鍊?/span>
pArg += sizeof(fmt); //絳変環浜庡師鏉ョ殑va_start

do
{
c =*fmt;
if (c != '%')
{
putchar(c); //鐓у師鏍瘋緭鍑哄瓧絎?/span>
}
else
{
//鎸夋牸寮忓瓧絎﹁緭鍑烘暟鎹?/span>
switch(*++fmt)
{
case 'd':
printf("%d",*((int*)pArg));
break;
case 'x':
printf("%#x",*((int*)pArg));
break;
default:
break;
}
pArg += sizeof(int); //絳変環浜庡師鏉ョ殑va_arg
}
++fmt;
}while (*fmt != '\0');
pArg = NULL; //絳変環浜?/span>va_end
return;
}
int main(int argc, char* argv[])
{
int i = 1234;
int j = 5678;

myprintf("the first test:i=%d",i,j);
myprintf("the secend test:i=%d; %x;j=%d;",i,0xabcd,j);
system("pause");
return 0;
}
鍦?/span>intel+win2k+vc6鐨勬満鍣ㄦ墽琛岀粨鏋滃涓嬶細
the first test:i=1234
the secend test:i=1234; 0xabcd;j=5678;

鍥?/span>.搴旂敤
姹傛渶澶у?/span>:
#include //涓嶅畾鏁扮洰鍙傛暟闇瑕佺殑瀹?/span>
int max(int n,int num,...)
{
va_list x;//璇存槑鍙橀噺x
va_start(x,num);//x琚垵濮嬪寲涓烘寚鍚?/span>num鍚庣殑絎竴涓弬鏁?/span>
int m=num;
for(int i=1;i {
//灝嗗彉閲?/span>x鎵鎸囧悜鐨?/span>int綾誨瀷鐨勫艱祴緇?/span>y,鍚屾椂浣?/span>x鎸囧悜涓嬩竴涓弬鏁?/span>
int y=va_arg(x,int);
if(y>m)m=y;
}
va_end(x);//娓呴櫎鍙橀噺x
return m;
}
main()
{
printf("%d,%d",max(3,5,56),max(6,0,4,32,45,533));
}

 

鏈枃杞澆鑷綉涓婏紝鏈潵鏄娉ㄦ槑鍑哄鐨勶紝緇撴灉鍒漢涔熼兘鏄漿杞界殑錛屽懙鍛點備笉榪囨鏂囪鐨勫緢涓嶉敊錛屽緢娓呮錛岀壒鍒槸鎶婂彲鍙樺弬鏁板疄鐜扮殑閭e嚑涓畯錛佸伓涔熸槸鍐茬潃榪欏嚑涓畯鍘葷殑銆?/span>

#define _INTSIZEOF(n) ( (sizeof(n) + sizeof(int) - 1) & ~(sizeof(int) - 1) )
榪欎釜瀹忥紝涓寮濮嬫垜灝辨槸鎯充笉鏄庣櫧錛佷笉鐭ラ亾鏄佷簡錛岃繕鏄浜嗭紝鎴栬呮槸鐢熼攬浜嗐傛兂浜嗗ソ涓浼氳繕鏄病鎼炴槑鐧斤紝涓嶈繃鐪嬩簡涓涓嬫湰鏂囩殑鍒嗘瀽錛屼竴涓嬪瓙灝辨槑鐧戒簡錛岄偅鏄浉褰撶殑鎭嶇劧澶ф偀鍟娿?/span>

#define va_arg(ap,t) ( *(t *)((ap += _INTSIZEOF(t)) - _INTSIZEOF(t)) )

榪欎釜瀹忥紝涓寮濮嬩篃鏄病鏈夋槑鐧姐傚鐪嬩簡濂藉嚑閬嶆墠鍙戠幇浜嗗ゥ縐樻墍鍦ㄥ晩錛屼負浠涔堣鍔犱竴涓紝鐒跺悗鍐嶅噺涓涓憿錛熷洜涓虹涓涓姞鐩存帴鍔犲埌ap涓婂幓浜嗭紝鑰屽悗涓涓噺鍙槸鍑忎簡涓涓嬫嫭鍙峰唴鐨勫鹼紝涔熷氨鏄綋鍓嶅間簡銆?/span>

瀹忕湡鏄帀瀹沖晩錛佹垨鑰呰瀹冨簲鐢ㄧ湡騫匡紒榪欎笉紱佽鎴戞兂璧蜂互鍓嶇湅榪囩殑瀹忥紝鎬庝箞鍒ゆ柇鏄?/span>win榪樻槸linux騫沖彴鐨勶紝鎬庝箞鍒ゆ柇鏄?/span>32浣嶇殑榪樻槸64浣嶇殑銆傚畯鏄竴闂ㄥ闂晩銆?/span>

鏈枃鐨勫彟涓澶т紭鐐規槸錛屾湁闈炲父綆鍗曠殑渚嬪瓙錛岀湅浜嗗氨鎳傘傛仼銆傜湅浜嗕繚綆′綘灝變細鐢ㄤ簡銆備笉榪囪繖騫村ご鎸囬拡涔熸槸涓ソ涓滆タ鍟婏紝闇瑕佷粈涔堬紝浼犱釜鎸囬拡灝辨槸浼犱簡涓鍒囨兂瑕佺殑涓滆タ鍟婏紝鍙璁╂寚閽堟寚鍚戜綘闇瑕佺殑涓滆タ錛屽彲浠ユ槸浠繪剰澶氱殑鍙傛暟錛堜笉榪囪繖鏍峰瓙鐨勮瘽錛屽叿浣撳埌鍝釜鍙傛暟緇撴潫灝辮鎴戜滑鑷繁鏉ュ畾浜嗭紝涓嶅儚榪欓噷錛屾墍鏈夌殑鍙傛暟閮藉凡緇忓帇鏍堜簡錛岀紪璇戝櫒鍙互甯垜浠喅瀹氬叿浣撴湁澶氬皯涓弬鏁幫紝鍒頒粈涔堟椂鍊欑粨鏉燂級銆?/span>

Have fun.



kk 2007-04-10 10:38 鍙戣〃璇勮
]]>
Rational Rose 2003涓嬭澆鍦板潃http://www.shnenglu.com/jacky2019/archive/2007/04/10/21573.htmlkkkkTue, 10 Apr 2007 01:22:00 GMThttp://www.shnenglu.com/jacky2019/archive/2007/04/10/21573.htmlhttp://www.shnenglu.com/jacky2019/comments/21573.htmlhttp://www.shnenglu.com/jacky2019/archive/2007/04/10/21573.html#Feedback16http://www.shnenglu.com/jacky2019/comments/commentRss/21573.htmlhttp://www.shnenglu.com/jacky2019/services/trackbacks/21573.htmlhttp://www.21php.com/Rational Rose 2003.rar

鏄ㄦ櫄涓嬬殑錛岄熷害100K宸﹀彸

kk 2007-04-10 09:22 鍙戣〃璇勮
]]>
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
      <noscript id="pjuwb"></noscript>
            <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
              <dd id="pjuwb"></dd>
              <abbr id="pjuwb"></abbr>
              欧美黄在线观看| 欧美v日韩v国产v| 中文日韩在线| 欧美午夜一区| 欧美伊久线香蕉线新在线| 亚洲女女做受ⅹxx高潮| 国产午夜精品久久久| 久久精品视频一| 男人的天堂亚洲在线| 亚洲激情专区| 这里只有精品视频| 国产亚洲人成网站在线观看| 久久婷婷蜜乳一本欲蜜臀| 久久资源av| 亚洲午夜精品一区二区| 欧美亚洲一区二区三区| 亚洲国产高清高潮精品美女| 亚洲经典视频在线观看| 欧美高清视频一区二区| 亚洲欧美在线免费观看| 久久久精彩视频| 亚洲深夜激情| 欧美一区二区在线免费观看| 91久久午夜| 亚洲一二三区在线观看| 亚洲国产精品成人综合色在线婷婷| 亚洲欧洲一区二区天堂久久| 一区二区三区在线免费播放| 亚洲综合色网站| 另类图片国产| 欧美日韩亚洲综合在线| 久久国产精品毛片| 欧美日本国产| 久久久亚洲国产美女国产盗摄| 欧美成人资源网| 久久视频这里只有精品| 欧美人交a欧美精品| 久久激情综合| 欧美日韩国产一区二区| 老司机精品视频网站| 国产精品久久久久久超碰| 欧美激情精品久久久久久久变态| 国产精品三级视频| 亚洲毛片在线| 亚洲激情网站免费观看| 先锋影音久久| 新狼窝色av性久久久久久| 欧美精品一区二区三区蜜臀| 麻豆精品视频在线观看| 国产欧美日韩另类一区| 夜夜爽av福利精品导航 | 久久久在线视频| 国产精品私房写真福利视频| 亚洲精品中文字幕在线| 亚洲欧洲中文日韩久久av乱码| 久久久激情视频| 久久久99精品免费观看不卡| 国产精品久久久久影院色老大| 亚洲精品影视| 一本色道久久综合| 欧美精品久久久久久久免费观看| 美国成人直播| 亚洲成人在线视频播放| 久久在精品线影院精品国产| 免费亚洲一区| 亚洲欧洲三级电影| 欧美成人精品1314www| 亚洲丰满在线| 日韩视频久久| 欧美视频你懂的| 亚洲素人一区二区| 久久成人免费电影| 一区二区三区在线观看视频| 久久久久.com| 亚洲国产精品久久久久秋霞蜜臀| 亚洲国产另类 国产精品国产免费| 久久理论片午夜琪琪电影网| 女女同性精品视频| 亚洲美女尤物影院| 国产精品白丝av嫩草影院 | 嫩草影视亚洲| 99精品欧美一区二区三区| 欧美欧美全黄| 亚洲一区视频| 农村妇女精品| 99在线精品观看| 国产欧美日韩综合一区在线播放| 性欧美大战久久久久久久久| 免费不卡在线观看av| 亚洲精选在线| 国产欧美精品一区| 久久视频在线看| 一区二区三区高清在线观看| 欧美一区二区女人| 91久久精品国产91久久性色tv | 久久亚洲一区二区| 亚洲乱码国产乱码精品精天堂| 午夜日韩av| 亚洲国产成人久久| 国产精品萝li| 欧美极品一区二区三区| 亚洲一区日韩| 亚洲精品一区二区三区福利| 久久成人亚洲| 亚洲一级电影| 亚洲激情一区二区三区| 国产模特精品视频久久久久| 欧美电影免费观看高清完整版| 亚洲午夜一区| 亚洲精品在线观看免费| 久久亚洲国产精品日日av夜夜| 一区二区精品在线| 1024成人| 国产亚洲欧美日韩日本| 欧美日韩色婷婷| 欧美va亚洲va日韩∨a综合色| 亚洲一级黄色片| 日韩一区二区精品视频| 你懂的国产精品永久在线| 欧美在线一二三| 亚洲尤物精选| 一区二区三区鲁丝不卡| 亚洲激情在线观看| 亚洲电影免费观看高清完整版在线| 欧美性大战久久久久久久蜜臀 | 亚洲自拍偷拍麻豆| 国产精品99久久久久久www| 欧美激情1区2区3区| 久久久久免费| 欧美在线|欧美| 午夜精品国产精品大乳美女| 一区二区高清在线| 亚洲精品在线二区| 亚洲人体1000| 亚洲人成网站影音先锋播放| 在线免费观看一区二区三区| 国产亚洲激情在线| 国产一区二区三区久久精品| 国产精品麻豆va在线播放| 国产精品国产馆在线真实露脸| 欧美私人啪啪vps| 国产精品国产自产拍高清av| 国产精品国产三级国产普通话99 | 欧美日韩日本国产亚洲在线| 欧美久久久久久久久久| 欧美人与性动交α欧美精品济南到 | 久久精品人人做人人爽| 欧美在线欧美在线| 欧美专区18| 久久久久一区二区三区| 久久婷婷成人综合色| 老司机67194精品线观看| 欧美ed2k| 亚洲欧洲日本一区二区三区| 亚洲精品一二三| 正在播放亚洲| 欧美在线观看视频一区二区三区| 久久国产精品一区二区三区| 久久久久久久久综合| 欧美国产日韩一区| 欧美视频一区二区三区在线观看| 国产精品视频免费在线观看| 国产偷自视频区视频一区二区| 樱桃国产成人精品视频| 亚洲毛片一区| 午夜精品久久久久久| 久久一区二区三区超碰国产精品| 欧美成人一区在线| 99国产精品一区| 欧美一区二区三区视频| 猛干欧美女孩| 国产精品每日更新| 亚洲成人原创| 亚洲欧美日韩国产一区二区| 久久人人97超碰精品888| 亚洲国产精品99久久久久久久久| 99精品国产99久久久久久福利| 先锋影音网一区二区| 欧美福利网址| 国产一区二区三区免费观看| 日韩视频一区二区三区| 欧美在现视频| 日韩五码在线| 久久成人国产| 欧美性色aⅴ视频一区日韩精品| 国内精品久久久久久久果冻传媒| 夜夜嗨av一区二区三区网站四季av| 欧美影院在线| 一个色综合导航| 欧美成人午夜激情视频| 国产欧亚日韩视频| 一区二区精品| 亚洲高清久久| 久久精品夜夜夜夜久久| 国产精品国产福利国产秒拍 | 国产自产女人91一区在线观看| 在线性视频日韩欧美| 美日韩精品视频免费看| 午夜精品久久久久久| 欧美吻胸吃奶大尺度电影|