Feem ntau ib. NET tus programmer tau ntsib txoj haujlwm ntawm kev siv cov haujlwm ntawm lub zog DLL sau los ntawm lwm tus tsim tawm hauv cov cai tsis muaj tswj. Qee zaum cov haujlwm ntawm lub tsev qiv ntawv no tuaj yeem ua tau ntau yam, dav heev. Tsim nyog sau npe txhua chav kawm, kev ua haujlwm, tsis tu ncua, thiab lwm yam hauv koj txoj haujlwm. - lub sijhawm ntev heev. Zoo hmoo, muaj cov khoom siv uas qee qhov kho cov txheej txheem no. Peb yuav tham txog ib qho ntawm lawv.
Tsim nyog
- - PC nrog Visual Studio 2008/2010;
- - Is Taws Nem.
Cov Lus Qhia
Kauj ruam 1
Yog tias koj muaj lub tsev qiv ntawv zoo *.dll sau rau hauv cov cai tsis raug tswj, piv txwv li, hauv C lossis C ++, nrog rau nws cov ntaub ntawv header, thiab koj yuav tsum tshaj tawm tag nrho cov ntawv qiv tsim hauv koj txoj haujlwm, tom qab ntawv zoo heev tov rau koj tuaj yeem yog PInvoker twj. PInvoker muaj kev ywj pheej muab faib ua kev ncua rau Visual Studio IDE (cov qauv xyoo 2005, 2008 thiab 2010 tau txais kev txhawb nqa), ntxiv rau daim ntawv thov ib leeg.
Ua haujlwm nrog nws yog yooj yim thiab yooj yim. PInvoker ntshuam PInvoke cov ntsiab lus rau kev tswj hwm C # lossis VB. NET code los ntawm C / C ++ header files thiab lawv cov DLL uas cuam tshuam. Koj tsuas yog yuav tsum xaiv los ntawm daim ntawv teev cov kev ua haujlwm, qauv, kev suav, tas li, tus sawv cev, thiab lwm yam. xav tau thiab mas nkag rau hauv koj qhov project.
Ua ntej koj yuav tsum rub tawm thiab nruab PInvoker. Rub tawm PInvoker.msi installer lossis PInvokerAddin.msi txuas ntxiv rau Visual Studio los ntawm cov vev xaib raug cai. Kuv xav tias qhov no tsis yog ib qho teeb meem. Tsuas yog khiav cov ntaub ntawv koj xav tau thiab ua raws li cov lus qhia.
Kauj ruam 2
Cia peb saib qhov piv txwv ntawm yuav ua li cas ua haujlwm nrog cov cuab yeej tseem ceeb no. Pib Nrig Pom Kev Studio, tsim qhov project tshiab. Ib yam khoom tshiab tau ntxiv rau Cov Cuab Yeej -> Cov Cuab Yeej Cuab Yeej: PInvoker. Nyem rau nws thiab PInvoker Addin chaw qhib lub qhov rai yuav qhib. Xaiv yam lus ntawm koj qhov project Lus: C # lossis VB. NET. Nyob rau hauv Profiles daim ntawv teev npe-xaiv, xaiv hloov kho cov profiles.
Kauj ruam 3
Lub qhov rai profile tswj hwm yuav qhib. Xaiv Tsim Tsim ib cov ntaub ntawv ntshuam tshiab thiab nyem Next.
Kauj ruam 4
Tam sim no koj xav tau ntxiv cov ntawv header. Koj tuaj yeem rub thiab nqis lawv rau ntawm PInvoker Profiles Wizard qhov rai. Tom ntej no, sau lub npe chaw uas cov ntaub ntawv no khaws cia.
Kauj ruam 5
Cov kauj ruam tom ntej yog los teev lub tsev qiv ntawv dynamic nws tus kheej. Koj tseem tuaj yeem nyab xeeb nws nrog tus nas rau ntawm lub qhov rais ntawm PInvoker profile wizard.
Kauj Ruam 6
Tom qab txhaj rau Qhov Finish khawm, txheej txheem ntawm kev ntshuam cov lus txhais los ntawm lub tsev qiv ntawv dynamic xaiv yuav pib. Cov tiav tiav ntawm kev khiav hauj lwm yuav qhia los ntawm inscription Ntshuam tiav thiab cov npe npe ntawm kev khiav dej num los ntawm DLL uas tshwm hauv qhov chaw seem.
Kauj Ruam 7
Tam sim no koj tuaj yeem yooj yim import PInvoke cov ntsiab lus rau hauv koj qhov project. Hauv daim teb sab laug (1), nyob hauv Hom Chaw, xaiv hom: haujlwm, txheej txheem, qauv, enumeration, tas li, tus sawv cev, thiab lwm yam. Nyob rau hauv Lub Npe Sau, xaiv lub npe ntawm tus qauv tsim nyog. Los ntawm ib qho nyem, nws cov lus piav qhia yuav tshwm sim hauv nruab nrab ntawm PInvoker qhov rai (2). Ob npaug - yuav qhib nws cov lus txhais hauv cov ntawv header. Txhawm rau Insert Insert khawm (3) yuav nkag rau cov lus txhais rau koj C # / VB. NET project. Tam sim no koj tuaj yeem siv cov DLL txawv teb hauv koj txoj haujlwm.