patrickTingen / DataDigger

A dynamic dataviewer for your Progress / OpenEdge databases
https://datadigger.wordpress.com/
MIT License
50 stars 23 forks source link

Problem in function getUserName in DataDiggerLib.p #54

Closed movedoa closed 3 years ago

movedoa commented 4 years ago

Had this on a client mashine. For some reason GetUserNameA just returned "" and not the user name but the return value (intResult) was 1. I can not reproduce this an my mashine and i can't really debug this on the clients mashine. Maybe some UAC or rights problem.

Anyway there is already a check in this function that looks at the return value and sets the name to default if the return value is <> 1

IF intResult <> 1 THEN
    cUserName = "default".
  ELSE

The code should also check if cUserName is ? or "" to account for this case.

movedoa commented 4 years ago

Just a random idea. Maybe the username contained some exotic characters. Since you use the Ansi version of the winapi function i would guess this would not work.

Maybe you should use the W versions of all winapi functions (there seem to be some more in the codebase) if cpinternal is UTF-8 (With the apropriate codepage convert of corse, see https://knowledgebase.progress.com/articles/Article/000043703 and https://knowledgebase.progress.com/articles/Article/How-to-Call-WIN32-API-Function-GetUserName)

movedoa commented 4 years ago

Thinking about it maybe this would also explain #34. SokoDigger uses SendMessageA and we run everything with UTF-8 🤔

patrickTingen commented 3 years ago

For now I think I will just use "default" if the username cannot be retrieved. Will test the sokodigger again with an UTF-8 session