@@ -358,6 +358,29 @@ private static extern CSTR_RESULT CompareStringA(
358
358
[ In ] int cchCount2
359
359
) ;
360
360
361
+ /// <inheritdoc cref="CompareString"/>
362
+ [ Obsolete ( "DEPRECATED: StringApiSetFunction.CompareStringEx is preferred" ) ]
363
+ public unsafe static CSTR_RESULT CompareStringA (
364
+ int Locale ,
365
+ CSTR_FLAGS dwCmpFlags ,
366
+ ReadOnlySpan < byte > lpString1 ,
367
+ int cchCount1 ,
368
+ ReadOnlySpan < byte > lpString2 ,
369
+ int cchCount2
370
+ )
371
+ {
372
+ fixed ( byte * ptrString1 = lpString1 )
373
+ fixed ( byte * ptrString2 = lpString2 )
374
+ return CompareStringA (
375
+ Locale ,
376
+ dwCmpFlags ,
377
+ Pointer . Create < LPCSTR > ( ptrString1 ) ,
378
+ cchCount1 ,
379
+ Pointer . Create < LPCSTR > ( ptrString2 ) ,
380
+ cchCount2
381
+ ) ;
382
+ }
383
+
361
384
/// <inheritdoc cref="CompareString"/>
362
385
[ Obsolete ( "DEPRECATED: StringApiSetFunction.CompareStringEx is preferred" ) ]
363
386
[ SuppressMessage ( "Globalization" ,
@@ -369,9 +392,9 @@ public static extern CSTR_RESULT CompareStringA(
369
392
[ In ] int Locale ,
370
393
[ In , MarshalAs ( UnmanagedType . I4 ) ]
371
394
CSTR_FLAGS dwCmpFlags ,
372
- [ In ] LPSTR lpString1 ,
395
+ [ In ] LPCSTR lpString1 ,
373
396
[ In ] int cchCount1 ,
374
- [ In ] LPSTR lpString2 ,
397
+ [ In ] LPCSTR lpString2 ,
375
398
[ In ] int cchCount2
376
399
) ;
377
400
#endregion
@@ -405,16 +428,36 @@ private static extern CSTR_RESULT CompareStringW(
405
428
[ In ] int cchCount2
406
429
) ;
407
430
431
+ /// <inheritdoc cref="CompareString"/>
432
+ public unsafe static CSTR_RESULT CompareStringW (
433
+ int Locale ,
434
+ CSTR_FLAGS dwCmpFlags ,
435
+ ReadOnlySpan < char > lpString1 ,
436
+ ReadOnlySpan < char > lpString2
437
+ )
438
+ {
439
+ fixed ( char * ptrString1 = lpString1 )
440
+ fixed ( char * ptrString2 = lpString2 )
441
+ return CompareStringW (
442
+ Locale ,
443
+ dwCmpFlags ,
444
+ Pointer . Create < LPCWSTR > ( ptrString1 ) ,
445
+ lpString1 . Length ,
446
+ Pointer . Create < LPCWSTR > ( ptrString2 ) ,
447
+ lpString2 . Length
448
+ ) ;
449
+ }
450
+
408
451
/// <inheritdoc cref="CompareString"/>
409
452
[ DllImport ( Kernel32 , CallingConvention = CallingConvention . Winapi , SetLastError = true , CharSet = CharSet . Unicode ) ]
410
453
[ return : MarshalAs ( UnmanagedType . I4 ) ]
411
454
public static extern CSTR_RESULT CompareStringW (
412
455
[ In ] int Locale ,
413
456
[ In , MarshalAs ( UnmanagedType . I4 ) ]
414
457
CSTR_FLAGS dwCmpFlags ,
415
- [ In ] LPWSTR lpString1 ,
458
+ [ In ] LPCWSTR lpString1 ,
416
459
[ In ] int cchCount1 ,
417
- [ In ] LPWSTR lpString2 ,
460
+ [ In ] LPCWSTR lpString2 ,
418
461
[ In ] int cchCount2
419
462
) ;
420
463
#endregion
@@ -510,6 +553,29 @@ [In] int cchCount2
510
553
} ;
511
554
#endif
512
555
556
+ /// <inheritdoc cref="CompareString"/>
557
+ [ Obsolete ( "DEPRECATED: StringApiSetFunction.CompareStringEx is preferred" ) ]
558
+ public unsafe static CSTR_RESULT CompareString (
559
+ int Locale ,
560
+ CSTR_FLAGS dwCmpFlags ,
561
+ ReadOnlySpan < byte > lpString1 ,
562
+ int cchCount1 ,
563
+ ReadOnlySpan < byte > lpString2 ,
564
+ int cchCount2
565
+ )
566
+ {
567
+ fixed ( byte * ptrString1 = lpString1 )
568
+ fixed ( byte * ptrString2 = lpString2 )
569
+ return CompareString (
570
+ Locale ,
571
+ dwCmpFlags ,
572
+ Pointer . Create < LPCTSTR > ( ptrString1 ) ,
573
+ cchCount1 ,
574
+ Pointer . Create < LPCTSTR > ( ptrString2 ) ,
575
+ cchCount2
576
+ ) ;
577
+ }
578
+
513
579
/// <inheritdoc cref="CompareString"/>
514
580
[ Obsolete ( "DEPRECATED: StringApiSetFunction.CompareStringEx is preferred" ) ]
515
581
#if ! NETSTANDARD1_3
@@ -526,9 +592,9 @@ CSTR_RESULT CompareString(
526
592
[ In ] int Locale ,
527
593
[ In , MarshalAs ( UnmanagedType . I4 ) ]
528
594
CSTR_FLAGS dwCmpFlags ,
529
- [ In ] LPTSTR lpString1 ,
595
+ [ In ] LPCTSTR lpString1 ,
530
596
[ In ] int cchCount1 ,
531
- [ In ] LPTSTR lpString2 ,
597
+ [ In ] LPCTSTR lpString2 ,
532
598
[ In ] int cchCount2
533
599
)
534
600
#if ! NETSTANDARD1_3
@@ -537,14 +603,18 @@ [In] int cchCount2
537
603
=> Marshal . SystemDefaultCharSize switch
538
604
{
539
605
1 => CompareStringA ( Locale , dwCmpFlags ,
540
- Pointer . Create < LPSTR > ( lpString1 . Pointer ) , cchCount1 ,
541
- Pointer . Create < LPSTR > ( lpString2 . Pointer ) , cchCount2 ) ,
606
+ Pointer . Create < LPCSTR > ( lpString1 . Pointer ) , cchCount1 ,
607
+ Pointer . Create < LPCSTR > ( lpString2 . Pointer ) , cchCount2 ) ,
542
608
2 => CompareStringW ( Locale , dwCmpFlags ,
543
- Pointer . Create < LPWSTR > ( lpString1 . Pointer ) , cchCount1 ,
544
- Pointer . Create < LPWSTR > ( lpString2 . Pointer ) , cchCount2 ) ,
609
+ Pointer . Create < LPCWSTR > ( lpString1 . Pointer ) , cchCount1 ,
610
+ Pointer . Create < LPCWSTR > ( lpString2 . Pointer ) , cchCount2 ) ,
545
611
_ => throw new PlatformNotSupportedException( )
546
612
} ;
547
613
#endif
548
614
#endregion
615
+ // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1626
616
+ #region FindNLSString function
617
+
618
+ #endregion
549
619
}
550
620
}
0 commit comments