Use atl com appwizardto compile the compose and select the differences between .dlland .exe.
. Dll is an in-process component and cannot be run independently. It can be called by the client after compilation is complete.
. EXE is a component that can be run independently. It can be called by the client only after it is run.
The former and the client use the same address space, while the latter is separated.
How can I register a program as a service in 2000?
//
// Function: Always installservice ()
//
// Purpose: INSTALLThe Service
//
// Parameters:
// None
//
// Return value:
// None
//
// Comments:
//
Void uninstall installservice ()
{
SC _handle schservice;
SC _handle schscmanager;
Tchar szpath [512];
If (getmodulefilename (null, szpath, 512) = 0)
{
_ Tprintf (text ("unable to install % s-% s \ n"), text (szservicedisplayname), getlasterrortext (szerr, 256 ));
Return;
}
Schscmanager = openscmanager (
Null, // machine (null = Local)
Null, // database (null = default)
SC _manager_connect & brvbar; SC _manager_create_service // access required
);
If (schscmanager)
{
Schservice = createservice (
Schscmanager, // scmanager Database
Text (szservicename), // name of service
Text (szservicedisplayname), // name to display
Service_query_status, // desired access
Service_win32_own_process, // service type
Service_demand_start, // start Type
Service_error_normal, // Error Control Type
Szpath, // Service's binary
Null, // No load ordering Group
Null, // No tag identifier
Text (szdependencies), // Dependencies
Null, // LocalSystem account
Null); // No Password
If (schservice)
{
_ Tprintf (text ("% s installed. \ n"), text (szservicedisplayname ));
Closeservicehandle (schservice );
}
Else
{
_ Tprintf (text ("createservice failed-% s \ n"), getlasterrortext (szerr, 256 ));
}
Closeservicehandle (schscmanager );
}
Else
_ Tprintf (text ("openscmanager failed-% s \ n"), getlasterrortext (szerr, 256 ));
}
Void main ()
{
...
If (install_service)
Cmdinstallservice ();
...
}
1. Create an ActiveX (DLL) project with VB (+ sp5.0) on the Win2000 Server and change the project name to "com_test"
2. Add a class module named "clsadd" and enter the following lines of code:
Option explicit
Public X, Y as integer
Public Function myadd () as integer
Myadd = x + y
End Function
3. Open the "Project Properties" dialog box, select "generate", select "Automatic Upgrade", select "parts", and select "remote server files" (this is important, otherwise, the Type Library File com_test.tlb will not be generated during compilation) and "binary compatibility", and "OK"
4. Save and compile and generate "com_test.dll"
5. Open "Control Panel/management/component service" and use the "COM + application installation wizard" under "COM + application" to create an empty COM + application, the name is "mytest"
6. Under "mytest", create a "component" and select "install new component" in the "component Installation Wizard" (note: do not use "Import registered components"), and then add the com_test.dll and com_test.tlb generated in step 1 (both files are required !), Complete.
7. Right-click "my computer" at the top of "COM + application" and select "properties". Then, on the "default properties" page in the "properties" dialog box, change "Default Authentication Level" to "NONE". OK.
8. Right-click "mytest" and export the "application proxy" of the client ". Note: In the Export Dialog Box, You must select "application proxy" instead of "server application "!
9. Install the exported two files (that is, the application proxy) on the Win98 machine. At this time, it will add several registration items to the Registry and add them in C: \ Program Files \ complus applications generates a folder named clisd. Open com_test.tlb and apl82.tmp.
Note: There is no com_test.dll file on Win98, which is on Win2000 Server!
Now the preparation is complete. Check whether your COM + Configuration component can work on Win98. (Log On with the Administrator and password first)
10. Start VB (+ sp5.0), create an EXE project, place a text box and a command button on the form, and add code to the Click Event of the command button:
Dim ox as object
Set ox = Createobject ("com_test.clsadd", "Win2000 Server IP Address ")
Ox. x = 12
Ox. Y = 13
Text1.text = ox. myadd ()
Run the program. After a flash of hard drive lights on the Win2000 Server, text1 jumps out of "25"
--- Succeeded!