Talking about the writing of plug-in programs (below) [Original] DLL

xiaoxiao2021-03-06  40

Talking about the writing of plug-in programs (below) [Original] DLL

1. Create a project, "Visual C Project" ---> "Win32" ---> "Win32 Project" ---> "DLL", select "Export Symbol", (VS2003 Platform), press the source directory organization specification setting For project, refer to my blog 2004.12 in these articles.

2. Add a link library to export definition files: ****. DEF, add it to the project.

PTZPELCO-D.DEF: Declare the module parameters of the DLL.

Library "PTZPELCO-D"

Exports

Here, it can be explicitly exported

Createptzinstance

Private

Protocolnames

Data

Description: The above is export variables and export functions, respectively.

3. Delete the project's default export variable and export function, the default export class is also deleted (the header file can be removed).

4. Add definitions in the CPP file where DLLMain is located:

Const

Char * protocolnames []

=

{

"Pelco-D",

"Pelco-P",

0

/ / Must end with 0

}

CPTZinterface * __stdcall createptzinstance

Const

Char * pszprotocolsname)

{

IF

0

== StrCMP (pszprotocolsname, protocolnames [

0]))

{

Return

New CPELCO_D;

/ / Look at the definition below!

}

IF

0

== StrCMP (pszprotocolsname, protocolnames [

1]))

{

Return

NEW CPELCO_P;

/ / Look at the definition below!

}

Return

0;

}

5. A class is derived from the interface, defined as follows:

Class CPELCO_P: PUBLIC CPTZINTERFACE {......}

Pay attention

Createptzinstance

The function, this has reached the purpose of creating this protocol object.

6. Description: The created object is destroyed by this class, called by the user. 7. Please keep your full document, Tianyi has sewing, 0:05 in the early morning of 2004.12.24, Shenzhen Nanshan Science and Technology Park

转载请注明原文地址:https://www.9cbs.com/read-76728.html

New Post(0)