Подготовка Setup ПКМ8 для InnoSetup


Раздел Установка дополнительных компонентов

Где-то среди функций, которые в секции [Code] есть функция CurStepChanged, если нет, то надо определить её оригинальное содержимое из дистрибутива следующее:

  1. procedure CurStepChanged(CurStep: TSetupStep);
  2. var
  3. addSetupProgressPage: TOutputProgressWizardPage;
  4. begin
  5. addSetupProgressPage := CreateOutputProgressPage('Подождите...', 'Установка дополнительных компонентов');
  6.  
  7. case CurStep of
  8. ssInstall:
  9. begin
  10. NBGetCurState();
  11. end;
  12. ssPostInstall:
  13. begin
  14. addSetupProgressPage.SetText('Установка дополнительного ПО','');
  15. addSetupProgressPage.SetProgress(0,9);
  16. addSetupProgressPage.Show();
  17. addSetupProgressPage.SetText('Установка распространяемого компонента Microsoft Visual C++','');
  18. addSetupProgressPage.SetProgress(1,9);
  19. VCRedistSetup();
  20.  
  21. addSetupProgressPage.SetText('Установка Microsoft Access Database Engine','');
  22. addSetupProgressPage.SetProgress(2,9);
  23. AccessDataBaseEngineSetup();
  24.  
  25. addSetupProgressPage.SetText('Установка .NET Framework 4.6.1','');
  26. addSetupProgressPage.SetProgress(3,9);
  27. NetSetup();
  28.  
  29. addSetupProgressPage.SetText('Установка Microsoft SQL Server 2012 Express LocalDB','');
  30. addSetupProgressPage.SetProgress(4,9);
  31. SQLLocalDBSetup();
  32.  
  33. addSetupProgressPage.SetText('Регистрация компонентов','');
  34. addSetupProgressPage.SetProgress(5,9);
  35. //NBUpdateTxt();
  36.  
  37. addSetupProgressPage.SetText('Настройка путей','');
  38. addSetupProgressPage.SetProgress(6,9);
  39. NBSetupInf();
  40. addSetupProgressPage.SetText('Инициализация настроек','');
  41. addSetupProgressPage.SetProgress(7,9);
  42. MebelIni();
  43. K32Ini()
  44. K3TalkIni();
  45. K3RefEditorMetapathsIni();
  46. addSetupProgressPage.SetText('Установка драйвера CodeMeter','');
  47. addSetupProgressPage.SetProgress(8,9);
  48. NBTasks();
  49. addSetupProgressPage.SetText('Готово','');
  50. addSetupProgressPage.SetProgress(9,9);
  51. addSetupProgressPage.Hide();
  52. //зарегистрируем тут, чтобы в случае неудачи ничего не накрылось
  53. try
  54. NBRegisterDLL();
  55. except
  56. begin
  57. MsgBox('K3ViewAX is not registered!', mbConfirmation, MB_OK);
  58. end
  59. end;
  60. end;
  61. end;
  62. end;

Секция ssPostInstall

Содержимое секции ssInstall старое, а вот в секции ssPostInstall выполняются как раз пункты установки всякого стороннего ПО

сначала ставятся microsoft'овские библиотеки с++, для этого где-то повыше надо определить функцию

  1. function VCRedistSetup() : Boolean;
  2. var
  3. ErrorCode: Integer;
  4. ErrorMsg: String;
  5. begin
  6. if not ShellExec('', ExpandConstant('{app}\Kit\VCRedist\VC_redist.x86.exe'),
  7. '/install /quiet /norestart', '', SW_SHOW, ewWaitUntilTerminated, ErrorCode) then
  8. begin
  9. ErrorMsg := Format('Не установлен распространяемый компонент Microsoft Visual C++ для Visual Studio 2015, 2017 и 2019. Ошибка %d', [ErrorCode]);
  10. MsgBox(ErrorMsg, mbError, MB_OK);
  11. end;
  12. end;

Затем ставится access database engine с помощью функции

  1. function AccessDataBaseEngineSetup() : Boolean;
  2. var
  3. ErrorCode: Integer;
  4. ErrorMsg: String;
  5. begin
  6. if not ShellExec('', ExpandConstant('{app}\Kit\Acсess DataBase Engine\accessdatabaseengine.exe'),
  7. '/q', '', SW_SHOW, ewWaitUntilTerminated, ErrorCode) then
  8. begin
  9. ErrorMsg := Format('Проблемы при установке accessdatabaseengine.exe. Ошибка %d', [ErrorCode]);
  10. MsgBox(ErrorMsg, mbError, MB_OK);
  11. end;
  12. end;

net

