[vlc-commits] [Git][videolan/vlc][master] 3 commits: ntservice: use ANSI API

Steve Lhomme (@robUx4) gitlab at videolan.org
Thu Dec 7 09:20:01 UTC 2023



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
4e84066f by Steve Lhomme at 2023-12-07T09:03:16+00:00
ntservice: use ANSI API

All the internal strings we use are using CHAR.

- - - - -
ec8924b3 by Steve Lhomme at 2023-12-07T09:03:16+00:00
windrive: use ANSI API's to test drive letters

No need for wide chars for that. The API is supported in UWP [1].
The code was also puttin a WCHAR letter in a char string.

[1] https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getdrivetypea

- - - - -
4d62dc12 by Steve Lhomme at 2023-12-07T09:03:16+00:00
eject: use ANSI API's to handle Windows drive letters

We don't need wide chars for this.

- - - - -


3 changed files:

- modules/control/ntservice.c
- modules/gui/eject.c
- modules/services_discovery/windrive.c


Changes:

=====================================
modules/control/ntservice.c
=====================================
@@ -139,9 +139,9 @@ void Close( vlc_object_t *p_this )
 static void *Run( void *data )
 {
     intf_thread_t *p_intf = data;
-    SERVICE_TABLE_ENTRY dispatchTable[] =
+    const SERVICE_TABLE_ENTRYA dispatchTable[] =
     {
-        { (WCHAR*) TEXT(VLCSERVICENAME), (LPSERVICE_MAIN_FUNCTION) &ServiceDispatch },
+        { (LPSTR)VLCSERVICENAME, (LPSERVICE_MAIN_FUNCTIONA) &ServiceDispatch },
         { NULL, NULL }
     };
 
@@ -164,7 +164,7 @@ static void *Run( void *data )
         return NULL;
     }
 
-    if( StartServiceCtrlDispatcher( dispatchTable ) == 0 )
+    if( StartServiceCtrlDispatcherA( dispatchTable ) == 0 )
     {
         msg_Err( p_intf, "StartServiceCtrlDispatcher failed" ); /* str review */
     }


=====================================
modules/gui/eject.c
=====================================
@@ -124,14 +124,12 @@ static int intf_Eject( vlc_object_t *p_this, const char *psz_device )
     VLC_UNUSED(p_this);
 
 #if defined(_WIN32)
-    MCI_OPEN_PARMS op;
+    MCI_OPEN_PARMSA op = {};
     DWORD i_flags;
-    WCHAR psz_drive[4];
+    CHAR psz_drive[] = "X:";
 
-    memset( &op, 0, sizeof(MCI_OPEN_PARMS) );
-    op.lpstrDeviceType = (LPCTSTR)MCI_DEVTYPE_CD_AUDIO;
+    op.lpstrDeviceType = (LPCSTR)MCI_DEVTYPE_CD_AUDIO;
 
-    wcscpy( psz_drive, TEXT("X:") );
     psz_drive[0] = psz_device[0];
     op.lpstrElementName = psz_drive;
 
@@ -139,7 +137,7 @@ static int intf_Eject( vlc_object_t *p_this, const char *psz_device )
     i_flags = MCI_OPEN_TYPE | MCI_OPEN_TYPE_ID |
               MCI_OPEN_ELEMENT | MCI_OPEN_SHAREABLE;
 
-    if( mciSendCommand( 0, MCI_OPEN, i_flags, (uintptr_t)&op ) )
+    if( mciSendCommandA( 0, MCI_OPEN, i_flags, (uintptr_t)&op ) )
         return VLC_EGENERIC;
 
     /* Eject disc */


=====================================
modules/services_discovery/windrive.c
=====================================
@@ -60,19 +60,19 @@ static int Open (vlc_object_t *obj)
 
     LONG drives = GetLogicalDrives ();
     char mrl[12] = "file:///A:/", name[3] = "A:";
-    WCHAR path[4] = TEXT("A:\\");
+    CHAR path[4] = "A:\\";
 
     for (char d = 0; d < 26; d++)
     {
         input_item_t *item;
-        WCHAR letter = 'A' + d;
+        CHAR letter = 'A' + d;
 
         /* Does this drive actually exist? */
         if (!(drives & (1 << d)))
             continue;
         /* Is it a disc drive? */
         path[0] = letter;
-        if (GetDriveType (path) != DRIVE_CDROM)
+        if (GetDriveTypeA (path) != DRIVE_CDROM)
             continue;
 
         mrl[8] = name[0] = letter;



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/63d44f046a59f0090954022a9b44903f114152b0...4d62dc124285f9e7488d100f3ebe2c841ce9d32d

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/63d44f046a59f0090954022a9b44903f114152b0...4d62dc124285f9e7488d100f3ebe2c841ce9d32d
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list