0 registered members (),
1,459
guests, and 9
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: How can i get the system's name? (computer-name)
[Re: Toon]
#400677
05/06/12 01:05
05/06/12 01:05
|
Joined: Apr 2005
Posts: 4,506 Germany
fogman
Expert
|
Expert
Joined: Apr 2005
Posts: 4,506
Germany
|
Afaik it is "GetComputerName". Link: GetComputerName
Last edited by fogman; 05/06/12 01:07.
no science involved
|
|
|
Re: How can i get the system's name? (computer-name)
[Re: fogman]
#400710
05/06/12 15:16
05/06/12 15:16
|
Joined: Nov 2003
Posts: 433 The Netherlands
Toon
OP
Senior Member
|
OP
Senior Member
Joined: Nov 2003
Posts: 433
The Netherlands
|
Oke this was exactly what i was looking for but I don't know how to use it exept for including the windows.h I tried this (just a guess :P), but it doesn't work
STRING* comp = "#128";
GetComputerName(comp);
|
|
|
Re: How can i get the system's name? (computer-name)
[Re: Toon]
#400714
05/06/12 16:23
05/06/12 16:23
|
Joined: Apr 2007
Posts: 3,751 Canada
WretchedSid
Expert
|
Expert
Joined: Apr 2007
Posts: 3,751
Canada
|
You should have looked at the link which perfectly describes all parameters:
STRING *comp;
void getComputerName()
{
char buffer[MAX_COMPUTERNAME_LENGTH + 1];
long size = MAX_COMPUTERNAME_LENGTH + 1;
memset(buffer, 0, size);
if(GetComputerName(buffer, &size))
{
str_cpy(comp, buffer);
}
else
{
str_cpy(comp, "Couldn't get the computer name");
}
}
Shitlord by trade and passion. Graphics programmer at Laminar Research. I write blog posts at feresignum.com
|
|
|
Re: How can i get the system's name? (computer-name)
[Re: WretchedSid]
#400939
05/10/12 09:37
05/10/12 09:37
|
Joined: Nov 2003
Posts: 433 The Netherlands
Toon
OP
Senior Member
|
OP
Senior Member
Joined: Nov 2003
Posts: 433
The Netherlands
|
Thanks for the reply! I did look at the msdn-page but I have no clue whatsoever about this 'real c-programming' . I learned c-script back in the days of A6 and made the transition to lite-c recently... But now my next question ^^ the code you posted returned the following error: Error in line 10: syntax error < char buffer [MAX_COMPUTERNAME_LENGTH + 1]; > Here is the code of the test I tried to run:
#include <acknex.h>
#include <windows.h>
#include <default.c>
STRING *comp;
void getComputerName()
{
char buffer [MAX_COMPUTERNAME_LENGTH + 1];
long size = MAX_COMPUTERNAME_LENGTH + 1;
memset(buffer, 0, size);
if(GetComputerName(buffer, &size))
{
str_cpy(comp, buffer);
}
else
{
str_cpy(comp, "Couldn't get the computer name");
}
error(comp);
}
void main()
{
while(!key_enter){wait(1);}
getComputerName();
}
|
|
|
Re: How can i get the system's name? (computer-name)
[Re: Toon]
#400958
05/10/12 14:25
05/10/12 14:25
|
Joined: Jan 2002
Posts: 4,225 Germany / Essen
Uhrwerk
Expert
|
Expert
Joined: Jan 2002
Posts: 4,225
Germany / Essen
|
Because you didn't define that constant.
#define MAX_COMPUTERNAME_LENGTH 32
Additionally the lite-c compilter doesn't like expressions where it expects constants. S you should be on the safe side when using
char buffer [32];
long size = 32;
instead.
Always learn from history, to be sure you make the same mistakes again...
|
|
|
Re: How can i get the system's name? (computer-name)
[Re: Uhrwerk]
#400961
05/10/12 14:34
05/10/12 14:34
|
Joined: Apr 2007
Posts: 3,751 Canada
WretchedSid
Expert
|
Expert
Joined: Apr 2007
Posts: 3,751
Canada
|
Additionally the lite-c compilter doesn't like expressions where it expects constants. S you should be on the safe side when using Are you sure? Last time I checked, it worked quite good, at least in structs. Also, MAX_COMPUTERNAME_LENGTH should be defined in windows.h, at least thats were I expected it.
Shitlord by trade and passion. Graphics programmer at Laminar Research. I write blog posts at feresignum.com
|
|
|
Re: How can i get the system's name? (computer-name)
[Re: WretchedSid]
#400978
05/10/12 16:50
05/10/12 16:50
|
Joined: Jan 2002
Posts: 4,225 Germany / Essen
Uhrwerk
Expert
|
Expert
Joined: Jan 2002
Posts: 4,225
Germany / Essen
|
Are you sure? Last time I checked, it worked quite good, at least in structs. No, I am not sure. Checked that several month ago. Might well be that JCL changed it in the meantime. Also, MAX_COMPUTERNAME_LENGTH should be defined in windows.h, at least that's were I expected it. Should but isn't.
Always learn from history, to be sure you make the same mistakes again...
|
|
|
Re: How can i get the system's name? (computer-name)
[Re: Uhrwerk]
#401056
05/12/12 14:06
05/12/12 14:06
|
Joined: Dec 2009
Posts: 128 China
frankjiang
Member
|
Member
Joined: Dec 2009
Posts: 128
China
|
you can write dll above this function by Cpp anything you want to do
development 3d game is interesting!
|
|
|
|