Dear Experts,
I have code for adding/deleting/modifying form icon and tool tip text to task bar. Its working fine in Standard.exe project but when i tried to use these code as dll file then i am getting error code 424 , object required.

I already register dll file through regsvr32 command but unable to access.

Kindly help.

I am sending code as attachment.

?????????????????????????????????????????????????????????????dll code

Private Type NOTIFYICONDATA
    cbSize As Long
    hWnd As Long
    uID As Long
    uFlags As Long
    uCallbackMessage As Long
    hIcon As Long
    szTip As String * 64
End Type

Private Const NIM_ADD = 0
Private Const NIM_MODIFY = 1
Private Const NIM_DELETE = 2
Private Const NIF_MESSAGE = 1
Private Const NIF_ICON = 2
Private Const NIF_TIP = 4

Private Declare Function Shell_NotifyIconA Lib "SHELL32" _
    (ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As Integer

Private Function setNOTIFYICONDATA(hWnd As Long, ID As Long, _
    Flags As Long, CallbackMessage As Long, Icon As Long, _
    Tip As String) As NOTIFYICONDATA
    
    Dim nidTemp As NOTIFYICONDATA
    
    nidTemp.cbSize = Len(nidTemp)
    nidTemp.hWnd = hWnd
    nidTemp.uID = ID
    nidTemp.uFlags = Flags
    nidTemp.uCallbackMessage = CallbackMessage
    nidTemp.hIcon = Icon
    nidTemp.szTip = Tip & Chr$(0)
    
    setNOTIFYICONDATA = nidTemp
End Function

Public Sub AddIcon(txtTip As String)
    ' This will add the Form1 icon to the system tray
    
    Dim retVal As Integer
    Dim nid As NOTIFYICONDATA
    
    ' This creates our NotifyIconData variable
    nid = setNOTIFYICONDATA( _
        Form1.hWnd, vbNull, _
        NIF_MESSAGE Or NIF_ICON Or NIF_TIP, _
        vbNull, Form1.Icon, txtTip)
    
    ' Now we call our API with this variable
    retVal = Shell_NotifyIconA(NIM_ADD, nid)
End Sub

Public Sub ModifyIcon(txtTip As String, Icofilepatch As String)
    ' This will modify an existing tray icon
    
    Dim retVal As Integer
    Dim nid As NOTIFYICONDATA
     Form1.Icon = Nothing
   Form1.Icon = LoadPicture(Icofilepatch)
    nid = setNOTIFYICONDATA( _
        Form1.hWnd, vbNull, _
        NIF_MESSAGE Or NIF_ICON Or NIF_TIP, _
        vbNull, Form1.Icon, txtTip)
    
    retVal = Shell_NotifyIconA(NIM_MODIFY, nid)
End Sub

Public Sub DeleteIcon(txtTip As String)
    ' This will delete an existing tray icon
    
    Dim retVal As Integer
    Dim nid As NOTIFYICONDATA
    
    nid = setNOTIFYICONDATA( _
        Form1.hWnd, vbNull, _
        NIF_MESSAGE Or NIF_ICON Or NIF_TIP, _
        vbNull, Form1.Icon, txtTip)
    
    retVal = Shell_NotifyIconA(NIM_DELETE, nid)
End Sub


Public Function Sam(x As Integer, y As Integer) As Integer
Sam = x + y
End Function

????????????????????????????????????????????????????????dll code


????????????????????????????????????????????????????????standard.exe code

Dim test As testdll.testclass

Private Sub Form_Load()
Dim x As Integer
Set test = New testdll.testclass
test.AddIcon "sdf"

End Sub

????????????????????????????????????????????????????????standard.exe code


error message object required.

Member Avatar for Huntondoom

I recommend that you put the code for the DLL in you standard.exe, in the same class
so when you debug you can see where it goes wrong, when it is in a .dll you wont be able to do that, after your done just copy everything back

You have to pass reference to your form when calling DLL functions, so you need to modify public functions like this:

Public Sub AddIcon(Form1 As Form, txtTip As String)
or
Public Sub AddIcon(Form1 As Object, txtTip As String)

and then from your exe:

Call test.AddIcon(Me, "sdf")

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.