http://www.tutorialspoint.com/dll/dll_quick_guide.htm

browseui.dll  时间:2021-05-24  阅读:()
Copyrighttutorialspoint.
comDLL-QUICKGUIDEDLL-QUICKGUIDEDLL-INTRODUCTIONDLL-INTRODUCTIONDynamiclinkingisamechanismthatlinksapplicationstolibrariesatruntime.
Thelibrariesremainintheirownfilesandarenotcopiedintotheexecutablefilesoftheapplications.
DLLslinktoanapplicationwhentheapplicationisrun,ratherthanwhenitiscreated.
DLLsmaycontainlinkstootherDLLs.
Manytimes,DLLsareplacedinfileswithdifferentextensionssuchas.
EXE,.
DRVor.
DLL.
AdvantagesofDLLGivenbelowareafewadvantagesofhavingDLLfiles.
UsesfewerresourcesDLLfilesdon'tgetloadedintotheRAMtogetherwiththemainprogram;theydon'toccupyspaceunlessrequired.
WhenaDLLfileisneeded,itisloadedandrun.
Forexample,aslongasauserofMicrosoftWordiseditingadocument,theprinterDLLfileisnotrequiredinRAM.
Iftheuserdecidestoprintthedocument,thentheWordapplicationcausestheprinterDLLfiletobeloadedandrun.
PromotesmodulararchitectureADLLhelpspromotedevelopingmodularprograms.
Ithelpsyoudeveloplargeprogramsthatrequiremultiplelanguageversionsoraprogramthatrequiresmodulararchitecture.
Anexampleofamodularprogramisanaccountingprogramhavingmanymodulesthatcanbedynamicallyloadedatrun-time.
AideasydeploymentandinstallationWhenafunctionwithinaDLLneedsanupdateorafix,thedeploymentandinstallationoftheDLLdoesnotrequiretheprogramtoberelinkedwiththeDLL.
Additionally,ifmultipleprogramsusethesameDLL,thenallofthemgetbenefitedfromtheupdateorthefix.
Thisissuemayoccurmorefrequentlywhenyouuseathird-partyDLLthatisregularlyupdatedorfixed.
ApplicationsandDLLscanlinktootherDLLsautomatically,iftheDLLlinkageisspecifiedintheIMPORTSsectionofthemoduledefinitionfileasapartofthecompile.
Else,youcanexplicitlyloadthemusingtheWindowsLoadLibraryfunction.
ImportantDLLFilesCOMDLG32.
DLL-Controlsthedialogboxes.
GDI32.
DLL-Containsnumerousfunctionsfordrawinggraphics,displayingtext,andmanagingfonts.
KERNEL32.
DLL-Containshundredsoffunctionsforthemanagementofmemoryandvariousprocesses.
USER32.
DLL-Containsnumeroususerinterfacefunctions.
Involvedinthecreationofprogramwindowsandtheirinteractionswitheachother.
DLL-HOWTOWRITEDLL-HOWTOWRITEFirst,wewilldiscusstheissuesandtherequirementsthatyoushouldconsiderwhiledevelopingyourownDLLs.
TypesofDLLsWhenyouloadaDLLinanapplication,twomethodsoflinkingletyoucalltheexportedDLLfunctions.
Thetwomethodsoflinkingare:load-timedynamiclinking,andrun-timedynamiclinking.
Load-timedynamiclinkingInload-timedynamiclinking,anapplicationmakesexplicitcallstotheexportedDLLfunctionslikelocalfunctions.
Touseload-timedynamiclinking,provideaheader.
hfileandanimportlibrary.
libfile,whenyoucompileandlinktheapplication.
Whenyoudothis,thelinkerwillprovidethesystemwiththeinformationthatisrequiredtoloadtheDLLandresolvetheexportedDLLfunctionlocationsatloadtime.
RuntimedynamiclinkingInruntimedynamiclinking,anapplicationcallseithertheLoadLibraryfunctionortheLoadLibraryExfunctiontoloadtheDLLatruntime.
AftertheDLLissuccessfullyloaded,youusetheGetProcAddressfunction,toobtaintheaddressoftheexportedDLLfunctionthatyouwanttocall.
Whenyouuseruntimedynamiclinking,youdonotneedanimportlibraryfile.
Thefollowinglistdescribestheapplicationcriteriaforchoosingbetweenload-timedynamiclinkingandruntimedynamiclinking:Startupperformance:Iftheinitialstartupperformanceoftheapplicationisimportant,youshoulduserun-timedynamiclinking.
Easeofuse:Inload-timedynamiclinking,theexportedDLLfunctionsarelikelocalfunctions.
Ithelpsyoucallthesefunctionseasily.
Applicationlogic:Inruntimedynamiclinking,anapplicationcanbranchtoloaddifferentmodulesasrequired.
Thisisimportantwhenyoudevelopmultiple-languageversions.
TheDLLEntryPointWhenyoucreateaDLL,youcanoptionallyspecifyanentrypointfunction.
TheentrypointfunctioniscalledwhenprocessesorthreadsattachthemselvestotheDLLordetachthemselvesfromtheDLL.
YoucanusetheentrypointfunctiontoinitializeordestroydatastructuresasrequiredbytheDLL.
Additionally,iftheapplicationismultithreaded,youcanusethreadlocalstorageTLStoallocatememorythatisprivatetoeachthreadintheentrypointfunction.
ThefollowingcodeisanexampleoftheDLLentrypointfunction.
BOOLAPIENTRYDllMain(HANDLEhModule,//HandletoDLLmoduleDWORDul_reason_for_call,LPVOIDlpReserved)//Reserved{switch(ul_reason_for_call){caseDLL_PROCESS_ATTACHED://AprocessisloadingtheDLL.
break;caseDLL_THREAD_ATTACHED://Aprocessiscreatinganewthread.
break;caseDLL_THREAD_DETACH://Athreadexitsnormally.
break;caseDLL_PROCESS_DETACH://AprocessunloadstheDLL.
break;}returnTRUE;}WhentheentrypointfunctionreturnsaFALSEvalue,theapplicationwillnotstartifyouareusingload-timedynamiclinking.
Ifyouareusingruntimedynamiclinking,onlytheindividualDLLwillnotload.
TheentrypointfunctionshouldonlyperformsimpleinitializationtasksandshouldnotcallanyotherDLLloadingorterminationfunctions.
Forexample,intheentrypointfunction,youshouldnotdirectlyorindirectlycalltheLoadLibraryfunctionortheLoadLibraryExfunction.
Additionally,youshouldnotcalltheFreeLibraryfunctionwhentheprocessisterminating.
WARNING:Inmultithreadedapplications,makesurethataccesstotheDLLglobaldataissynchronizedthreadsafetoavoidpossibledatacorruption.
Todothis,useTLStoprovideuniquedataforeachthread.
ExportingDLLFunctionsToexportDLLfunctions,youcaneitheraddafunctionkeywordtotheexportedDLLfunctionsorcreateamoduledefinition.
deffilethatliststheexportedDLLfunctions.
Touseafunctionkeyword,youmustdeclareeachfunctionthatyouwanttoexportwiththefollowingkeyword:__declspec(dllexport)TouseexportedDLLfunctionsintheapplication,youmustdeclareeachfunctionthatyouwanttoimportwiththefollowingkeyword:__declspec(dllimport)Typically,youwoulduseoneheaderfilehavingdefinestatementandanifdefstatementtoseparatetheexportstatementandtheimportstatement.
YoucanalsouseamoduledefinitionfiletodeclareexportedDLLfunctions.
Whenyouuseamoduledefinitionfile,youdonothavetoaddthefunctionkeywordtotheexportedDLLfunctions.
Inthemoduledefinitionfile,youdeclaretheLIBRARYstatementandtheEXPORTSstatementfortheDLL.
Thefollowingcodeisanexampleofadefinitionfile.
//SampleDLL.
def//LIBRARY"sampleDLL"EXPORTSHelloWorldWriteaSampleDLLInMicrosoftVisualC++6.
0,youcancreateaDLLbyselectingeithertheWin32Dynamic-LinkLibraryprojecttypeortheMFCAppWizarddllprojecttype.
ThefollowingcodeisanexampleofaDLLthatwascreatedinVisualC++byusingtheWin32Dynamic-LinkLibraryprojecttype.
//SampleDLL.
cpp#include"stdafx.
h"#defineEXPORTING_DLL#include"sampleDLL.
h"BOOLAPIENTRYDllMain(HANDLEhModule,DWORDul_reason_for_call,LPVOIDlpReserved){returnTRUE;}voidHelloWorld(){MessageBox(NULL,TEXT("HelloWorld"),TEXT("InaDLL"),MB_OK);}//File:SampleDLL.
h//#ifndefINDLL_H#defineINDLL_H#ifdefEXPORTING_DLLextern__declspec(dllexport)voidHelloWorld();#elseextern__declspec(dllimport)voidHelloWorld();#endif#endifCallingaSampleDLLThefollowingcodeisanexampleofaWin32ApplicationprojectthatcallstheexportedDLLfunctionintheSampleDLLDLL.
//SampleApp.
cpp#include"stdafx.
h"#include"sampleDLL.
h"intAPIENTRYWinMain(HINSTANCEhInstance,HINSTANCEhPrevInstance,LPSTRlpCmdLine,intnCmdShow){HelloWorld();return0;}NOTE:Inload-timedynamiclinking,youmustlinktheSampleDLL.
libimportlibrarythatiscreatedwhenyoubuildtheSampleDLLproject.
Inruntimedynamiclinking,youusecodethatissimilartothefollowingcodetocalltheSampleDLL.
dllexportedDLLfunction.
.
.
.
typedefVOID(*DLLPROC)(LPTSTR);.
.
.
HINSTANCEhinstDLL;DLLPROCHelloWorld;BOOLfFreeDLL;hinstDLL=LoadLibrary("sampleDLL.
dll");if(hinstDLL!
=NULL){HelloWorld=(DLLPROC)GetProcAddress(hinstDLL,"HelloWorld");if(HelloWorld!
=NULL)(HelloWorld);fFreeDLL=FreeLibrary(hinstDLL);}.
.
.
WhenyoucompileandlinktheSampleDLLapplication,theWindowsoperatingsystemsearchesfortheSampleDLLDLLinthefollowinglocationsinthisorder:TheapplicationfolderThecurrentfolderTheWindowssystemfolder(TheGetSystemDirectoryfunctionreturnsthepathoftheWindowssystemfolder).
TheWindowsfolder(TheGetWindowsDirectoryfunctionreturnsthepathoftheWindowsfolder).
DLL-REGISTRATIONDLL-REGISTRATIONInordertouseaDLL,ithastoberegisteredbyhavingappropriatereferencesenteredintheRegistry.
ItsometimeshappensthataRegistryreferencegetscorruptedandthefunctionsoftheDLLcannotbeusedanymore.
TheDLLcanbere-registeredbyopeningStart-Runandenteringthefollowingcommand:regsvr32somefile.
dllThiscommandassumesthatsomefile.
dllisinadirectoryorfolderthatisinthePATH.
Otherwise,thefullpathfortheDLLmustbeused.
ADLLfilecanalsobeunregisteredbyusingtheswitch"/u"asshownbelow.
regsvr32/usomefile.
dllThiscanbeusedtotoggleaserviceonandoff.
DLL-TOOLSDLL-TOOLSSeveraltoolsareavailabletohelpyoutroubleshootDLLproblems.
Someofthemarediscussedbelow.
DependencyWalkerTheDependencyWalkertool(depends.
exe)canrecursivelyscanforallthedependentDLLsthatareusedbyaprogram.
WhenyouopenaprograminDependencyWalker,theDependencyWalkerperformsthefollowingchecks:ChecksformissingDLLs.
ChecksforprogramfilesorDLLsthatarenotvalid.
Checksthatimportfunctionsandexportfunctionsmatch.
Checksforcirculardependencyerrors.
Checksformodulesthatarenotvalidbecausethemodulesareforadifferentoperatingsystem.
ByusingDependencyWalker,youcandocumentalltheDLLsthataprogramuses.
ItmayhelppreventandcorrectDLLproblemsthatmayoccurinthefuture.
DependencyWalkerislocatedinthefollowingdirectorywhenyouinstallMicrosoftVisualStudio6.
0:drive\ProgramFiles\MicrosoftVisualStudio\Common\ToolsDLLUniversalProblemSolverTheDLLUniversalProblemSolverDUPStoolisusedtoaudit,compare,document,anddisplayDLLinformation.
ThefollowinglistdescribestheutilitiesthatmakeuptheDUPStool:Dlister.
exe-ThisutilityenumeratesalltheDLLsonthecomputerandlogstheinformationtoatextfileortoadatabasefile.
Dcomp.
exe-ThisutilitycomparestheDLLsthatarelistedintwotextfilesandproducesathirdtextfilethatcontainsthedifferences.
Dtxt2DB.
exe-ThisutilityloadsthetextfilesthatarecreatedbyusingtheDlister.
exeutilityandtheDcomp.
exeutilityintothedllHelldatabase.
DlgDtxt2DB.
exe-ThisutilityprovidesagraphicaluserinterfaceGUIversionoftheDtxt2DB.
exeutility.
DLL-TIPSDLL-TIPSKeepthefollowingtipsinmindwhilewritingaDLL:UsepropercallingconventionCorstdcall.
Beawareofthecorrectorderofargumentspassedtothefunction.
NEVERresizearraysorconcatenatestringsusingtheargumentspasseddirectlytoafunction.
Remember,theparametersyoupassareLabVIEWdata.
ChangingarrayorstringsizesmayresultinacrashbyoverwritingotherdatastoredinLabVIEWmemory.
YouMAYresizearraysorconcatenatestringsifyoupassaLabVIEWArrayHandleorLabVIEWStringHandleandareusingtheVisualC++compilerorSymanteccompilertocompileyourDLL.
Whilepassingstringstoafunction,selectthecorrecttypeofstringtopass.
CorPascalorLabVIEWstringHandle.
Pascalstringsarelimitedto255charactersinlength.
CstringsareNULLterminated.
IfyourDLLfunctionreturnsnumericdatainabinarystringformatforexample,viaGPIBortheserialport,itmayreturnNULLvaluesasapartofthedatastring.
Insuchcases,passingarraysofshort8bitintegersismostreliable.
Ifyouareworkingwitharraysorstringsofdata,ALWAYSpassabufferorarraythatislargeenoughtoholdanyresultsplacedinthebufferbythefunctionunlessyouarepassingthemasLabVIEWhandles,inwhichcaseyoucanresizethemusingCINfunctionsunderVisualC++orSymanteccompiler.
ListDLLfunctionsintheEXPORTSsectionofthemoduledefinitionfileifyouareusing_stdcall.
ListDLLfunctionsthatotherapplicationscallinthemoduledefinitionfileEXPORTSsectionortoincludethe_declspecdllexportkeywordinthefunctiondeclaration.
IfyouuseaC++compiler,exportfunctionswiththeextern.
C.
{}statementinyourheaderfileinordertopreventnamemangling.
IfyouarewritingyourownDLL,youshouldnotrecompileaDLLwhiletheDLLisloadedintothememorybyanotherapplication.
BeforerecompilingaDLL,ensurethatallapplicationsusingthatparticularDLLareunloadedfromthememory.
ItensuresthattheDLLitselfisnotloadedintothememory.
Youmayfailtorebuildcorrectlyifyouforgetthisandyourcompilerdoesnotwarnyou.
TestyourDLLswithanotherprogramtoensurethatthefunctionandtheDLLbehavecorrectly.
TestingitwiththedebuggerofyourcompilerorasimpleCprograminwhichyoucancallafunctioninaDLLwillhelpyouidentifywhetherpossibledifficultiesareinherenttotheDLLorLabVIEWrelated.
DLL-EXAMPLESDLL-EXAMPLESWehaveseenhowtowriteaDLLandhowtocreatea"HelloWorld"program.
ThatexamplemusthavegivenyouanideaaboutthebasicconceptofcreatingaDLL.
Here,wewillgiveadescriptionofcreatingDLLsusingDelphi,BorlandC++,andagainVC++.
Letustaketheseexamplesonebyone.
HowtowriteandcallDLL'swithinDelphiMakingDLL'sfromtheBorlandC++BuilderIDEMakingDLL'sinMicrosoftVisualC++6.
0Loading[MathJax]/jax/output/HTML-CSS/jax.
js

