Build SO step by step文档格式.docx
- 文档编号:7149948
- 上传时间:2023-05-08
- 格式:DOCX
- 页数:12
- 大小:881.14KB
Build SO step by step文档格式.docx
《Build SO step by step文档格式.docx》由会员分享,可在线阅读,更多相关《Build SO step by step文档格式.docx(12页珍藏版)》请在冰点文库上搜索。
Download
DownloadControlObject(CO)implemetionfrom
Ihavedownloadthethreefilesfor1.7.001.Thethirdone,SourceCodeandDataFiles,isveryusefulinthedevelopingdebug.Stronglyrecommendyoudownloadit.
STEP2:
Install
InstalltheOPOSCCO.Selectadirectoryandinstall“CCORuntime”and“CCOSourceCodeandDataFiles”.
STEP3:
MakeCCOprojectwork
ThereisVisualC++Workspaceinthesubdirectory,“\source”.Makeitrun.
Itmayencountersomefilepositionerrorswhenrunningtheproject.Findthecorrectfilespositionandmakesureitbuildanew.OCXfileinthe“Source\OCX\Debug”.Hereisscreenimage.
STEP4:
RegisterCOOCX
RegisterthenewOCX.Commandis:
>
regsvr32xxxx.ocx
STEP5:
CreateClientApplication
BuildanormaldialogapplicationastheCOclient.
Thesimplerelationamongclientapplication,CO,ServiceObject(SO)isthatclientcallCOmethod,thenCOcallSOmethod.SoyouneedaclientapplicationfordebugSO.
Step5.0:
AddOPOSincludingfilestotheclientproject
Opos.h
OposPpad.h
Addingdifferentfilesintheotherdevices.
Step5.1:
5.1.0AddtheOCXtotheclientprojectfromthemenu:
Project/AddtoProject/ComonentsandControls
5.1.1theninserttherightActiveXControl.
step5.2
5.2.0InsertaOPOSCOtothedialog.
5.2.1Insertabuttontothedialog.Asfollowing:
5.2.2AddamembervariablefortheOPOScontrol.
Tohere,theclientisready.
STEP6.CreateSO
CreateanewMFCAppWizarDLLProject.
Checkthe“Automation”inthestep1of1.
Step6.0
AddCOclassfromaTLBfilewithMFCClassWizard.
ThisTLBfilelocateinthedirectory“\Source\zPINPad”inthisexample.
thisCOclassisusedwhenSOfiretheEvent.
Step6.1Addinterface.
WithClassWizard,add“newclass”derivedfromCCmdTarget,checkthe“CreateabelbytypeID”
Nowyougetanewclassandainterface.InthisexampletheyareIDTPINPad,IIDTPINPad.
NOTE:
ID:
PINPadSO.IDTPINPad
Youspecifyit,andthisIDistheregisteritemvalue,detailsseeSTEP6.4
6.2Addmethodsandproperties
Addmethodsfortheinterfaceaccordingthespecification.
Makeitrun,andmakesureproduceaDLLandTLBfileinthedebugdirectory.
6.3RegistertheSO.
Commandis:
>
Regsvr32pinPadSO2.dll
6.4AddOPOSRegisterItemforSO
[HKEY_LOCAL_MACHINE\SOFTWARE\OLEforRetail\ServiceOPOS\PINPad\idtPINPad]
"
="
pinPadSO2.idtPinPad"
Copyabovetwolinesintoafile,andsaveas*.regfile,thenregisterit.
Theusingofthisregisteritem
WhenclientcallCO.OpenmethodwithDeviceNmae,hereis“idtPINPad”.Thismethodquerytheregisteritem:
idtPINPad,getthevalue“pinPadSO2.idtPinPad”,thisistheIDspecifiedatSTEP6.1,andthenconvertthisIDtoSOCOMGUID.ThencreateSOinstancewiththisGUID.
step6.3registerSOCOM.Andtheregisteritemaddedinthestep6.4letCOlearntheSOID.
STEP7DebugSO
It’sagoodideathataddclientapplicationproject,COproject,SOprojectintooneWorkSpace.
Backtotheclientdialogapplication.
Addfollowingcodesinthebuttonclickmessagehandlefunction
voidCTestPINPadDlg:
:
OnButOpen()
{
//TODO:
Addyourcontrolnotificationhandlercodehere
intres=m_coPOSPINPad.Open(_T("
idtPINPad"
));
TRACE("
COopenreturncode:
%d\n"
res);
if(res!
=OPOS_SUCCESS){
intores=m_coPOSPINPad.GetOpenResult();
TRACE("
Openresultcode:
%d\n"
ores);
}
}
NotetheparameterofOpenmethod,“idtPINPad”istheregisternamespecifiedatSTEP6.4
STEP8:
ImplementSO.
RundebugintheSOprojectandexecutetheclientdialogapplication.
Congratulation!
IfitcanbeinterruptedintheSOmethodOpenServiceintheDEBUGmode.
ThismeanstheSOinterfaceisready.TherestworkisjustfulfillingthemethodsoftheSOinterface.
OneTip:
Maybe,thefirsttroubleforanewOPOSdeveloperisthatoneormorespecialSOinterface’smethodsarelost.GetAmountandSetAmountarelostinmyPINPadproject.TheCO.Openreturn104(OPOS_E_NOSERVICE)andopenResultis305(OPOS_OR_BADIF).ButIhavenoideaofwhichmethodislost.SoIdebugthePINPadCO.Openmethod.ThefollowingisasectioncoderofOpen.Thearrays_SOMethodNamescontainallthespecifiedmethodnamesthatarerequested.
TheCO.OpenmethodcheckallSOmethods,ifanySOmehthodrequestedlost,CO.Openfailed.
//GetthedispatchIDsforthemethodssupportedbytheServiceObject.
//Stopwhenwecan'
tgetoneorwhenallareacquired.
intnMethodCount=0;
while(s_SOMethodNames[nMethodCount]!
=0)
{
_CWNCCMN(s_SOMethodNames[nMethodCount]);
//Initforconversion.
OLECHAR*pMN=MN;
//Assignpointer,convertingtowideifneeded.
if(S_OK!
=
_pService->
GetIDsOfNames(
IID_NULL,&
pMN,1,LOCALE_SYSTEM_DEFAULT,&
_DispIDs[nMethodCount])
)
//Iffailed,dospecialcases:
//-IfwefailedthenewerCloseService,thentryClosebeforefailing.
if(nMethodCount==nDICloseService)
pMN=L"
Close"
;
//-IfwefailedthenewerCOM-friendlynameClaimDeviceorReleaseDevice,
//thentrytheoriginalnameClaimorReleasebeforefailing.
elseif(nMethodCount==nDIClaimDevice)
Claim"
elseif(nMethodCount==nDIReleaseDevice)
Release"
else//Ifnotspecialcase,
break;
//stop.
//Ifspecialcasebutstillnotfound,stop.
}
nMethodCount++;
ENDofFILE
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- Build SO step by
![提示](https://static.bingdoc.com/images/bang_tan.gif)