следующий по списку .net

  1. function IsDotNetDetected(version: string; service: cardinal): boolean;
  2. var
  3. key, versionKey: string;
  4. install, release, serviceCount, versionRelease: cardinal;
  5. success: boolean;
  6. begin
  7. versionKey := version;
  8. versionRelease := 0;
  9. if version = 'v1.1' then begin
  10. versionKey := 'v1.1.4322';
  11. end else if version = 'v2.0' then begin
  12. versionKey := 'v2.0.50727';
  13. end
  14.  
  15. else if Pos('v4.', version) = 1 then begin
  16. versionKey := 'v4\Full';
  17. case version of
  18. 'v4.6.1': versionRelease := 394254;
  19. end;
  20. end;
  21. key := 'SOFTWARE\Microsoft\NET Framework Setup\NDP\' + versionKey;
  22. if Pos('v4', version) = 1 then begin
  23. success := success and RegQueryDWordValue(HKLM, key, 'Servicing', serviceCount);
  24. end else begin
  25. success := success and RegQueryDWordValue(HKLM, key, 'SP', serviceCount);
  26. end;
  27. if versionRelease > 0 then begin
  28. success := success and RegQueryDWordValue(HKLM, key, 'Release', release);
  29. success := success and (release >= versionRelease);
  30. end;
  31.  
  32. result := success and (install = 1) and (serviceCount >= service);
  33. end;
  1. function NetSetup() : Boolean;
  2. var
  3. value: String;
  4. ErrorCode: Integer;
  5. ErrorMsg: String;
  6. section: String;
  7. ini: String;
  8. bNetSetupRes: Boolean;
  9. bdotNET_Framework_4_6: Boolean;
  10. begin
  11. bdotNET_Framework_4_6 := IsDotNetDetected('v4.6.1', 0);
  12. ini := ExpandConstant('{app}\Bin\SetupInf.ini');
  13. section := 'Log';
  14. if (not bdotNET_Framework_4_6) then begin
  15. bNetSetupRes := ShellExec('', ExpandConstant('{app}\Kit\dotNet\NDP461-KB3102436-x86-x64-AllOS-ENU.exe'), '/quiet', '', SW_SHOW, ewWaitUntilTerminated, ErrorCode);
  16. if(not bNetSetupRes) then begin
  17. value := Format('Установка .NET Framework 4.6.1 (%d)', [0]);
  18. SetIniString(section, 'dotNETInstall', value, ini);
  19. ErrorMsg := Format('Не удалось установить .NET Framework 4.6.1 Ошибка %d', [ErrorCode]);
  20. MsgBox(ErrorMsg, mbError, MB_OK);
  21. end
  22. else begin
  23. value := Format('Успешная установка .NET Framework 4.6.1 (%d)', [1]);
  24. SetIniString(section, 'dotNETInstall', value, ini);
  25. end;
  26. end;
  27. end;

sqllocaldb

следующий на очереди sqllocaldb, там только одна "хитрость", после установки надо ещё на всякий стартануть дефолтный экземпляр

  1. function SQLLocalDBSetup() : Boolean;
  2. var
  3. FileName : String;
  4. value : String;
  5. bRes : Boolean;
  6. ErrorCode: Integer;
  7. begin
  8. //*** удалить файл блокировки
  9. Filename := ExpandConstant(szMasterAppData + '\Base\NGuidesSQLNew_log.ldf');
  10. if FileExists(Filename) then
  11. DeleteFile(Filename);
  12. //*** установить SQL
  13. if IsWin64 then
  14. value := ExpandConstant('{app}\Kit\SQLLocalDB\x64\SqlLocaLDB.msi')
  15. else
  16. value := ExpandConstant('{app}\Kit\SQLLocalDB\x86\SqlLocaLDB.msi');
  17. msg := Format('SqlLocaLDB: Exist = %d%s(%s)', [FileExists(value), newline, value]);
  18. if not ShellExec('', value, '/qn IACCEPTSQLLOCALDBLICENSETERMS=YES', '', SW_SHOW, ewWaitUntilTerminated, ErrorCode) then begin
  19. msg := Format('Не удалось установить SQLLocalDB Ошибка %d', [ErrorCode]);
  20. MsgBox(msg, mbInformation, MB_OK);
  21. end;
  22. bRes := ShellExec('', 'SqlLocalDb', 'start v11.0', '', SW_HIDE, ewWaitUntilTerminated, ErrorCode);
  23. bRes := ShellExec('', 'SqlLocalDb', 'share v11.0 v11.0', '', SW_HIDE, ewWaitUntilTerminated, ErrorCode);
  24. msg := Format('SqlLocalDb: bRes = %d, err = %d,%s(%s)', [bRes, ErrorCode, newline, value]);
  25. end;

