summaryrefslogtreecommitdiff
path: root/gio
diff options
context:
space:
mode:
authorOle André Vadla Ravnås <oleavr@gmail.com>2018-08-15 22:25:08 +0200
committerOle André Vadla Ravnås <oleavr@gmail.com>2021-01-05 21:42:59 +0100
commit0ab51f8d4eafacae84fd73d635e1b1469ccc8459 (patch)
tree113f7d5a5585c2abfb8a9d7beee9e2b6006cf465 /gio
parent01b77666bc52d7ef2c4c20319153be1165f8643d (diff)
downloadglib-0ab51f8d4eafacae84fd73d635e1b1469ccc8459.tar.gz
gwin32: Always use unicode APIs
Instead of the legacy ANSI ones. This also means GLib behaves correctly when built with unicode preprocessor defines.
Diffstat (limited to 'gio')
-rw-r--r--gio/gwin32mount.c8
-rw-r--r--gio/gwin32registrykey.c2
-rw-r--r--gio/gwin32volumemonitor.c24
-rw-r--r--gio/win32/gwinhttpvfs.c14
4 files changed, 27 insertions, 21 deletions
diff --git a/gio/gwin32mount.c b/gio/gwin32mount.c
index 5b4847a9d..83d8695a1 100644
--- a/gio/gwin32mount.c
+++ b/gio/gwin32mount.c
@@ -131,6 +131,9 @@ _g_win32_mount_new (GVolumeMonitor *volume_monitor,
{
GWin32Mount *mount;
const gchar *drive = path; //fixme
+ WCHAR *drive_utf16;
+
+ drive_utf16 = g_utf8_to_utf16 (drive, -1, NULL, NULL, NULL);
#if 0
/* No volume for mount: Ignore internal things */
@@ -141,7 +144,7 @@ _g_win32_mount_new (GVolumeMonitor *volume_monitor,
mount = g_object_new (G_TYPE_WIN32_MOUNT, NULL);
mount->volume_monitor = volume_monitor != NULL ? g_object_ref (volume_monitor) : NULL;
mount->mount_path = g_strdup (path);
- mount->drive_type = GetDriveType (drive);
+ mount->drive_type = GetDriveTypeW (drive_utf16);
mount->can_eject = FALSE; /* TODO */
mount->name = _win32_get_displayname (drive);
@@ -151,6 +154,9 @@ _g_win32_mount_new (GVolumeMonitor *volume_monitor,
if (volume != NULL)
_g_win32_volume_set_mount (volume, mount);
#endif
+
+ g_free (drive_utf16);
+
return mount;
}
diff --git a/gio/gwin32registrykey.c b/gio/gwin32registrykey.c
index 6b24fdd90..29895217d 100644
--- a/gio/gwin32registrykey.c
+++ b/gio/gwin32registrykey.c
@@ -2484,7 +2484,7 @@ g_win32_registry_key_watch (GWin32RegistryKey *key,
if (g_once_init_enter (&nt_notify_change_multiple_keys))
{
NtNotifyChangeMultipleKeysFunc func;
- HMODULE ntdll = GetModuleHandle ("ntdll.dll");
+ HMODULE ntdll = GetModuleHandleW (L"ntdll.dll");
if (ntdll != NULL)
func = (NtNotifyChangeMultipleKeysFunc) GetProcAddress (ntdll, "NtNotifyChangeMultipleKeys");
diff --git a/gio/gwin32volumemonitor.c b/gio/gwin32volumemonitor.c
index 83d6d3260..c6657a357 100644
--- a/gio/gwin32volumemonitor.c
+++ b/gio/gwin32volumemonitor.c
@@ -68,13 +68,13 @@ get_viewable_logical_drives (void)
DWORD no_drives;
gboolean hklm_present = FALSE;
- if (RegOpenKeyEx (HKEY_LOCAL_MACHINE,
- "Software\\Microsoft\\Windows\\"
- "CurrentVersion\\Policies\\Explorer",
- 0, KEY_READ, &key) == ERROR_SUCCESS)
+ if (RegOpenKeyExW (HKEY_LOCAL_MACHINE,
+ L"Software\\Microsoft\\Windows\\"
+ L"CurrentVersion\\Policies\\Explorer",
+ 0, KEY_READ, &key) == ERROR_SUCCESS)
{
- if (RegQueryValueEx (key, "NoDrives", NULL, &var_type,
- (LPBYTE) &no_drives, &no_drives_size) == ERROR_SUCCESS)
+ if (RegQueryValueExW (key, L"NoDrives", NULL, &var_type,
+ (LPBYTE) &no_drives, &no_drives_size) == ERROR_SUCCESS)
{
/* We need the bits that are set in viewable_drives, and
* unset in no_drives.
@@ -88,13 +88,13 @@ get_viewable_logical_drives (void)
/* If the key is present in HKLM then the one in HKCU should be ignored */
if (!hklm_present)
{
- if (RegOpenKeyEx (HKEY_CURRENT_USER,
- "Software\\Microsoft\\Windows\\"
- "CurrentVersion\\Policies\\Explorer",
- 0, KEY_READ, &key) == ERROR_SUCCESS)
+ if (RegOpenKeyExW (HKEY_CURRENT_USER,
+ L"Software\\Microsoft\\Windows\\"
+ L"CurrentVersion\\Policies\\Explorer",
+ 0, KEY_READ, &key) == ERROR_SUCCESS)
{
- if (RegQueryValueEx (key, "NoDrives", NULL, &var_type,
- (LPBYTE) &no_drives, &no_drives_size) == ERROR_SUCCESS)
+ if (RegQueryValueExW (key, L"NoDrives", NULL, &var_type,
+ (LPBYTE) &no_drives, &no_drives_size) == ERROR_SUCCESS)
{
viewable_drives = viewable_drives & ~no_drives;
}
diff --git a/gio/win32/gwinhttpvfs.c b/gio/win32/gwinhttpvfs.c
index 3dfac259e..03feaf983 100644
--- a/gio/win32/gwinhttpvfs.c
+++ b/gio/win32/gwinhttpvfs.c
@@ -39,20 +39,20 @@ static void
lookup_funcs (void)
{
HMODULE winhttp = NULL;
- char winhttp_dll[MAX_PATH + 100];
+ WCHAR winhttp_dll[MAX_PATH + 100];
int n;
if (lookup_done)
return;
- n = GetSystemDirectory (winhttp_dll, MAX_PATH);
+ n = GetSystemDirectoryW (winhttp_dll, MAX_PATH);
if (n > 0 && n < MAX_PATH)
{
- if (winhttp_dll[n-1] != '\\' &&
- winhttp_dll[n-1] != '/')
- strcat (winhttp_dll, "\\");
- strcat (winhttp_dll, "winhttp.dll");
- winhttp = LoadLibrary (winhttp_dll);
+ if (winhttp_dll[n-1] != L'\\' &&
+ winhttp_dll[n-1] != L'/')
+ wcscat (winhttp_dll, L"\\");
+ wcscat (winhttp_dll, L"winhttp.dll");
+ winhttp = LoadLibraryW (winhttp_dll);
}
if (winhttp != NULL)