Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
5 registered members (Quad, TipmyPip, degenerate_762, AndrewAMD, Nymphodora), 997 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
How can i get the system's name? (computer-name) #400671
05/05/12 22:01
05/05/12 22:01
Joined: Nov 2003
Posts: 433
The Netherlands
T
Toon Offline OP
Senior Member
Toon  Offline OP
Senior Member
T

Joined: Nov 2003
Posts: 433
The Netherlands
What is the easiest way to get the system's name / computer-name?

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
F
fogman Offline
Expert
fogman  Offline
Expert
F

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
T
Toon Offline OP
Senior Member
Toon  Offline OP
Senior Member
T

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

Code:
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 Offline
Expert
WretchedSid  Offline
Expert

Joined: Apr 2007
Posts: 3,751
Canada
You should have looked at the link which perfectly describes all parameters:
Code:
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
T
Toon Offline OP
Senior Member
Toon  Offline OP
Senior Member
T

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' tongue. 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:

Code:
#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 Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
Because you didn't define that constant.
Code:
#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
Code:
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 Offline
Expert
WretchedSid  Offline
Expert

Joined: Apr 2007
Posts: 3,751
Canada
Originally Posted By: Uhrwerk
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: Uhrwerk] #400972
05/10/12 15:32
05/10/12 15:32
Joined: Nov 2003
Posts: 433
The Netherlands
T
Toon Offline OP
Senior Member
Toon  Offline OP
Senior Member
T

Joined: Nov 2003
Posts: 433
The Netherlands
Thanks people! Here is the finished code for those who are interested:

Code:
#include <acknex.h>
#include <windows.h> 

STRING* comp = "#128";

void getComputerName()
{
    char buffer [128];
    long size = 128;

    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()
{
  getComputerName();
}



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 Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
Originally Posted By: JustSid
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.

Originally Posted By: JustSid
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 Offline
Member
frankjiang  Offline
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!

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1