MCPcopy Create free account
hub / github.com/AutoHotkey/AutoHotkey / GetAHKInstallDir

Function GetAHKInstallDir

source/script2.cpp:4731–4753  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4729
4730
4731DWORD GetAHKInstallDir(LPTSTR aBuf)
4732// Caller must ensure that aBuf is large enough (either by having called this function a previous time
4733// to get the length, or by making it MAX_PATH in capacity).
4734// Returns the length of the string (0 if empty).
4735{
4736 TCHAR buf[MAX_PATH];
4737 DWORD length;
4738#ifdef _WIN64
4739 // First try 64-bit registry, then 32-bit registry.
4740 for (DWORD flag = 0; ; flag = KEY_WOW64_32KEY)
4741#else
4742 // First try 32-bit registry, then 64-bit registry.
4743 for (DWORD flag = 0; ; flag = KEY_WOW64_64KEY)
4744#endif
4745 {
4746 length = ReadRegString(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\AutoHotkey"), _T("InstallDir"), buf, MAX_PATH, flag);
4747 if (length || flag)
4748 break;
4749 }
4750 if (aBuf)
4751 _tcscpy(aBuf, buf); // v1.0.47: Must be done as a separate copy because passing a size of MAX_PATH for aBuf can crash when aBuf is actually smaller than that (even though it's large enough to hold the string).
4752 return length;
4753}
4754
4755
4756

Callers 2

FindAutoHotkeyUtilFunction · 0.85
BIV_DECL_RFunction · 0.85

Calls 1

ReadRegStringFunction · 0.85

Tested by

no test coverage detected