Use Windows.pkg Use Dfspnfrm.pkg Use cRegistry.pkg Use vWin32fh.pkg #IFNDEF cx_RegKeyAlreadyExist Enum_List Define cx_RegKeyAlreadyExist Define cx_RegKeyCreated Define cx_RegkeyFailed Define cx_RegKeyVDFKeyDoesNotExist Define CX_InstalledOkVdfUnder16 End_Enum_List #ENDIF // Note: The "Visual" part will automatically be removed if // the current DataFlex version is above 17. Define CS_StudioPath for "Software\Data Access Worldwide\Visual DataFlex Tools\" Define CS_StudioTools for "\Studio\Tools" Define CS_RegWorkspace for "" Define CS_RegApplication for "" Define CS_RegProject for "" Define CS_RegFileName for "" Define CS_CommandLine for "CommandLine" Define CS_Name for "Name" Define CS_Separator for "Separator" Define CS_Command for "Command" Define CS_CleanMarkersFlag for "/c" Define CS_CleanMarkers for "(Clean Markers)" Define CS_CodeIndentFlag for "/i" Define CS_CodeIndent for "(Code Indent)" Object oAddToStudio_dg is a ModalPanel Set Size to 81 330 Set Label to "Add Program To DataFlex Studio's Tools Menu" Set piMinSize to 79 211 Set Location to 5 4 Set Locate_Mode to Center_On_Parent Object oStudioIntegration_grp is a Group Set Size to 45 299 Set Location to 8 15 Set Label to "DataFlex Studio Integration" Object oStudioMajorVersion_sf is a SpinForm Set Size to 12 27 Set Location to 18 168 Set Maximum_Position to 30 Set Minimum_Position to 14 Set Label_Col_Offset to 2 Set Label_Justification_Mode to JMode_Right Set Label to "Add to Studio's Tools Menu: Major Version" Set Status_Help to "DataFlex main version - e.g. '18'" Set Value to FMAC_VERSION Set peAnchors to anNone End_Object Object oStudioMinorVersion_sf is a SpinForm Set Size to 12 27 Set Location to 18 254 Set Label_Col_Offset to 2 Set Label to "Minor Version" Set Status_Help to "DataFlex minor version - e.g. '0'" Set Maximum_Position to 9 Set Minimum_Position to 0 Set Value to FMAC_REVISION Set Label_Justification_Mode to JMode_Right Set peAnchors to anNone End_Object End_Object Object oOK_btn is a Button Set Size to 14 50 Set Location to 59 207 Set Label to "Add Now" Set Status_Help to "Add to DataFlex Studios 'Tools' menu. The Studio version can be selected with the two spinforms. The COMManifestStudio program gets added to the Studios Tools menu. When selected from the Studio it will pass the current project name on the command line so that the current program's manifest file is automatically loaded by the COMManifestStudio program." Set peAnchors to anTopRight Procedure OnClick Integer iRetval iMajorVersion iMinorVersion String sText sStudioVersion Get Value of oStudioMajorVersion_sf to iMajorVersion Get Value of oStudioMinorVersion_sf to iMinorVersion Move (String(iMajorVersion) + "." + String(iMinorVersion)) to sStudioVersion Get AddProgramToStudioToolsMenu sStudioVersion to iRetval Case Begin Case (iRetval = cx_RegKeyAlreadyExist) Move ("The program already exists in the" * sStudioVersion * "DataFlex Studios Tools menu.") to sText Break Case (iRetval = cx_RegKeyCreated) Move ("Success. The tool was added to the" * sStudioVersion * "DataFlex Studios Tools menu.") to sText Break Case (iRetval = cx_RegkeyFailed) Move "Failed. Could not create the registry key for adding the program to the DataFlex Studio's Tools menu." to sText Break Case (iRetval = cx_RegKeyVDFKeyDoesNotExist) Move ("Could not find the Studio registry key. Is DataFlex Studio version" * sStudioVersion * "really installed on this machine?") to sText Break Case (iRetval = CX_InstalledOkVdfUnder16) Move ("The program was added to the" * sStudioVersion * "Studios Tools menu successfully, but because you installed for an earlier version of the Studio than 16.0 you need to compile the program under that same VDF version, else the Studio can't start the program properly. (Sorry, just a 'feature' of earlier versions of the Studio)") to sText Break Case End Send Info_Box sText End_Procedure End_Object Object oCancel_Btn is a Button Set Label to "&Close" Set Location to 59 264 Set peAnchors to anBottomRight Procedure OnClick Send Close_Panel End_Procedure End_Object Function AddProgramToStudioToolsMenu String sStudioVersion Returns Integer Boolean bOk bExists bOpen bCodeIndent String sKey sValue sProgramPath sProgram sProduct sProductCommentar sStudioPath sParam sTag sCommandLine Handle hoReg hoArray Integer i iItems iCreated iRetval Move False to bOk Get pbCodeIndent of ghoApplication to bCodeIndent If (bCodeIndent = True) Begin Move CS_RegFileName to sTag Move CS_CodeIndentFlag to sParam Move CS_CodeIndent to sProductCommentar End Else Begin Move CS_RegProject to sTag Move CS_CleanMarkersFlag to sParam Move CS_CleanMarkers to sProductCommentar End Move (CS_StudioPath + (Trim(sStudioVersion))) to sStudioPath If (sStudioVersion > "17.1") Begin Move (Replace("Visual ", sStudioPath, "")) to sStudioPath End Get psProgramPath of (phoWorkspace(ghoApplication)) to sProgramPath Get PathAtIndex of (phoWorkspace(ghoApplication)) sProgramPath 1 to sProgramPath Get vFolderFormat sProgramPath to sProgramPath Get psProduct of (phoWorkspace(ghoApplication)) to sProduct Move (sProduct * sProductCommentar) to sProduct Get Module_Name to sProgram Get Create U_cRegistry to hoReg Set phRootKey of hoReg to HKEY_CURRENT_USER // First check if the DataFlex version is installed Get KeyExists of hoReg sStudioPath to bExists If (bExists = False) Begin Send Destroy of hoReg Function_Return cx_RegKeyVDFKeyDoesNotExist End // Then check if any tools have been installed in the Tools Menu. // If no tools created yet, create the Tools registry key. Move (sStudioPath + CS_StudioTools) to sStudioPath Get KeyExists of hoReg sStudioPath to bExists If (bExists = False) Begin Set pfAccessRights of hoReg to KEY_ALL_ACCESS Get CreateKey of hoReg sStudioPath to iCreated If (iCreated <> 0) Begin Move cx_RegkeyFailed to iRetval End Else Begin Move True to bExists End End If (bExists = True) Begin Get OpenKey of hoReg sStudioPath to bOk If (bOk = True) Begin Get Create U_Array to hoArray Get GetSubkeys of hoReg hoArray to iItems Decrement iItems Move False to bExists Set pfAccessRights of hoReg to KEY_READ // Check if the key already exists: For i from 0 to iItems Get Value of hoArray i to sKey Move (sStudioPath + "\" + sKey) to sKey Get OpenKey of hoReg sKey to bOpen If (bOpen = True) Begin Get ReadString of hoReg CS_Name to sValue Get ReadString of hoReg CS_CommandLine to sCommandLine If (Uppercase(sValue) = Uppercase(sProduct) and Uppercase(sCommandLine) = Uppercase(sTag * String(sParam))) Begin Move True to bExists End End Loop Send Destroy of hoArray If (bExists = False) Begin Set pfAccessRights of hoReg to KEY_ALL_ACCESS // We need to create the next key number: // The studio expect tools menu items to be numbered 1,2,3...n Increment iItems Increment iItems Get CreateKey of hoReg (sStudioPath + "\" + String(iItems)) to iCreated If (iCreated = 0) Begin Send WriteString of hoReg CS_Name sProduct // From DataFlex 16 and up the params for the Studio's Tools menu changed slightly: If (sStudioVersion >= "16.0") Begin Send WriteString of hoReg CS_Command (sProgramPath + sProgram) Send WriteString of hoReg CS_CommandLine (sTag * String(sParam)) End Else Begin Send WriteString of hoReg CS_CommandLine ('"' + sProgramPath + sProgram + ".exe" + '"' * (sTag * String(sParam))) Move CX_InstalledOkVdfUnder16 to iRetval End Send WriteDword of hoReg CS_Separator 1 Move cx_RegKeyCreated to iRetval End Else Begin Move cx_RegkeyFailed to iRetval End End Else Begin Move cx_RegKeyAlreadyExist to iRetval End Send CloseKey of hoReg End End Send Destroy of hoReg Function_Return iRetval End_Function Procedure Page Integer iPageObject Forward Send Page iPageObject Set Icon to "SQLConnections.ico" End_Procedure On_Key Key_Alt+Key_O Send KeyAction of oOK_Btn On_Key Key_Alt+Key_C Send KeyAction of oCancel_Btn On_Key kCancel Send KeyAction of oCancel_Btn End_Object