Navigation:  The Buzz > Operating System  >

Get Computer Name

Previous pageReturn to chapter overviewNext page

Dec 20, 2007  Button

Guys,

 

Another question, please:

 

I use user32.MessageBoxA to display different types of message boxes and

it works fine.

Thought it would be the same idea to use advapi32.GetUserNameA and kernel32.GetComputerNameA, but seems that I was wrong, as rather then in a message box case, here I need to get not the return code only, but a parameter returned...

 

Any ideas how to implement it, please?

F.e. I've tried to Update a numeric variable by CallDLL

('kernel32.GetComputerNameA','AL4',Param1,Param2) just to insure that I have a code returned, but with no luck... Tried Call UDP, but same problem..

 

Many thanks!!!

 

Check:

 

http://www.ng-sw.de/mg-wikka/WindowsAPI

 

Try the following:

 

Call UDP '@...'

'AL4'

<Alpha '16' variable to receive the computer name>

16

<Numeric 'N10' variable to receive return code>

 

Steve Blank

 

Steven,

 

Thanks - I have some process I guess, as I am getting Wrong number of

arguments in user function/procedure now....

I tried to send 2 or 3 parameters, but with the same result.

 

What do I miss?

 

THX

 

Just so we're both on the same page here: Magic passes the arguments

that are inside of CallDLL functions by value, not by reference, so

you must use a Call UDP operation - neither CallDLL(), nor

CallDLLF(), nor CallDLLS() will work.

 

Create two variables, as follows:

 

A Attribute: Alpha, Picture: '16'

B Attribute: Numeric, Picture: 'N10'

 

In the Call UDP operation, specify FOUR arguments as follows:

 

1) 'AL4' /* String expression */

2) A /* Variable A */

3) 16 /* Numeric expression */

4) B /* Variable B */

 

Steve Blank

 

WORKING !!!

 

Many thanks ( I missed 16 ) and Happy New Year!

 

To get the correct computernames (citrix, TS,console) i work with the

EnvironmentVariables.

 

update v-computername = Fill ('.',32)

Call prg GetEnvironmenVar('CLIENTNAME', v-Computername)

Call prg GetEnvironmenVar(''COMPUTERNAME'', v-Computername) if v-computername =

Fill ('.',32) or Upper(v-computername)='CONSOLE'

 

Prg GetEnvironmenVar looks like

update o-EnvironmentValue = Fill ('.',256)

Call UDP '@...' ('AAL4',i-EnvironmentVariable Alpha

256,o-EnvironmentValue Alpha 256, 256, v-status num 4)

 

regards

Frank Van Herreweghe

 

Very naughty I shall say :-)

 

THX !!!

 

 


Page url: http://www.magic-iug.com/MIUGWeb3/index.html?hm_get_computer_name.htm