C語言的DLL編寫與調(diào)用_第1頁
C語言的DLL編寫與調(diào)用_第2頁
C語言的DLL編寫與調(diào)用_第3頁
已閱讀5頁,還剩4頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認(rèn)領(lǐng)

文檔簡介

1、C語言的DLL編寫1、打開C語言的MicrosoftVisualC+6.0MicrosoftVisuaC+6j肉Micro知仕VisualC+6.0Tools迅雷軟件IrrtelliIDEAJavaJavaDevelopmentKtMicrosoftVisuaJ£+6.QMicrosoftVisualSourceSafeMicrosoftOffice皓匏音樂MicrosoftVisualBas<6.0中文版MicrosoftWebPdbii&hingAdobeReaderXIMEdtosearyCdethS;這里換成海ftH:CpragrarnFilesMicrosSr

2、uchmCOIM心IIWSD398'E2、選擇file->new,在project選項中選擇MFCAppWizard(dll),給工程起名字,選擇保存路徑。3、選擇RegularDLLusingsharedMFCDLL,點擊finish4、此時工程的結(jié)構(gòu)圖如下所示*FourthSample-MicrosoftVisualC斗4卜-Fcurl|BFileEditViewInsertProjectBudTools匚tt)歹Ml質(zhì)ICFourthSampIc/AllclassmemberEjAjX|Key=【W(wǎng)orkspace'FourthSampI予FourthSamplef

3、iles-!_JSourceFiles土FourthSamplc*c:國FourthSample.di國FourthSample.rc蜀SldAfx.cpp-_jHeaderFiles司FourthSample,h畫Resource.bHStdAfx.h尋白ResourceFiles旦】FourthSample.rcReadMe.bde':1prHHMIBIliiBJIIIIKIIIBp!f?FILE*PROFILEFILEFILEFILEFILEBlocComComFilerFileVInterLcgaLegaOrigiPrivtProdq匚nrkProd.匕CIwm二JsiFtg。

4、jjFileViSpec5、在FourthSample源文件中寫上對外暴露的dll函數(shù)方法,;iWorkspace"FourthSamiple1;1pi二圖FourthSamplefilesl±J如也4HIggI崗:IliUrHiSBniplu.cijpil|groHrthfittmpk.drfElFourthsarnph.rc畫SldAhc.qip3-!JHeaderFilesIElourthairnplle.h|gRe£grwh由曲心iLjrteaflurccFiiilci三FngirthSmpinS|RdMe.hd:EN0lE£SME_ri&quo

5、t;)HCJFnurthainprflppenntructinnUI-uurthari|j1vApp::lFilurthjii|jlefl!pp()HMilconrructlnncodelierpt/PlaceallsignificantinitializatianinInitlnstanceftllhsoneanduinljjiCFourthS-diiipIeAppobjectCTuurIhS-dnri|jIMppthiApii;mIprn"T'punTdhM|iart_)4riF<E:sagfB0X<HULLTiMhelLouorldldeno",C

6、4JIDKJ-;Rm材|gni#vi.|6、在FourthSample.def中追加對外暴露的方法名ohnlaj|件gMFnmllWDrkspscc"FouiihSample1:IprHFourthSamplefiles=_jSourcerilre.FaurthSampIc.cpp:-KJ卜ourthMfjmple.detSFOurtKSample.ftjS<ilACccpi|jA_jHejidprFIIm.司F«iirthSnmp)e.h3Htcource.h目StilAbcIiAl_iResimrcrTiles=.InnrrhSnmplE-rr?唐ReadMe.M

7、Jj|m叫K-甲幽山1算丐|:iourthjnple-dM:DeclaresthenoduleparimeterslortheULL.L1GRARV"FOurtliSdFqjl#"&CSCRIPT1UH'fQurthSnpleUindovUynqFiicLinkLibrary'EXPORTS,:LxuliZltIXPdDrr53CqohPfeuuL_iiunOI7、選中FourthSample.cpp,編譯源文件FourthSample-MicrosoftVisualC+-FourthSampte.cpp3FileEditViewInsertPraj

