Узнать имя компа
От: Sheridan Россия  
Дата: 24.10.05 13:12
Оценка:
как можно узнать имя компьютера с помощью winapi?

[RSDN@Home][1.2.0][alpha][619]
[Делай великое, не обещая великого. [Пифагор]]
Matrix has you...
Re: Узнать имя компа
От: SergH Россия  
Дата: 24.10.05 13:22
Оценка:
Здравствуйте, Sheridan, Вы писали:

S>как можно узнать имя компьютера с помощью winapi?


Текущего?

GetComputerName
GetComputerNameEx
GetComputerObjectName
Делай что должно, и будь что будет
Re[2]: Узнать имя компа
От: Zibir Чехия www.tigru.org
Дата: 16.03.06 07:16
Оценка:
Здравствуйте, SergH, Вы писали:

SH>Здравствуйте, Sheridan, Вы писали:


S>>как можно узнать имя компьютера с помощью winapi?


SH>Текущего?


SH>GetComputerName

SH>GetComputerNameEx
SH>GetComputerObjectName

А конкретный пример можно?
Re[3]: Узнать имя компа
От: pullover  
Дата: 16.03.06 08:13
Оценка:
Z>А конкретный пример можно?
MSDN:

#include <windows.h>
#include <stdio.h>

#define BUFSIZE 1024

void main()
{
   LPTSTR lpszSystemInfo;      // pointer to system information string 
   DWORD cchBuff = BUFSIZE;    // size of computer or user name 
   TCHAR tchBuffer[BUFSIZE];   // buffer for string

   DWORD dwResult;             // function return value
 
   lpszSystemInfo = tchBuffer; 
 
   // Get and display the name of the computer. 
 
   if( GetComputerName(lpszSystemInfo, &cchBuff) ) 
      printf("Computer name:  %s\n", lpszSystemInfo); 
 
   // Get and display the user name. 

   cchBuff = BUFSIZE; 
   if( GetUserName(lpszSystemInfo, &cchBuff) )
      printf("User name:  %s\n\n", lpszSystemInfo);
 
   // Get and display the system directory. 
 
   if( GetSystemDirectory(lpszSystemInfo, MAX_PATH+1) ) 
      printf("System directory:  %s\n", lpszSystemInfo); 

   // Get and display the Windows directory. 
 
   if( GetWindowsDirectory(lpszSystemInfo, MAX_PATH+1) )
      printf("Windows directory:  %s\n\n", lpszSystemInfo);
 
   // Display the "environment variables" header. 
 
   printf("Environment variables (partial list): \n"); 
 
   // Expand the OS environment variable.
 
   dwResult = ExpandEnvironmentStrings( 
                 "OS=%OS%",
                 lpszSystemInfo, 
                 BUFSIZE);
   if( dwResult <= BUFSIZE )
      printf("  %s\n", lpszSystemInfo);

 
   // Expand the PATH environment variable. 
 
   dwResult = ExpandEnvironmentStrings( 
                 "PATH=%PATH%", 
                 lpszSystemInfo, 
                 BUFSIZE);
   if( dwResult <= BUFSIZE )
      printf("  %s\n", lpszSystemInfo);
 
   // Expand the TMP environment variable. 
  
   dwResult = ExpandEnvironmentStrings( 
               "TEMP=%TEMP%",
               lpszSystemInfo, 
               BUFSIZE);
   if( dwResult <= BUFSIZE )
      printf("  %s\n", lpszSystemInfo);
}
Re[4]: Узнать имя компа
От: Zibir Чехия www.tigru.org
Дата: 16.03.06 08:42
Оценка:
Здравствуйте, pullover, Вы писали:

P>MSDN:


Спасибо!
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.