| 3195 | // but that would require Administrator priviledges on modern systems. |
| 3196 | |
| 3197 | flag FRegisterExtensions() |
| 3198 | { |
| 3199 | HKEY hkey; |
| 3200 | char szExe[cchSzMax], szIco[cchSzMax], *pch; |
| 3201 | |
| 3202 | GetModuleFileName(wi.hinst, szExe, cchSzMax); |
| 3203 | sprintf(szIco, "%s,1", szExe); |
| 3204 | for (pch = szExe; *pch; pch++) |
| 3205 | ; |
| 3206 | sprintf(pch, "%s", " %1"); |
| 3207 | |
| 3208 | // Define .as extension and point it to Astrolog File Type. |
| 3209 | if (RegCreateKey(HKEY_CURRENT_USER, |
| 3210 | "Software\\Classes\\.as", &hkey) != ERROR_SUCCESS) |
| 3211 | goto LError; |
| 3212 | if (RegSetValue(hkey, NULL, REG_SZ, "Astrolog.as", 11) != ERROR_SUCCESS) |
| 3213 | goto LError; |
| 3214 | RegCloseKey(hkey); |
| 3215 | |
| 3216 | // Set File Type name for .as extensions. |
| 3217 | if (RegCreateKey(HKEY_CURRENT_USER, |
| 3218 | "Software\\Classes\\Astrolog.as", &hkey) != ERROR_SUCCESS) |
| 3219 | goto LError; |
| 3220 | if (RegSetValue(hkey, NULL, REG_SZ, "Astrolog Settings", 17) != |
| 3221 | ERROR_SUCCESS) |
| 3222 | goto LError; |
| 3223 | RegCloseKey(hkey); |
| 3224 | |
| 3225 | // Make .as extension files be opened by Astrolog. |
| 3226 | if (RegCreateKey(HKEY_CURRENT_USER, |
| 3227 | "Software\\Classes\\Astrolog.as\\shell\\open\\command", |
| 3228 | &hkey) != ERROR_SUCCESS) |
| 3229 | goto LError; |
| 3230 | if (RegSetValue(hkey, NULL, REG_SZ, szExe, CchSz(szExe)) != ERROR_SUCCESS) |
| 3231 | goto LError; |
| 3232 | RegCloseKey(hkey); |
| 3233 | |
| 3234 | // Make .as extension files be edited by Windows Notepad. |
| 3235 | if (RegCreateKey(HKEY_CURRENT_USER, |
| 3236 | "Software\\Classes\\Astrolog.as\\shell\\edit\\command", |
| 3237 | &hkey) != ERROR_SUCCESS) |
| 3238 | goto LError; |
| 3239 | if (RegSetValue(hkey, NULL, REG_SZ, "Notepad %1", 10) != ERROR_SUCCESS) |
| 3240 | goto LError; |
| 3241 | RegCloseKey(hkey); |
| 3242 | |
| 3243 | // Set icon for .as extension files. |
| 3244 | if (RegCreateKey(HKEY_CURRENT_USER, |
| 3245 | "Software\\Classes\\Astrolog.as\\DefaultIcon", &hkey) != ERROR_SUCCESS) |
| 3246 | goto LError; |
| 3247 | if (RegSetValue(hkey, NULL, REG_SZ, szIco, CchSz(szIco)) != ERROR_SUCCESS) |
| 3248 | goto LError; |
| 3249 | RegCloseKey(hkey); |
| 3250 | |
| 3251 | if (wi.wCmd == cmdSetupExtension) |
| 3252 | PrintNotice("Registered Astrolog as owner of file extension \".as\".\n"); |
| 3253 | return fTrue; |
| 3254 | LError: |
no test coverage detected