8、art|宣訕蛆工也ndemH北與o;U0X昭嘻CompteFourthSample.cppCtrkF7vancedPGlobalsl.RuildFoufthSample.dIIjJ同1W幽RehulkiAlH=BatctiBuildF78、Workspace'FourthSample*白FoiuirthSamplefilest_3SourceFiles-FnurthSmnlr:.rnnl匿FourthSample,del卻FourthSamiplc.n:吾StdAfx.cppJHeaderFiles司FourthSampIch回Resource.h司StdAlx.hJResourceF

9、iles司FourthSample.rc2國ReadMe.txt生成dll文件r/Startbug卜istructiDebuggerRemoteCoinaction.thSanpl!CtrkF5uttionActeCori15gLimon.Configurstions.,FicantiProfife./TheoneandonlyCFourtharCFourthSampleApptheApp;extern"C*rvoiddclspecfMessageBox(NULLrMhello«orFourthsample-Micr<xsvftVisualC+-FcurthSampl

10、e.cppl0Fi-iEetInsultProj&rt|BuidTa&i已希。wi咨h國x電)嚏i二繆£onrpInF口urth牝nnple.匚|?p切十F7BuiidFourthSampeJiiF7vancedParGlobalsJfALU盅賢瓦ild-BarctiBjjid11Workspace'FourthSample*Cesri色®IFourthSamplefiles-盤SourceFiles1!-固FourthSamole.cSt3rtDebug尻DebuggerRemoteConnection.istructiorthSmple國Four

11、thSsmple.defI它妨丑廣己fi志|F.urthS打mple.rc:2StdAtxxpp-HeaderAles;司FourthSsmpk.hMResource.h國StdAfx,hResourceFilesM|FaurthSample.rc?宣RedMe.txtl±J_ExternalDependenciesSetAu界Cngurstion.Configuratmns.Profile,.,9、注意事項:在編譯源文件時可能要報以下錯誤,CtrF5actionc.Ficantin/"TheoneandunlyCFourtt)$npCFourthSampleApptheA

12、pp;extern"C*1uoiddeclspec(MessageBox(NULL,"helloworlRfl111時:讓詢古鼻】fjikiilfrnrHIifln-ndHMHMpra|Hnr<-HpLIrrlMMrrfilrFPcftuq/FHurthdRilF*sTmrnrruCliiil<1AuritiiidiilP-.o*J-IfnrArCGlirthirnlngiCs)解決方法:選中該源文件,點擊右鍵Settings,END_MESSfiGE_HfiP()OienConpleFoutbSawle.cppSettings.FotJrthSanDockin

13、gVsdideWorkspace'FourthSampic':1pr-FourthSampletiles§0SourceJ;ilesIL-bFuurthSan閔FourfhSan禽StdAfx.cp-HeaderFiles!;5,司司Resource.'司StdAtx.h-白ResourceFil旦竺蘭司FmurtfiSamplem2圄RcadMe.txt/ffCFourthSanpieAppconstructionmpleApp:CFourthSampleADO:addconstructioncoac£-llsigni-Flcntini/eando

14、nlpCFourthSanplnplePpp肥heApp;extern"C"uoid_declspec(dH&ssageBox(NULL,''helloworld再次編譯,通過。C語言調(diào)用DLL1、新建一個c的源文件,進行dll調(diào)用的測試2、源代碼如下,代碼中有關(guān)鍵詞用法,請參考其他資料3、彈出一個對話框,說明dll調(diào)用成功。|商曰aMdfc劃ewpiaeit臼京u|蟲jfcjToolsWmcoHelp|Globals匚費板。Tip<jFfijiSanole.k+FTF7S尊1FifthSampIcclasses-QuidFrfthSBmple+*xerl削仲|(zhì)畫曲典aiBatchBd.CeindvaiiccdPflfam3*二|包,S:artDebug-MULL;肚i喝I、,_BC-jii"ec:ic-i.LEKwetEFeiSample.我電Cm+F5|ifararj|("tPSt.ilLL&quo

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論