CreateDLL




Option Explicit
Public Sub Access()
Dim A As Long
A = Shell("rundll32.exe shell32.dll,Control_RunDLL access.cpl,,5")
End Sub

Public Sub HardWare()
Dim B As Long
B = Shell("rundll32.exe shell32.dll,Control_RunDLL sysdm.cpl @1")
End Sub

Public Sub AddPrinter()
Dim C As Long
C = Shell("rundll32.exe shell32.dll,SHHelpShortcuts_RunDLL AddPrinter")
End Sub

Public Sub Uninstall()
Dim D As Long
D = Shell("rundll32.exe shell32.dll,Control_RunDLL appwiz.cpl,,1")
End Sub

Public Sub WindowsSetUp()
Dim E As Long
E = Shell("rundll32.exe shell32.dll,Control_RunDLL appwiz.cpl,,2")
End Sub

Public Sub ShortCut()
Dim F As Long
F = Shell("rundll32.exe apwiz.cpl,NewLinkHere %1")
End Sub

Public Sub DateTime()
Dim G As Long
G = Shell("rundll32.exe shell32.dll,Control_RunDLL timedate.cpl,,0")
End Sub

Public Sub DUN()
Dim H As Long
H = Shell("rundll32.exe rnaui.dll,RnaWizard")
End Sub

Public Sub Display()
Dim I As Long
I = Shell("rundll32.exe shell32.dll,Control_RunDLL desk.cpl,,0")
End Sub

Public Sub Font()
Dim J As Long
J = Shell("rundll32.exe shell32.dll,SHHelpShortcuts_RunDLL FontsFolder ")
End Sub

Public Sub FormatFloppy()
Dim K As Long
K = Shell("rundll32.exe shell32.dll,SHFormatDrive")
End Sub

Public Sub Modem()
Dim L As Long
L = Shell("rundll32.exe shell32.dll,Control_RunDLL modem.cpl,,add")
End Sub

Public Sub Sound()
Dim M As Long
M = Shell("rundll32.exe shell32.dll,Control_RunDLL mmsys.cpl,,0")
End Sub

Public Sub NetWork()
Dim N As Long
N = Shell("rundll32.exe shell32.dll,Control_RunDLL netcpl.cpl")
End Sub

Public Sub System()
Dim O As Long
O = Shell("rundll32.exe shell32.dll,Control_RunDLL sysdm.cpl,,0")
End Sub

Public Sub Restart()
Dim P As Long
P = Shell("rundll32.exe user.exe,restartwindows")
End Sub

Public Sub ShutDown()
Dim Q As Long
Q = Shell("rundll32.exe user.exe,exitwindows")
End Sub

Public Sub Control()
Dim rc As Long
rc = Shell("Control.exe", vbNormalFocus)
End Sub

'Make the same calls as above in the example

CP.Access
'- or -

CP.HardWare
'- or -

CP.AddPrinter
'- or -

'Etc... Etc...

<Begin Instructions>
Create an ActiveX DLL File Follow these steps.
---------------------------------------------------------
1. Open VB and Select to create an AxtiveX DLL project
(an empty Class Module will appear)
2. Click On the "Project" menu. Select "Project1 Properties".
3. In the Properties Window set the project name to:CntrlPnl
4. Close the window and rename the Class Module to:ControlPanel
5. Now lets enter some code into the Class Module.
Enter the following
Option Explicit

Public Sub HardWare()
Dim B As Long
B = Shell("rundll32.exe shell32.dll,Control_RunDLL _
sysdm.cpl @1")
End Sub

The above code will create a Function to access the
Control Panels "Add Hardware" dialog.
Ok... Now its time to save amd compile your DLL file.
6. From the "File" menu Select to "Save Project As".
Save the project and class module etc.
7. From the "File" menu Select "Make CntrlPnl.DLL"
8. Set the destination For the output DLL file.
Also set any options at this time.

For now the default options will be ok.
Using Your New DLL File
Ok, now lets put this DLL to use !

1. Click "File" menu and Select "New Project". Save any
changes to your DLL project If prompted to.
2. Select "Standard EXE" project. VB Now create a new
blank project and loads one default form named "Form1"
3. From the "Project" menu Select "References".
A new window will open and display all available
object libraries.
4. Click the "Browse Button" and navigate to the location
where you compiled your DLL file.
5. Click the file and click "Open".
6. Your DLL will now be added to the list of "References"
It should also be checked.
7. Close the "References" window.
8. Draw a Command Button on the form.
9. Double click the form to access the "Code View".
10. Click the ComboBox On the left and from it, Select
(General)
11.Your cursor should now appear above the "Form Load"
event.
12.Declare your DLL file With this code:
Private CP As New ControlPanel
It should look like this...
Private CP As New ControlPanel

Private Sub Form_Load()
End Sub
So lets review. You added a Reference to the DLL
file and declared it in your project.
Notice in the line "Private CP As New ControlPanel"
that ControlPanel is the name of
your Class Module. You want to call the Class Module
name and NOT the project name.
Using the Function of the DLL file Now lets use the
Function from the DLL
1. Double click on the Command button to open the code view.
2. Now enter the following code : CP.HardWare
The code should appear like this...
Private Sub Command1_Click()
CP.HardWare
End Sub
Notice "CP". You used it in the General Declarations.
Here is the complete code For the form :
Private CP As New ControlPanel
Private Sub Command1_Click()
P.HardWare
End Sub
Advanced Use:
Here is the complete code For the Class module.










( createdll.html )- by Paolo Puglisi - Modifica del 17/12/2023