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

Hostodo商家提供两年大流量美国VPS主机 可选拉斯维加斯和迈阿密

Hostodo商家算是一个比较小众且运营比较久的服务商,而且还是率先硬盘更换成NVMe阵列的,目前有提供拉斯维加斯和迈阿密两个机房。看到商家这两年的促销套餐方案变化还是比较大的,每个月一般有这么两次的促销方案推送,可见商家也在想着提高一些客户量。毕竟即便再老的服务商,你不走出来让大家知道,迟早会落寞。目前,Hostodo有提供两款大流量的VPS主机促销,机房可选拉斯维加斯和迈阿密两个数据中心,且都...

HostKvm(4.25美)香港和俄罗斯高防机房云服务器

HostKvm 商家我们算是比较熟悉的国内商家,商家主要还是提供以亚洲数据中心,以及直连海外线路的服务商。这次商家有新增香港和俄罗斯两个机房的高防服务器方案。默认提供30GB防御,且目前半价优惠至4.25美元起步,其他方案的VPS主机还是正常的八折优惠。我们看看优惠活动。香港和俄罗斯半价优惠:2021fall,限购100台。通用优惠码:2021 ,八折优惠全部VPS。我们看看具体的套餐。1、香港高...

搬瓦工:新增荷兰机房 EUNL_9 测评,联通 AS10099/AS9929 高端优化路线/速度 延迟 路由 丢包测试

搬瓦工最近上线了一个新的荷兰机房,荷兰 EUNL_9 机房,这个 9 的编号感觉也挺随性的,之前的荷兰机房编号是 EUNL_3。这次荷兰新机房 EUNL_9 采用联通 AS9929 高端路线,三网都接入了 AS9929,对于联通用户来说是个好消息,又多了一个选择。对于其他用户可能还是 CN2 GIA 机房更合适一些。其实对于联通用户,这个荷兰机房也是比较远的,相比之下日本软银 JPOS_1 机房可...

browseui.dll为你推荐
招标编号:5106812018000248用户重庆Assumegraph支持ipad支持ipadgetIntjava尺寸(mm)操作區域手控图书馆学、情报学期刊投稿指南Descriptionios5重庆网通中国联通重庆分公司的公司简介
域名主机基地 西安服务器 bandwagonhost 轻博 彩虹ip 刀片服务器的优势 最好的免费空间 cdn加速原理 hktv 无限流量 免费ftp 购买空间 七牛云存储 广州主机托管 服务器防御 石家庄服务器 tracker服务器 免费赚q币 腾讯服务器 alexa世界排名 更多