|
9 | 9 | #include <cstring> |
10 | 10 | #include <unistd.h> |
11 | 11 |
|
| 12 | +// ============================================================ |
| 13 | +// DLL entry point constants |
| 14 | +// ============================================================ |
| 15 | +#ifndef DLL_PROCESS_ATTACH |
| 16 | +#define DLL_PROCESS_ATTACH 1 |
| 17 | +#define DLL_THREAD_ATTACH 2 |
| 18 | +#define DLL_THREAD_DETACH 3 |
| 19 | +#define DLL_PROCESS_DETACH 0 |
| 20 | +#endif |
| 21 | + |
12 | 22 | // ============================================================ |
13 | 23 | // Error codes |
14 | 24 | // ============================================================ |
@@ -1148,3 +1158,56 @@ inline HRESULT GetApplicationRestartSettings(HANDLE hProcess, LPWSTR pwzCommandl |
1148 | 1158 | if (pdwFlags) *pdwFlags = 0; |
1149 | 1159 | return E_NOTIMPL; |
1150 | 1160 | } |
| 1161 | + |
| 1162 | +// ============================================================ |
| 1163 | +// INI file (Private Profile) functions — declarations only. |
| 1164 | +// Implemented in win32_profile.mm (ObjC++ for Foundation access). |
| 1165 | +// ============================================================ |
| 1166 | +UINT GetPrivateProfileIntW(LPCWSTR lpAppName, LPCWSTR lpKeyName, INT nDefault, LPCWSTR lpFileName); |
| 1167 | +DWORD GetPrivateProfileStringW(LPCWSTR lpAppName, LPCWSTR lpKeyName, LPCWSTR lpDefault, |
| 1168 | + LPWSTR lpReturnedString, DWORD nSize, LPCWSTR lpFileName); |
| 1169 | +BOOL WritePrivateProfileStringW(LPCWSTR lpAppName, LPCWSTR lpKeyName, LPCWSTR lpString, LPCWSTR lpFileName); |
| 1170 | + |
| 1171 | +// ============================================================ |
| 1172 | +// MSVC CRT safe string functions (not in tchar.h for non-tchar code) |
| 1173 | +// ============================================================ |
| 1174 | + |
| 1175 | +#include <cerrno> |
| 1176 | +#include <cstdarg> |
| 1177 | + |
| 1178 | +// Forward-declare _wfopen from winbase.h (defined above) |
| 1179 | +#ifndef _WFOPEN_DEFINED |
| 1180 | +FILE* _wfopen(const wchar_t* filename, const wchar_t* mode); |
| 1181 | +#define _WFOPEN_DEFINED |
| 1182 | +#endif |
| 1183 | + |
| 1184 | +inline errno_t _wfopen_s(FILE** pFile, const wchar_t* filename, const wchar_t* mode) |
| 1185 | +{ |
| 1186 | + if (!pFile) return EINVAL; |
| 1187 | + *pFile = _wfopen(filename, mode); |
| 1188 | + return (*pFile) ? 0 : errno; |
| 1189 | +} |
| 1190 | + |
| 1191 | +inline errno_t _itow_s(int value, wchar_t* buf, size_t sizeInWords, int radix) |
| 1192 | +{ |
| 1193 | + if (!buf || sizeInWords == 0) return EINVAL; |
| 1194 | + if (radix == 10) |
| 1195 | + swprintf(buf, sizeInWords, L"%d", value); |
| 1196 | + else if (radix == 16) |
| 1197 | + swprintf(buf, sizeInWords, L"%x", value); |
| 1198 | + else if (radix == 8) |
| 1199 | + swprintf(buf, sizeInWords, L"%o", value); |
| 1200 | + else |
| 1201 | + buf[0] = L'\0'; |
| 1202 | + return 0; |
| 1203 | +} |
| 1204 | + |
| 1205 | +inline int _snwprintf_s(wchar_t* buf, size_t sizeOfBuffer, size_t count, const wchar_t* fmt, ...) |
| 1206 | +{ |
| 1207 | + (void)count; |
| 1208 | + va_list args; |
| 1209 | + va_start(args, fmt); |
| 1210 | + int r = vswprintf(buf, sizeOfBuffer, fmt, args); |
| 1211 | + va_end(args); |
| 1212 | + return r; |
| 1213 | +} |
0 commit comments