Дальше идёт "загадочный" пункт настройка путей, ра хотели сами разбраться, что надо, а что нет, то даю в оригинале, сами решайте, что с этой портянкой вам делать, с большой долей вероятности здесь нет каких-то отличий с 7.4, даже сама функция, наверное, называется также, поэтому гадайте, какой содержимое оставить AppPostSetup, который в конце запускается определён для мебели так #define AppPostSetup "MPostSetup"

  1. function NBSetupInf(): Boolean;
  2. var
  3. Section, Filename, szMenuName1, szMenuName2, msg, szCutting, szCuttingPath, s1, s2: String;
  4. ResultCode: Integer;
  5. begin
  6. Filename := ExpandConstant('{app}\Bin\SetupInf.ini');
  7. szMasterAppData := GetAppData(''); //ExpandConstant(AddBackslash('{commonappdata}') + '{#MasterAppDataTail}');
  8. szSlaveAppData := GetAppData(''); //ExpandConstant(AddBackslash('{commonappdata}') + '{#SlaveAppDataTail}');
  9. szMenuName2:=''
  10. if (GetAppPower()=0) then begin //ПКМ
  11. szMenuName1 := 'MebelMenuFullPKM.xml';
  12. end;
  13. if (GetAppPower()=1) then begin // Салон
  14. szMenuName1 := 'MebelMenuFullSalon.xml';
  15. end;
  16. if (GetAppPower()=3) then begin // Амби
  17. szMenuName1 := 'MebelMenuFullAmbi.xml';
  18. end;
  19. if (GetAppPower()=4) then begin // Фасад
  20. szMenuName1 := 'MebelMenuFullFasade.xml';
  21. end;
  22. #ifdef TRIAL
  23. if Not RegQueryStringValue(HKLM, 'SOFTWARE\Wow6432Node\GeoS\K3-Mebel Cutting Trial\8.0',
  24. 'App', szCutting) then
  25. begin
  26. szCutting:='';
  27. end;
  28. if Not RegQueryStringValue(HKLM, 'SOFTWARE\Wow6432Node\GeoS\K3-Mebel Cutting Trial\8.0',
  29. 'AppData', szCuttingPath) then
  30. begin
  31. szCuttingPath:='';
  32. end;
  33. #endif
  34. #ifdef VPN
  35. if Not RegQueryStringValue(HKLM, 'SOFTWARE\Wow6432Node\GeoS\K3-Mebel Cutting VPN\8.0',
  36. 'App', szCutting) then
  37. begin
  38. szCutting:='';
  39. end;
  40. if Not RegQueryStringValue(HKLM, 'SOFTWARE\Wow6432Node\GeoS\K3-Mebel Cutting VPN\8.0',
  41. 'AppData', szCuttingPath) then
  42. begin
  43. szCuttingPath:='';
  44. end;
  45. #endif
  46. #ifdef WORK
  47. if Not RegQueryStringValue(HKLM, 'SOFTWARE\Wow6432Node\GeoS\K3-Mebel Cutting\8.0',
  48. 'App', szCutting) then
  49. begin
  50. szCutting:='';
  51. end;
  52. if Not RegQueryStringValue(HKLM, 'SOFTWARE\Wow6432Node\GeoS\K3-Mebel Cutting\8.0',
  53. 'AppData', szCuttingPath) then
  54. begin
  55. szCuttingPath:='';
  56. end;
  57. #endif
  58. #ifdef DEMO
  59. if Not RegQueryStringValue(HKLM, 'SOFTWARE\Wow6432Node\GeoS\K3-Mebel Cutting Demo\8.0',
  60. 'App', szCutting) then
  61. begin
  62. szCutting:='';
  63. end;
  64. if Not RegQueryStringValue(HKLM, 'SOFTWARE\Wow6432Node\GeoS\K3-Mebel Cutting Demo\8.0',
  65. 'AppData', szCuttingPath) then
  66. begin
  67. szCuttingPath:='';
  68. end;
  69. #endif
  70. #ifdef VPN
  71. Section := 'VPN';
  72. DeleteIniSection(Section, Filename);
  73. SetIniString(Section, 'Name', 'GeoS_VPN', Filename);
  74. SetIniString(Section, 'VpnIp', '{#CmGeoSVPNServer}', Filename);
  75. #endif
  76. Section := 'Setup';
  77. DeleteIniSection(Section, Filename);
  78. SetIniString(Section, 'Version', '3', Filename);
  79. SetIniString(Section, 'Silent', '0', Filename);
  80. SetIniString(Section, 'Language', '25', Filename);
  81. SetIniString(Section, 'MasterAppDataFolder', AddBackslash(szMasterAppData), Filename);
  82. SetIniString(Section, 'CommonAppDataPrefix', AddBackslash(szMasterAppData), Filename);
  83. SetIniString(Section, 'CommonAppDataSuffix', '{#MasterAppDataTail}', Filename);
  84. SetIniString(Section, 'ProjectPath', AddBackslash(szProjectPath), Filename);
  85. SetIniString(Section, 'RootPath', AddBackslash(ExpandConstant('{app}')), Filename);
  86. SetIniString(Section, 'SQLInstance', szSQLInstance, Filename);
  87. SetIniBool(Section, ExpandConstant('{#AppBase}'), bExistAppMain, Filename);
  88. SetIniBool(Section, ExpandConstant('{#SlaveAppBase}'), bExistSlaveAppMain, Filename);
  89. SetIniBool(Section, 'DemoKit', bDemoKit, Filename);
  90. SetIniInt(Section, 'Salon', GetAppPower(), Filename);
  91. SetIniInt(Section, 'Network', 0, Filename);
  92. msg := '{#ThisGuid}';
  93. Delete(msg, 1, 1);
  94. SetIniString(Section, 'GUID', msg, Filename);
  95. SetIniString(Section, 'GUID2', szGuid2, Filename);
  96. // Section [Rendering]
  97. Section := 'Rendering';
  98. DeleteIniSection(Section, Filename);
  99. SetIniInt(Section, 'Overwrite', 1, Filename);
  100. SetIniInt(Section, 'TotalML',10, Filename);
  101. SetIniString(Section, 'ML1', 'pkm7_1.ml', Filename);
  102. SetIniString(Section, 'ML2', 'room3.ml', Filename);
  103. SetIniString(Section, 'ML3', 'Fasads.ml', Filename);
  104. SetIniString(Section, 'ML4', 'm_mebel7_1.ml', Filename);
  105. SetIniString(Section, 'ML5', 'BumpLib.ml', Filename);
  106. SetIniString(Section, 'ML6', 'CS.ml', Filename);
  107. SetIniString(Section, 'ML7', 'pkm6_3.ml', Filename);
  108. SetIniString(Section, 'ML8', 'RAL_Classic_K7.ml', Filename);
  109. SetIniString(Section, 'ML9', 'room1.ml', Filename);
  110. SetIniString(Section, 'ML10', 'room2.ml', Filename);
  111.  
  112. // Section [exRDT]
  113. Section := 'exRDT';
  114. DeleteIniSection(Section, Filename);
  115. SetIniInt(Section, 'Overwrite', 1, Filename);
  116. SetIniInt(Section, 'Who', 0, Filename);
  117. SetIniInt(Section, 'TotalLines', 20, Filename);
  118. SetIniString(Section, 'Line1', 'pkm7_1.ml', Filename);
  119. SetIniString(Section, 'Line2', szCutting, Filename);
  120. SetIniString(Section, 'Line3', AddBackslash(szCuttingPath), Filename);
  121. #if APPLICATION_POWER == PKM_INS || APPLICATION_POWER == FASADE_INS || APPLICATION_POWER == PKM_BETA_INS
  122. #ifndef DEMO
  123. SetIniString(Section, 'Line4', '%ROOTPATH%\Bin\k3cncw.exe', Filename);
  124. SetIniString(Section, 'Line5', '%MASTERAPPDATAFOLDER%\Data\PKM\PROTO\CNC\', Filename);
  125. #else
  126. SetIniString(Section, 'Line4', '', Filename);
  127. SetIniString(Section, 'Line5', '', Filename);
  128. #endif
  129. #else
  130. SetIniString(Section, 'Line4', '', Filename);
  131. SetIniString(Section, 'Line5', '', Filename);
  132. #endif
  133. SetIniString(Section, 'Line6', '<Proto>=%MASTERAPPDATAFOLDER%\Data\PKM\Proto', Filename);
  134. #if APPLICATION_POWER != FASADE_INS
  135. SetIniString(Section, 'Line7', '<Models>=%MASTERAPPDATAFOLDER%\Data\PKM\Models', Filename);
  136. #else
  137. SetIniString(Section, 'Line7', '<Models>=', Filename);
  138. #endif
  139. SetIniString(Section, 'Line8', '<Projects>=%PROJECTPATH%', Filename);
  140. SetIniString(Section, 'Line9', '<App>=%ROOTPATH%\Bin', Filename);
  141. SetIniString(Section, 'Line10', '<Reports>=%MASTERAPPDATAFOLDER%\Bin\Reports', Filename);
  142. SetIniString(Section, 'Line11', '<Textures>=%MASTERAPPDATAFOLDER%\Bin\MatLib', Filename);
  143. SetIniString(Section, 'Line12', '<K3Files>=%MASTERAPPDATAFOLDER%\Data\PKM\K3Files', Filename);
  144. #if APPLICATION_POWER == FASADE_INS
  145. SetIniString(Section, 'Line13', '<Pictures>=', Filename);
  146. #else
  147. SetIniString(Section, 'Line13', '<Pictures>=%MASTERAPPDATAFOLDER%\Data\PKM\Pictures', Filename);
  148. #endif
  149. SetIniString(Section, 'Line14', '<CommonAppData>=%MASTERAPPDATAFOLDER%\BIN', Filename);
  150. SetIniString(Section, 'Line15', '<OrderRemoveToArchive>=%PROJECTPATH%\OrderRemoveToArchive', Filename);
  151. SetIniString(Section, 'Line16', '<ExportImport>=%PROJECTPATH%\ExportImport', Filename);
  152. #if APPLICATION_POWER == FASADE_INS
  153. SetIniString(Section, 'Line17', '<Tests>=', Filename);
  154. #else
  155. SetIniString(Section, 'Line17', '<Tests>=%MASTERAPPDATAFOLDER%\Data\PKM\Tests', Filename);
  156. #endif
  157. SetIniString(Section, 'Line18', '%MASTERAPPDATAFOLDER%\Data\PKM\NGuides.mdb', Filename);
  158. SetIniString(Section, 'Line19', '0', Filename);
  159. SetIniString(Section, 'Line20', '<PyEnv>=%MASTERAPPDATAFOLDER%\Data\PKM\PyEnv', Filename);
  160. SetIniInt(Section, 'Id1', 10, Filename);
  161. SetIniInt(Section, 'Id2', 12, Filename);
  162. SetIniInt(Section, 'Id3', 13, Filename);
  163. SetIniInt(Section, 'Id4', 2, Filename);
  164. SetIniInt(Section, 'Id5', 3, Filename);
  165. SetIniInt(Section, 'Id6', 300, Filename);
  166. SetIniInt(Section, 'Id7', 301, Filename);
  167. SetIniInt(Section, 'Id8', 302, Filename);
  168. SetIniInt(Section, 'Id9', 303, Filename);
  169. SetIniInt(Section, 'Id10', 304, Filename);
  170. SetIniInt(Section, 'Id11', 305, Filename);
  171. SetIniInt(Section, 'Id12', 306, Filename);
  172. SetIniInt(Section, 'Id13', 307, Filename);
  173. SetIniInt(Section, 'Id14', 308, Filename);
  174. SetIniInt(Section, 'Id15', 309, Filename);
  175. SetIniInt(Section, 'Id16', 310, Filename);
  176. SetIniInt(Section, 'Id17', 320, Filename);
  177. SetIniInt(Section, 'Id18', 4, Filename);
  178. SetIniInt(Section, 'Id19', 1, Filename);
  179. SetIniInt(Section, 'Id20', 321, Filename);
  180. // Section [WDefs]
  181. #if 0
  182. Section := 'WDefs';
  183. DeleteIniSection(Section, Filename);
  184. SetIniInt(Section, 'Overwrite', 1, Filename);
  185. SetIniInt(Section, 'Line0', 10, Filename);
  186. SetIniInt(Section, 'Line1', 11, Filename);
  187. SetIniInt(Section, 'Line2', 0, Filename);
  188. SetIniInt(Section, 'Line3', 0, Filename);
  189. SetIniInt(Section, 'Line4', 0, Filename);
  190. #endif
  191. // Section [STPath]
  192. #if 0
  193. Section := 'STPath';
  194. DeleteIniSection(Section, Filename);
  195. SetIniString(Section, 'ExePath', '%ROOTPATH%\Bin\Mebel.exe', Filename);
  196. SetIniString(Section, 'K32ExePath', '%ROOTPATH%\Bin\K32.exe', Filename);
  197. SetIniString(Section, 'MainPath', '%MASTERAPPDATAFOLDER%\BIN\', Filename);
  198. SetIniString(Section, 'K32MainPath', '%MASTERAPPDATAFOLDER%\BIN\', Filename);
  199. SetIniString(Section, 'GuidesPath', '%MASTERAPPDATAFOLDER%\Data\PKM\tmguidesv7.mdb', Filename);
  200. SetIniString(Section, 'NGuidesPath', '%MASTERAPPDATAFOLDER%\Data\PKM\NGuides.mdb', Filename);
  201. SetIniString(Section, 'K7ProtoPath', '%MASTERAPPDATAFOLDER%\Data\PKM\K7Proto.mdb', Filename);
  202. #if APPLICATION_POWER == FASADE_INS
  203. SetIniString(Section, 'ModelsPath', '', Filename);
  204. #else
  205. SetIniString(Section, 'ModelsPath', '%MASTERAPPDATAFOLDER%\Data\PKM\MODELS\', Filename);
  206. #endif
  207. SetIniString(Section, 'CustPrjPath', '%PROJECTPATH%\', Filename);
  208. SetIniString(Section, 'ProtoPath', '%MASTERAPPDATAFOLDER%\Data\PKM\PROTO\', Filename);
  209. SetIniString(Section, 'TObjPath', '', Filename);
  210. SetIniString(Section, 'TObjMacPath', '', Filename);
  211. SetIniString(Section, 'ImlPath', '%MASTERAPPDATAFOLDER%\BIN\MatLib\pkm7_1.ml', Filename);
  212. SetIniString(Section, 'EditorPath', '%WINDIR%\notepad.exe', Filename);
  213. SetIniString(Section, 'CuttingPath', szCutting, Filename);
  214. SetIniString(Section, 'CutDataPath', AddBackslash(szCuttingPath), Filename);
  215. SetIniString(Section, 'FReportPath', '%MASTERAPPDATAFOLDER%\Bin\Reports\', Filename);
  216. SetIniString(Section, 'K3FilesPath', '%MASTERAPPDATAFOLDER%\Data\PKM\K3Files\', Filename);
  217. #if APPLICATION_POWER == FASADE_INS
  218. SetIniString(Section, 'PicturesPath', '', Filename);
  219. #else
  220. SetIniString(Section, 'PicturesPath', '%MASTERAPPDATAFOLDER%\Data\PKM\Pictures\', Filename);
  221. #endif
  222. SetIniString(Section, 'OrderRemoveToArchive', '%PROJECTPATH%\OrderRemoveToArchive\', Filename);
  223. SetIniString(Section, 'ExportImport', '%PROJECTPATH%\ExportImport\', Filename);
  224. SetIniString(Section, 'TestsPath', '%MASTERAPPDATAFOLDER%\Data\PKM\Tests\', Filename);
  225. #if APPLICATION_POWER == PKM_INS || APPLICATION_POWER == FASADE_INS || APPLICATION_POWER == PKM_BETA_INS
  226. #ifndef DEMO
  227. SetIniString(Section, 'CNCPath', '%ROOTPATH%\Bin\k3cncw.exe', Filename);
  228. SetIniString(Section, 'CNCDataPath', '%MASTERAPPDATAFOLDER%\Data\PKM\PROTO\CNC\', Filename);
  229. #else
  230. SetIniString(Section, 'CNCPath', '', Filename);
  231. SetIniString(Section, 'CNCDataPath', '', Filename);
  232. #endif
  233. #else
  234. SetIniString(Section, 'CNCPath', '', Filename);
  235. SetIniString(Section, 'CNCDataPath', '', Filename);
  236. #endif
  237. SetIniString(Section, 'PyEnv', '%MASTERAPPDATAFOLDER%\Data\PKM\PyEnv\', Filename);
  238. // Section [Menu]
  239. Section := 'Menu';
  240. DeleteIniSection(Section, Filename);
  241. SetIniInt(Section, 'TotalLines', 1, Filename);
  242. SetIniInt(Section, 'Overwrite', 1, Filename);
  243. SetIniString(Section, 'Menu1', '<Commonappdata>\'+szMenuName1, Filename);
  244. // Section [CorePath]
  245. Section := 'CorePath';
  246. DeleteIniSection(Section, Filename);
  247. SetIniInt(Section, 'Overwrite', 1, Filename);
  248. SetIniString(Section, 'Proto', '%MASTERAPPDATAFOLDER%\Data\PKM\NGuides.mdb', Filename);
  249. SetIniString(Section, 'K32Proto', '%MASTERAPPDATAFOLDER%\Data\PKM\K7Proto.mdb', Filename);
  250. #endif
  251.  
  252. //*** переименовать MebelCfg.xml
  253. s1 := ExpandConstant('{commonappdata}\{#MasterAppDataTail}\MebelCfg.xml');
  254. s2 := ExpandConstant('{userappdata}\{#MasterAppDataTail}\MebelCfg.xml');
  255. if not FileExists(s2) then begin
  256. CreateDir(ExpandConstant('{userappdata}\{#MasterAppDataTail}'));
  257. FileCopy(s1, s2, false);
  258. end;
  259. if (bExistAppMain) then begin
  260. s1 := ExpandConstant('{userappdata}\{#MasterAppDataTail}\' + szAppCfg);
  261. s2 := ExpandConstant('{userappdata}\{#MasterAppDataTail}\' + szSaveAppCfg);
  262. RenameFile(s1, s2);
  263. end;
  264. //*** переименовать K32Cfg.xml
  265. s1 := ExpandConstant('{commonappdata}\{#MasterAppDataTail}\K32Cfg.xml');
  266. s2 := ExpandConstant('{userappdata}\{#MasterAppDataTail}\K32Cfg.xml');
  267. if not FileExists(s2) then begin
  268. CreateDir(ExpandConstant('{userappdata}\{#MasterAppDataTail}'));
  269. FileCopy(s1, s2, false);
  270. end;
  271. if (bExistAppMain) then begin
  272. s1 := ExpandConstant('{userappdata}\{#MasterAppDataTail}\' + szK32Cfg);
  273. s2 := ExpandConstant('{userappdata}\{#MasterAppDataTail}\' + szSaveK32Cfg);
  274. RenameFile(s1, s2);
  275. end;
  276.  
  277. //*** Update base
  278. // Запуск PostSetup
  279. Filename := ExpandConstant('{app}\Bin\{#AppPostSetup}.exe');
  280. if not Exec(Filename, '\q', '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then begin
  281. msg := Format(ExpandConstant('Ошибка {#AppPostSetup}: %s'), [SysErrorMessage(ResultCode)]);
  282. MsgBox(msg, mbCriticalError, MB_OK);
  283. end;
  284.  
  285. Result := True;
  286. end;

инициализация настроек

в пункте 7, "инициализация настроек", для вас, наверное, полезным будет только настройка путей к спровочникам, но могу дать содержимое всех фунцкий

  1. function MebelIni(): Boolean;
  2. var
  3. Section, Filename : String;
  4. begin
  5. Filename := ExpandConstant('{app}\Bin\Mebel.ini');
  6. // Section [MetaFolders]
  7. Section := 'MetaFolders';
  8. DeleteIniSection(Section, Filename);
  9. SetIniString(Section, '<commonappdata>', AddBackslash(GetAppData(''))+'Bin', Filename);
  10. SetIniString(Section, '<appdata>', ExpandConstant(AddBackslash('%APPDATA%')+'{#SlaveAppDataTail}'), Filename);
  11. Result := True;
  12. end;
  13.  
  14. function K32Ini(): Boolean;
  15. var
  16. Section, Filename : String;
  17. begin
  18. Filename := ExpandConstant('{app}\Bin\K32.ini');
  19. // Section [MetaFolders]
  20. Section := 'MetaFolders';
  21. DeleteIniSection(Section, Filename);
  22. SetIniString(Section, '<commonappdata>', AddBackslash(GetAppData(''))+'Bin', Filename);
  23. SetIniString(Section, '<appdata>', ExpandConstant(AddBackslash('%APPDATA%')+'{#SlaveAppDataTail}'), Filename);
  24. Result := True;
  25. end;
  26.  
  27. function K3TalkIni(): Boolean;
  28. var
  29. Section, Filename : String;
  30. begin
  31. Filename := ExpandConstant('{app}\Bin\K3Talk.ini');
  32. // Section [MetaFolders]
  33. Section := 'K3Talk';
  34. DeleteIniSection(Section, Filename);
  35. SetIniString(Section, 'RealIni', AddBackslash(GetAppData(''))+'Bin\K3Talk.ini', Filename);
  36. Result := True;
  37. end;
  38.  
  39. function K3RefEditorMetapathsIni(): Boolean;
  40. var
  41. Section, Filename, FilenameUtf8 : String;
  42. var s: TArrayOfString;
  43. begin
  44. Filename := szMasterAppData + ExpandConstant('\K3RefEditor\K3RefEditorMetaPathsANSI.ini');
  45. FilenameUtf8 := szMasterAppData + ExpandConstant('\K3RefEditor\K3RefEditorMetaPaths.ini');
  46. // Section [Main]
  47. Section := 'Main';
  48. DeleteIniSection(Section, Filename);
  49.  
  50. SetIniString(Section, 'Proto', szMasterAppData + '\Data\PKM\Proto', Filename);
  51. SetIniString(Section, 'Models', szMasterAppData + '\Data\PKM\Models', Filename);
  52. SetIniString(Section, 'Textures', szMasterAppData + '\Bin\MatLib', Filename);
  53. SetIniString(Section, 'K3Files', szMasterAppData + '\Data\PKM\K3Files', Filename);
  54. SetIniString(Section, 'Pictures', szMasterAppData + '\Data\PKM\Pictures', Filename);
  55. SetIniString(Section, 'K3Mebel', ExpandConstant('{app}\Bin'), Filename);
  56. SetIniString(Section, 'K3MebelData', szMasterAppData, Filename);
  57. SetIniString(Section, 'DBFile', szMasterAppData + '\Base\NGuidesSQLNew.mdf', Filename);
  58. SetIniString(Section, 'DBUpgrades', szMasterAppData + '\Bin\K3Upgrades.mdb', Filename);
  59. SetIniString(Section, 'LDBInstanceName', 'v11.0', Filename);
  60. SetIniString(Section, 'Proto', szMasterAppData + '\Data\PKM\Proto', Filename);
  61. if LoadStringsFromFile(FileName, s) then
  62. if SaveStringsToUTF8File(FilenameUtf8, s, false) then
  63. DeleteFile(FileName);
  64. Result := True;
  65. end;

Установка драйвера ключа и ещё некоторые приблуды

Ну и последний содержательный пункт - установка драйвера ключа и ещё некоторые приблуды, которые выполняются в это же время, а перед этим пара вспомогательных функций для определения надо ставить или нет, которые тоже используются

  1. function IsCmDriver(): Boolean;
  2. begin
  3. Result := RegValueExists(RootKeyHKLM, 'SOFTWARE\WIBU-SYSTEMS\CodeMeter', 'RuntimeVersion');
  4. end;
  5.  
  6. //####################################( [NB] Драйвер не установлен или устарел )
  7. function IsObsoledCmDriver(): Boolean;
  8. var
  9. valS : String;
  10. begin
  11. if RegQueryStringValue(RootKeyHKLM, 'SOFTWARE\WIBU-SYSTEMS\CodeMeter', 'RuntimeVersion', valS) then begin
  12. #ifndef Online
  13. if CompareText(valS, '{#CmDriver}') < 0 then
  14. #else
  15. if CompareText(valS, '{#CmDriverOnline}') < 0 then
  16. #endif
  17. Result := True // драйвер установлен, но устарел
  18. else
  19. Result := False; // драйвер установлен, версия не старее, чем в дистрибутиве
  20. end else // драйвер не установлен
  21. Result := True;
  22. end;
  23.  
  24. //###################################################( [NB] Сервер ключа есть? )
  25. function IsCmServerList(): Boolean;
  26. var
  27. Names: TArrayOfString;
  28. I: Integer;
  29. valS, branch, branch2: String;
  30. begin
  31. //*** серверы ключей
  32. branch := 'Software\WIBU-SYSTEMS\CodeMeter\Server\CurrentVersion\ServerSearchList';
  33. if not RegGetSubkeyNames(RootKeyHKLM, branch, Names) then begin // списка нет вообще
  34. Result := false;
  35. exit;
  36. end;
  37. Result := false;
  38. for I := 0 to GetArrayLength(Names)-1 do begin
  39. branch2 := Format('%s\\%s', [branch, Names[I]]);
  40. valS := '?';
  41. RegQueryStringValue(RootKeyHKLM, branch2, 'Address', valS);
  42. #ifdef Online
  43. if (0 = CompareText(valS, '{#CmGeoSServer}')) and (0 = CompareText(valS, '{#CmGeoSServerReserve}')) then Result := true;
  44. #endif
  45. #ifdef TRIAL
  46. if 0 = CompareText(valS, '{#CmGeoSServer}') then Result := true;
  47. #endif
  48. #ifdef VPN
  49. if 0 = CompareText(valS, '{#CmGeoSVPNServer}') then Result := true;
  50. #endif
  51. end;
  52. end;
  53. function NBTasks(): Boolean;
  54. var
  55. ErrorCode: Integer;
  56. bRes: Boolean;
  57. Filename: String;
  58. ini, section, value: String;
  59. ErrorMsg: String;
  60. begin
  61. ini := ExpandConstant('{app}\Bin\SetupInf.ini');
  62. section := 'Log';
  63. //-- Создать папки с экспортом/импортом и архивом
  64. if (not DirExists(AddBackslash(szProjectPath)+'ExportImport')) then
  65. begin
  66. if (not CreateDir(AddBackslash(szProjectPath)+'ExportImport')) then
  67. value := Format('Не удалось создать папку для Экспорта/Импорта', [])
  68. else
  69. value := Format('Папка для Экспорта/Импорта успешно создана', [])
  70. end
  71. else
  72. value := Format('Папка для Экспорта/Импорта уже присутствует', []);
  73. SetIniString(section, 'ExportImport', value, ini);
  74. if (not DirExists(AddBackslash(szProjectPath)+'OrderRemoveToArchive')) then
  75. begin
  76. if (not CreateDir(AddBackslash(szProjectPath)+'OrderRemoveToArchive')) then
  77. value := Format('Не удалось создать папку для хранения архива', [])
  78. else
  79. value := Format('Папка для хранения архива успешно создана', [])
  80. end
  81. else
  82. value := Format('Папка для хранения архива уже присутствует', []);
  83. SetIniString(section, 'OrderRemoveToArchive', value, ini);
  84. //***
  85. //*** Версия Windows
  86. SetIniBool(section, 'AppV78', bVista, ini);
  87. //*** установить драйвер ключа
  88. #if 0
  89. if IsTaskSelected('DongleRunTime') then begin
  90. bRes := ShellExec('', ExpandConstant('{app}\Kit\CodeMeter Driver\CodeMeterRuntime.exe'), '/ComponentArgs "*":"/q"', '', SW_SHOW, ewWaitUntilTerminated, ErrorCode);
  91. CMExecErr := ErrorCode;
  92.  
  93. value := Format('Установка драйвера ключа (%d)', [bRes]);
  94. SetIniString(section, 'CodeMeterInstall', value, ini);
  95. end;
  96. #endif
  97. #ifndef DEMO
  98. if not IsCmDriver() or IsObsoledCmDriver then begin //[15.10.19]
  99. bRes := ShellExec('', ExpandConstant('{app}\Kit\CodeMeter Driver\CodeMeterRuntime.exe'), '/ComponentArgs "*":"/q"', '', SW_SHOW, ewWaitUntilTerminated, ErrorCode);
  100. CMExecErr := ErrorCode;
  101. end;
  102. #endif
  103.  
  104. //*** обновить список поиска сервера ключей
  105. if IsCmDriver() {and not IsCmServerList()} then begin
  106. CmServerListUpdate();
  107. end;
  108. // end;
  109. //*** установить видеокодек Xvid
  110. if IsTaskSelected('Xvid') then begin
  111. bRes := ShellExec('', ExpandConstant('{app}\Kit\Xvid\Xvid-1.3.4-20150621.exe'), '/q', '', SW_SHOW, ewWaitUntilTerminated, ErrorCode);
  112. value := Format('Установка видеокодека Xvid (%d)', [bRes]);
  113. SetIniString(section, 'XvidInstall', value, ini);
  114. end;
  115. Result := True;
  116. end;

регистрация ActiveX

ну и вишенка на торте - регистрация ActiveX компонента визуализации

  1. function NBRegisterDLL(): Boolean;
  2. var
  3. s: String;
  4. begin
  5. s := szMasterAppData + ExpandConstant('\K3ViewAX\K3ViewAX.ocx');
  6. if FileExists(s) then RegisterServer(False, s, True);
  7. Result := True;
  8. end;

Комментарии

Популярные сообщения из этого блога

SQLAlchemy: Подключение к уже существующим базам данных

Настройка MSSQL Server 12 Express для доступа из локальной сети к справочникам k3mebel

Отключение запроса на изменение пароля при первом подключении Ошибка 15128 ... MUST_CHANGE is ON.