// The following code has been borrowed from Nil's ManifestSideBySide Studio! // // It allows you to add your application to the Studio Tools menu. // // Define CS_StudioPath for "Software\Data Access Worldwide\Visual DataFlex Tools\" Define CS_StudioTools for "\Studio\Tools" Define CS_Command for "Command" Define CS_CommandLine for "CommandLine" Define CS_RegApplication for "" Define CS_RegFile for "" Define CS_Name for "Name" Define CS_Separator for "Separator" Enum_List Define cx_RegKeyAlreadyExist Define cx_RegKeyCreated Define cx_RegkeyFailed Define cx_RegKeyVDFKeyDoesNotExist Define CX_InstalledOkVdfUnder16 End_Enum_List // // Adds the ManifestSideBySide program to the VDF Studio's Tools menu. // Pass the Studio version as a dot separated string. E.g. "17.0" // The Studio uses a registry string for the purpose. // Checks are made so that if the program already exists in the Studio's // tools menu - nothing will be changed. A check is also performed that // the Studio for the passed version actually is installed on the machine. // Returns: // cx_RegKeyAlreadyExist, cx_RegKeyCreated, cx_RegkeyFailed, cx_RegKeyVDFKeyDoesNotExist or CX_InstalledOkVdfUnder16 Function AddProgramToStudioToolsMenu String sStudioVersion Returns Integer Boolean bOk bExists bOpen String sKey sValue sProgramPath sProgram sProduct sStudioPath Handle hoReg hoArray Integer i iItems iCreated iRetval Move False to bOk 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 If (Right(Rtrim(sProgramPath),1)<>"\") ; Move (sProgramPath+"\") To sProgramPath Get psProduct of (phoWorkspace(ghoApplication)) to sProduct Get Module_Name to sProgram Get Create (RefClass(cRegistry)) to hoReg Set phRootKey of hoReg to HKEY_CURRENT_USER // First check if the VDF 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 item 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 If (sValue = sProduct) ; Move True to bExists 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 VDF 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 CS_RegFile End Else Begin Send WriteString of hoReg CS_CommandLine ('"' + sProgramPath + sProgram + ".exe" + '"' * CS_RegFile) 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 InstallToStudioMenu Integer iRetval String sText sStudioVersion sStudioName Move "19.1" to sStudioVersion Get AddProgramToStudioToolsMenu sStudioVersion to iRetval Move "Visual DataFlex Studio" To sStudioName If (sStudioVersion > "17.1") Begin Move (Replace("Visual ", sStudioName, "")) to sStudioName End Case Begin Case (iRetval = cx_RegKeyAlreadyExist) Move ("The program already exists in the" * sStudioVersion * sStudioName + "'s Tools menu.") to sText Break Case (iRetval = cx_RegKeyCreated) Move ("Success. The tool was added to the" * sStudioVersion * sStudioName + "'s Tools menu.") to sText Break Case (iRetval = cx_RegkeyFailed) Move ("Failed. Could not create the registry key for adding the program to the" * sStudioName + "'s Tools menu.") to sText Break Case (iRetval = cx_RegKeyVDFKeyDoesNotExist) Move ("Could not find the Studio registry key. Is" * sStudioName * "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 this 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