Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

UnregisterClass (user32)
 
.
Summary
TODO - a short description

C# Signature:

[DllImport("user32.dll")]
public static extern bool UnregisterClass(string lpClassName, IntPtr hInstance);

VB.NET Signature:

<DllImport("user32.dll")> _
Public Shared Function UnregisterClass(lpClassName As String, hInstance As IntPtr) As Boolean
End Function

VB Signature:

Declare Function unregisterClassEx Lib "user32.dll" (TODO) As TODO

User-Defined Types:

None.

Sample Code(VB.NET):

    <StructLayout(LayoutKind.Sequential)> _
    Private Structure WNDCLASSEX
    Public cbSize As UInteger
    Public style As ClassStyles
    Public lpfnWndProc As IntPtr
    Public cbClsExtra As Integer
    Public cbWndExtra As Integer
    Public hInstance As IntPtr
    Public hIcon As IntPtr
    Public hCursor As IntPtr
    Public hbrBackground As IntPtr
    Public lpszMenuName As String
    Public lpszClassName As String
    Public hIconSm As IntPtr

    Shared Function MakeNew()
    Dim nw As New WNDCLASSEX
    nw.cbSize = Marshal.SizeOf(GetType(WNDCLASSEX))
    Return nw
    End Function
    End Structure

    <DllImport("user32.dll")> _
    Private Shared Function RegisterClassEx(ByRef lpwcx As WNDCLASSEX) As Short
    End Function

    <DllImport("user32.dll")> _
    Private Shared Function UnregisterClass(lpClassName As String, hInstance As IntPtr) As Boolean
    End Function

    Dim className As String = "Iranian_Persian_Class"
    Dim WndClass As WNDCLASSEX = WNDCLASSEX.MakeNew()
    With WndClass
    .style = 0
    .lpfnWndProc = IntPtr.Zero
    .cbClsExtra = 0
    .cbWndExtra = 0
    .hInstance = IntPtr.Zero
    .hIcon = IntPtr.Zero
    .hCursor = IntPtr.Zero
    .hbrBackground = IntPtr.Zero
    .lpszMenuName = ""
    .lpszClassName = className
    .hIconSm = IntPtr.Zero
    End With

    Dim rVal As Short = RegisterClassEx(WndClass)
    If rVal = 0 Then
    MsgBox("an error occured")
    Else
    With WndClass
    MsgBox("Class atom: " & rVal.ToString & vbCrLf & _
           "cbClsExtra: " & .cbClsExtra.ToString & vbCrLf & _
           "cbSize: " & .cbSize.ToString & vbCrLf & _
           "cbWndExtra: " & .cbWndExtra.ToString & vbCrLf & _
           "hbrBackground: " & .hbrBackground.ToString & vbCrLf & _
           "hCursor: " & .hCursor.ToString & vbCrLf & _
           "hIcon: " & .hIcon.ToString & vbCrLf & _
           "hIconSm: " & .hIconSm.ToString & vbCrLf & _
           "hInstance: " & .hInstance.ToString & vbCrLf & _
           "lpfnWndProc: " & .lpfnWndProc.ToString & vbCrLf & _
           "lpszClassName: " & .lpszClassName.ToString & vbCrLf & _
           "lpszMenuName: " & .lpszMenuName.ToString & vbCrLf & _
           "style: " & .style.ToString)
    End With

    If UnregisterClass(WndClass.lpszClassName, WndClass.hInstance) Then
    MsgBox("Unregister Class Sucessfuly")
    Else
    MsgBox("Unregister Class Failed")
    End If
    End If

Alternative Managed API:

Do you know one? Please contribute it!

Notes:

Important. First destroy the window than call UnregisterClass!!

Tips & Tricks:

Please add some!

Sample Code:

Please add some!

Documentation

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

 
Access PInvoke.net directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version
Revisions