Time of Update: 2018-12-05
DLL定義的全域變數可以被調用進程訪問;DLL也可以訪問調用進程的全域資料 1、在dll的project中的cpp檔案中添加一個全域變數。如:在dynamic.cpp中#include "stdafx.h"#include "dynamic.h"int dllGlobalVar;int __declspec(dllexport) add(int x, int y){return x - y;}2、在dynamic.h中#ifndef DYNAMIC_H#define
Time of Update: 2018-12-05
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace Argument{ /// <summary> /// C#預設情況下,實參是值傳遞 /// 為了用引用的方式傳遞參數,C#提供ref參數修飾符 /// 參數可以以值或者引用的方式傳遞給函數,而無需考慮其本身是實值型別還是參考型別 /// out修飾符,與ref相似,但1、
Time of Update: 2018-12-05
最近一直在做驅動檔案結構研究和安裝包的製作,經過一段時間的資料收集和學習,目前已經基本清楚了Inf檔案的結構,也製作了驅動的安裝包。由於本人文筆不好,下面直接說一下如何做驅動安裝包。 win7安裝沒有經過簽名的驅動需要先讓OS進入“測試模式”:首先以管理員身份運行cmd;然後輸入bcdedit/set testsigning on(有的也輸入bcdedit.exe/set testsigning
Time of Update: 2018-12-05
今天學習了其它大牛的歸併演算法分析和常式,然後參照相應資料,也寫了個非遞迴實現的歸併演算法,記錄下來,便於自己以後的複習:template<class T>void Merge(T src[],T dest[],int iSrcStart, int iSrcEnd,int iSrcArrLength)//因為src中含有兩個分別有序的序列,所以需要傳入參數告知兩個序列的起始{ int i=iSrcStart-1; int k=iSrcStart;//dest index int j=
Time of Update: 2018-12-05
1、建立工程,選擇win32 project2、建立項目,如:staticLib.h和staticLib.cpp在staticLib.h中添加代碼:#ifndef STATICLIB_H#define STATICLIB_Hextern "C" int add(int, int);#endif在staticLib.cpp檔案中加入代碼:#include "stdafx.h"#include <Windows.h>#include "..\staticLib\staticLib.h"#
Time of Update: 2018-12-05
看了一篇blog文章“摘:VC編碼規範 ”(http://blog.csdn.net/lts007007/archive/2006/01/05/571377.aspx),有幾點意見:函數名中用底線,我覺得不好,ceate_point()我覺得可以寫成CreatePoint(),這樣的風格才是Windows API風格,我覺得可以借用。反擴號的注釋內容“}//end
Time of Update: 2018-12-05
來自http://www.vckbase.com/bbs/prime/viewprime.asp?id=412下面的回複非常精彩。 /** * Create a metafile that contains the plotting graph. */HENHMETAFILE createEnhMetaFile(){HDC hdc;RECT rc, rcImg;int cxMms, cyMms, cxPix, cyPix;HENHMETAFILE hemf;hdc = GetDC(hwndCli
Time of Update: 2018-12-05
文章目錄 Remembering the PurposeA Matter of ApproachWhat to Do If You're a DeveloperWhen Code Reviews Aren't Face-to-FaceConclusionAbout the Author
Time of Update: 2018-12-05
題意:給一個1*M的棋盤,上面有N顆棋子,每次只能向左移動棋子,並且至少移動一步,兩人輪流操作,誰不能移動誰就輸了。 分析這題的P/N點時,和往常不一樣,不是從小資料推測,而是直接從性質推測,從右往左,把棋子分為兩兩一組,如果是奇數顆棋子,就補第一顆的位置為0,當對手移動兩顆棋子的左邊的棋子時,我們只需要把右邊這顆棋子移動相同的步數就行,當對手移動右邊的棋子時,把兩顆棋子之間的距離看為石子的個數,我們只需按照取石子的規則走就行。
Time of Update: 2018-12-05
參見http://www.experts-exchange.com/Programming/Programming_Languages/Cplusplus/Q_20513227.html 用ATL 添加一個"ATL Simple Object" 叫MyObject 這個時候想建立一個勢力 MyObject *ptr = new Myobject(); ) 編譯的時候會有這樣的錯誤: "Error C2259 cannot instantiate abstract
Time of Update: 2018-12-05
class wizard出錯與c++文法出錯沒有關係class wizard根據//{{來尋找插入函數的入口,所以,如果//{{出現的次數有多次,就出錯了.需要注意的是,幾時是被注釋掉的代碼,對class wizard也有影響,雖然編譯能通過.參見http://www.codeguru.com/forum/archive/index.php/t-112218.htmlCheck that you have only one of each of these in
Time of Update: 2018-12-05
“Sprague-Grundy函數”我們將面對更多與Nim遊戲有關的變種,還會看到Nim遊戲的a1^a2^...^an這個值更廣泛的意義。上面的文章裡我們仔細研究了Nim遊戲,並且瞭解了找出必勝策略的方法。但如果把Nim的規則略加改變,你還能很快找出必勝策略嗎?比如說:有n堆石子,每次可以從第1堆石子裡取1顆、2顆或3顆,可以從第2堆石子裡取奇數顆,可以從第3堆及以後石子裡取任意顆……這時看上去問題複雜了很多,但相信你如果掌握了本節的內容,類似的千變萬化的問題都是不成問題的。現在我們來研究一個看
Time of Update: 2018-12-05
Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number.An example is the root-to-leaf path 1->2->3 which represents the number 123.Find the total sum of all root-to-leaf numbers.For example, 1
Time of Update: 2018-12-05
AfxGetMainWnd返回NULL也是有可能的。因為_AFXWIN_INLINE CWnd* AFXAPI AfxGetMainWnd() { CWinThread* pThread = AfxGetThread(); return pThread != NULL ? pThread->GetMainWnd() : NULL; }而CWnd* CWinThread::GetMainWnd(){ if (m_pActiveWnd != NULL) return
Time of Update: 2018-12-05
遇到好幾個人說CMap在用CString做key類型時有問題,說用int和DWORD就可以,用CString就不行。因此很多人推薦使用MFC中的CMapStringToPtr之類。看下面的代碼://.h CMap<CString, LPCTSTR, int, int> typeMap;//.cpp typeMap.SetAt(_T("ONE"),1); typeMap.SetAt(_T("TWO"),2); int nValue = 0; BOOL
Time of Update: 2018-12-05
__stdcall約定 如果通過VC++編寫的DLL欲被其他語言編寫的程式調用,應將函數的調用方式聲明為__stdcall方式,WINAPI都採用這種方式,而C/C++預設的調用方式卻為__cdecl。__stdcall方式與__cdecl對函數名最終產生符號的方式不同。若採用C編譯方式(在C++中需將函式宣告為extern
Time of Update: 2018-12-05
是我在網上搜到的,zz一下。原作者是李漢鵬,找不到原文出去了,都是zz了好幾趟的。去掉討厭的異常警告 在程式中使用了CHtmlView以後,我們在調整視窗大小的時候經常會看到輸出視窗輸出的異常警告: ReusingBrowser.exe 中的 0x77e53887 處最可能的異常: Microsoft C++ exception: COleException @ 0x0012e348 。 Warning: constructing COleException, scode = DISP_E_
Time of Update: 2018-12-05
多態,不同的對象收到同一訊息可以產生不同的結果,這種現象叫做多態。多態的布控形式:多重參數變形,包含多態,過載多態,強制多態。其中前兩者稱為通用多態,後兩者稱為特定多態。強制多態(coercion)
Time of Update: 2018-12-05
彈珠小程式 import java.util.*;import java.awt.*;import java.awt.event.*;import java.awt.event.KeyAdapter.*;import java.awt.event.WindowAdapter.*;public class PinBall{private final int WIDTH = 300;private final int HEIGHT = 400;private final int RACKET_Y =
Time of Update: 2018-12-05
#define EXCHANGE(a, b) (a)=(a)^(b);\(b)=(b)^(a);\(a)=(b)^(a)void oddEvenNum(vector<int>& nums){int oddEnd = 0;int evenEnd = 0;while(evenEnd < nums.size()){if(nums[evenEnd] % 2){if(oddEnd != evenEnd){EXCHANGE(nums[oddEnd], nums[evenEnd]);