Geodatabase Designer
bin\GUIDReset.cls

' Copyright 2008 ESRI
' 
' All rights reserved under the copyright laws of the United States
' and applicable international laws, treaties, and conventions.
' 
' You may freely redistribute and use this sample code, with or
' without modification, provided you include the original copyright
' notice and use restrictions.
' 
' See use restrictions at <your ArcGIS install location>/developerkit/userestrictions.txt.
' 




Option Explicit

Private Const COMMAND_CAPTION As String = "Reset ObjectClass GUIDs"
Private Const MODULE_NAME As String = "GUIDReset.cls"

Private mPictureDisp As IPictureDisp
Private mApplication As esriFramework.IApplication

Implements ICommand

Private Sub Class_Initialize()
    Set mPictureDisp = LoadResPicture("GD_RESET", 0)
End Sub

Private Sub Class_Terminate()
    Set mPictureDisp = Nothing
    Set mApplication = Nothing
End Sub

Private Property Get ICommand_Bitmap() As esriSystem.OLE_HANDLE
    ICommand_Bitmap = mPictureDisp
End Property

Private Property Get ICommand_Caption() As String
    ICommand_Caption = COMMAND_CAPTION
End Property

Private Property Get ICommand_Category() As String
    ICommand_Category = COMMAND_CATEGORY
End Property

Private Property Get ICommand_Checked() As Boolean
    '
End Property

Private Property Get ICommand_Enabled() As Boolean
    Dim pGxApplication As esriCatalogUI.IGxApplication
    Dim pGxObject As esriCatalog.IGxObject
    Dim pGxDatabase As esriCatalog.IGxDatabase
    '
    Set pGxApplication = mApplication
    Set pGxObject = pGxApplication.SelectedObject
    '
    If TypeOf pGxObject Is esriCatalog.IGxDatabase Then
        Set pGxDatabase = pGxObject
        If pGxDatabase.WorkspaceName.Type <> esriFileSystemWorkspace Then
            ICommand_Enabled = True
        Else
            ICommand_Enabled = False
        End If
    Else
        ICommand_Enabled = False
    End If
End Property

Private Property Get ICommand_HelpContextID() As Long
    '
End Property

Private Property Get ICommand_HelpFile() As String
    '
End Property

Private Property Get ICommand_Message() As String
    ICommand_Message = COMMAND_CAPTION
End Property

Private Property Get ICommand_Name() As String
    ICommand_Name = "GeodatabaseDesigner_GUIDReset"
End Property

Private Sub ICommand_OnClick()
    On Error GoTo ErrorHandler
    '
    Select Case MsgBox("This command will reset the ObjectClass GUID's. Are you sure?", vbYesNoCancel, App.FileDescription)
    Case vbCancel, vbNo
        Exit Sub
    Case vbYes
        '-----------
        ' Let's Go!
        '-----------
    Case Else
        Exit Sub
    End Select
    '
    Call modUtility.GUIDReset(mApplication)
    '
    Exit Sub
ErrorHandler:
    Call HandleError(True, "ICommand_OnClick " & MODULE_NAME & " (" & CStr(Erl) & ")", Err.Number, Err.Source, Err.Description)
End Sub

Private Sub ICommand_OnCreate(ByVal hook As Object)
    Set mApplication = hook
End Sub

Private Property Get ICommand_Tooltip() As String
    ICommand_Tooltip = COMMAND_CAPTION
End Property