Board index » delphi » HELP I can't get GetUserName function's value

HELP I can't get GetUserName function's value

I'm Nishida.

I wrote this codes.

        if GetUserName(ch,sz) = false then showmessage('false')
        else                               showmessage('true');

and no compile error message or no any warning message.

But I always see 'false' message window. And 'ch' and 'sz' variable
had not chenged.

What's wrong?
Can't I use Win32api?

I use Delphi 2.0 for windows95.
Please any information. Thank you.

 

Re:HELP I can't get GetUserName function's value


Quote
nish...@cyborg.or.jp (Nishida Hironori) wrote:
>I'm Nishida.
>I wrote this codes.
>    if GetUserName(ch,sz) = false then showmessage('false')
>    else                               showmessage('true');
>and no compile error message or no any warning message.
>But I always see 'false' message window. And 'ch' and 'sz' variable
>had not chenged.
>What's wrong?

If you want to know, call the GetLastError function. From your code I
can not determine what's wrong, my guess would be that sz is not
initialized properly before the call to GetUserName (it should be the
maximum number of characters the buffer can contain).

See the Win32 API help for more info.

Quote
>Can't I use Win32api?
>I use Delphi 2.0 for windows95.
>Please any information. Thank you.

David

Other Threads