What happens if you pass the window number as argument for the function? I.e. hWinSetName = WinSetName(sWinName, 1) if your window has window number 1.
The WinSetName returns 1 (True) when successful.
Calling it on a non-existing window does return a value >1.
E.g :
WinsetName("MyWindow") will set the name (note not the title or anything, just a name-value pair).
if you then call WinNumber("MyWindow") it will retun the number of the window.
Same if you call WinGetName() in a cicode function it will return the set name.
I had similar results in Citect 2018 R2 with the Example project. Calling WinSetName("test") from the kernel returns 12032. The window number is 1, and calling WinSetName("test", 1") returns 1 the first time, then returns 0 the 2nd time I call it. However, calling WinGetName() returns "" and WinGetName(1) returns "Main", so the set name function isn't working, even when it returns 0. What version/update of Citect are you using?
Partially it works, or maybe it works different than the help suggest.
The ExampleSA is using it quiet a lot e.g the top 5 alarms pop up uses it : Headerbar_ShowTopFiveAlarmPopup.
And if in the ExampleSA you issue e.g WinGetName(3) from the kernel, you get values and you can also alter them using WinSetName("Test",3) (probably breaking some SA functionality) which return "1" on successful execution and "0" if the value set is the same as the current value. However consecutive calls on WinSetname do not seem to change it; odd.
Maybe to understand why you need it; what do you want to use this function for?