Gigsgigscloud($9.8)联通用户优选日本软银VPS

gigsgigsCloud日本东京软银VPS的大带宽配置有100Mbps、150Mbps和200Mbps三种,三网都走软银直连,售价最低9.8美元/月、年付98美元。gigsgigscloud带宽较大延迟低,联通用户的好选择!Gigsgigscloud 日本软银(BBTEC, SoftBank)线路,在速度/延迟/价格方面,是目前联通用户海外VPS的最佳选择,与美国VPS想比,日本软银VPS延迟更...

sharktech:洛杉矶/丹佛/荷兰高防服务器;1G独享$70/10G共享$240/10G独享$800

sharktech怎么样?sharktech (鲨鱼机房)是一家成立于 2003 年的知名美国老牌主机商,又称鲨鱼机房或者SK 机房,一直主打高防系列产品,提供独立服务器租用业务和 VPS 主机,自营机房在美国洛杉矶、丹佛、芝加哥和荷兰阿姆斯特丹,所有产品均提供 DDoS 防护。不知道大家是否注意到sharktech的所有服务器的带宽价格全部跳楼跳水,降幅简直不忍直视了,还没有见过这么便宜的独立服...

UCloud 618活动:香港云服务器月付13元起;最高可购3年,AMD/Intel系列

