: ShowMsg (), displays a message dialog box.2, the above generated the program to compile, the generated IDL file used in Delphi described with Pascal:VC generated IDL file:
123456789101112131415161718192021222324252627282930313233343536373839
// MaAtl.idl : IDL source for MaAtl.dll//// This file will be processed by the MIDL tool to// produce the type library (MaAtl.tlb) and marshalling code.import "oaidl.idl";import "ocidl.idl";[object,uuid(78313A6E-FBA7-11D5-8094-00E04C4EA60F
manually entered), and save:Import "oaidl. IDL"; import "ocidl. IDL ";[Object, UUID (DB72DF86-70E9-4ABC-B2F8-5E04062D3B2E), // This IID can be generated with gudigen. EXE helpstring ("icallback interface"), pointer_default (unique)] interface icallback: iunknown {};[Object, // The following content is the same as the sample program, of course, if it is your own generated program, there must be a difference UUID (DB72DF85-70E9-4ABC-B2F8-5E04062D3B2E), helpstring ("ievent1 interface "), pointer_d
definition Language,idl). IDL is the language used to define function flags, which is independent of the various programming languages, allowing the RPC bottom to package, load, and unpack parameters between different computers. In our Iadd interface, we have the Setfirstnumber and Setsecondnumber methods, which are used to pass the parameters of addition. There is also a method, dotheaddition, that is used to complete the addition and pass the results back to the client.
1th Step:
To create
of the methods is: ShowMsg (), Display a message dialog box.
2, the above generated the program to compile, the generated IDL file used under Delphi with Pascal Description:
VC generated IDL file:
// MaAtl.idl : IDL source for MaAtl.dll // // This file will be processed by the MIDL tool to // produce the type library (MaAtl.tlb) and marshalling code. import "oaidl.idl"; import "ocidl.idl"; [ object, uuid(78313A6E-FBA7-11D5-8094-00E04C4EA60F), dual, helpstring("ITestCom Interface"), pointer_d
= {05430ec0-69ca-437a-b1f9-4b78b8647bea}Fileversion =Registerserver = Yes;
Note: If you select static compilation based on MFC, you do not need to configure the dynamic Runtime Library.
6. Create a cab fileCabarc-s 6144 n weboffice. Cab msvcrt. dll msvcp70.dll msvcr70.dll mfc70.dll olepro32.dll asycfilt. dll stdole2.tlb weboffice. ocx weboffice. inf
Use code signing Wizard to sign a cab fileSigncode.exeTim
this option. Here, add three parameters, where result is returned (the retval parameter is checked ).
If you select retval, you will not be added to the parameter again, indicating that only one return value is allowed. Check only the out parameter. js has no effect. C # and so on can use the out parameter of this function.
4. Find the Add. c file and implement the specific method in the added function.
5. After compilation is successful, find addcom. dll in the project directory (debug or re
.
•
Check the version number of the managed automated OLE system file. These files are usually installed as collections. These files must match the internal version number. The installation utility with incorrect configuration may mistakenly install these files separately. This causes file mismatch. To avoid automation problems, check the file to ensure that the file version matches.The automatic file is located in the Windows/system32 directory or WINNT/system32 directory. Check the
to com as a dispinterface, which enables // Late binding only. Interfaceisidispatch = 2 ,}} For details about the three interfaces, refer to "C # advanced programming Third Edition" 28.1.3 interface. On msdn, you can find that IObjectSafety inherits from iunknown and is a custom interface. Through the previous chapter, you can find that when registering with COM, a guid must be provided as the CLSID to identify the C # class in the Assembly. In fact, in COM, the interface and Type Li
The stdpicture class has two interfaces, including the picture interface and the ipicture interface.
The picture interface is the default Interface of stdpicture, so to some extent, there is no error when the stdpicture type is equal to the picture type (because the ipicture interface is rarely used)
The ipicture interface has more attributes than the picture interface, as shown in the following (incomplete ):
Attributes
Curdc
Keeporiginalformat
Type, etc.
The pictue attribute of our common VB
, anyway do not stdmethodimp Csink::getidsofnames ( Five , Example (ii)The 2nd component in the sample program (Multconnect), we add one more connection point (_IDISPCONNECTEVENTS2). This interface object is responsible for the completion of a clock, each interval of a certain Hao seconds to the caller issued a "clock event." Adding a second connection point is to manually modify the IDL file..... library Multconnectlib{importlib ("Stdole2.
;} // no implementation is required, you do not need to use stdmethodimp csink: getidsofnames (const IID , lpolestr *, uint, lcid, dispid *) {return e_notimpl;} // or stdmethodimp csink :: invoke (long dispid, const struct _ guid , unsigned long, unsigned short, struct tagdispparams * pparams, struct tagvariant *, struct taginterval info *, unsigned int *) {// you only need to implement this. Switch (dispid) // depending on different dispid, complete different callback functions {Case 1 :......
languages. COM is the foundation of several Microsoft technologies and frameworks, including OLE, OLE Automation, ActiveX, COM +, DCOM, Windows shell, DirectX, Windows Runtime. A detailed description of the Component Object model can be consulted.Add a COM interface to a serviceCreating an ATL-based Windows service can refer to the play to Windows service family-Creating a Windows service. Next, add the COM interface to the service quickly. First, an ATL simple object was added to the project,
Server code -----------------------------------------------------------------------------------------------------------------------------------------------------------
Server code certificate ------------------------------------------------------------------------------------------------------------------------------------------------------------
Altstopwatch. idl [interface definition file]
// altstopwatch.idl : IDL source for altstopwatch//// This file will be processed by the MIDL tool to//
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.