ucloud6.18推出全球大促活动,针对新老用户(个人/企业)提供云服务器促销产品,其中最低配快杰云服务器月付5元起,中国香港快杰型云服务器月付13元起,最高可购3年,有AMD/Intel系列。当然这都是针对新用户的优惠。注意,UCloud全球有31个数据中心,29条专线,覆盖五大洲,基本上你想要的都能找到。注意:以上ucloud 618优惠都是新用户专享,老用户就随便看看!点击进入:uclou...

browseui.dll为你推荐
应用程序ios6cyclesios8output_buffering飞飞的官方网站是啥齐鲁工业大学高水平学科建设专项地址163googleadsense我申请Google AdSense要怎样才能通过Google AdSense呀?kb4012598win7怎么查看电脑是否安装了 ms17 010迅雷雷鸟迅雷会员每日免费抽奖,抽中迅雷的雷鸟披肩了,要钱吗ipad无法加入网络为什么我的ipad加入网络没法用微信5.0是哪一年的新版微信5.0如何登录网页版微信
个人注册域名 互联网域名管理办法 174.127.195.202 警告本网站 云鼎网络 怎么测试下载速度 789电视网 稳定免费空间 中国电信测速网 ftp免费空间 河南移动梦网 starry 电信网络测速器 阿里云手机官网 privatetracker 512内存 带宽测速 阿里云宕机故障 cc攻击 西安电信测速网 更多