From: Giovanni Dicanio on
"Rayne" <lancer6238(a)yahoo.com> ha scritto nel messaggio
news:af42ffe1-c33b-4732-bf5a-9d5eb7a7338a(a)m7g2000prd.googlegroups.com...

> status = GetComputerNameEx(ComputerNameDnsHostname, buf, &dwSize);
>
> and I get the errors
>
> error C2065: 'ComputerNameDnsHostname': undeclared identifier

Did you define 'ComputerNameDnsHostname' in any place?


> How do I get GetComputerNameEx to work?

I would suggest you reading the documentation (and sample code) available on
MSDN:

http://msdn.microsoft.com/en-us/library/ms724301.aspx


Giovanni



From: David Lowndes on
>...
>and I get the errors
>
>error C2065: 'ComputerNameDnsHostname': undeclared identifier
>error C3861: 'GetComputerNameEx': identifier not found, even with
>argument-dependent lookup

In the remarks section of the documentation on GetComputerNameEx it
says:

"To compile an application that uses this function, define the
_WIN32_WINNT macro as 0x0500 or later. For more information, see Using
the Windows Headers.
"

Have you done that?

Dave
From: Ulrich Eckhardt on
Rayne wrote:
> I have
>
> status = GetComputerNameEx(ComputerNameDnsHostname, buf, &dwSize);
>
> and I get the errors
>
> error C2065: 'ComputerNameDnsHostname': undeclared identifier
> error C3861: 'GetComputerNameEx': identifier not found, even with
> argument-dependent lookup
>
> I have #include <windows.h>, and using GetComputerName(buf, &dwSize);
> does not give me any errors.

I haven't checked, but here's what I would do:
Look up the docs at msdn.microsoft.com. There, near the bottom, you will see
which OS version is required, which header file to include and which
library to link.

I guess the header and library are nothing new to you, but the OS version
probably is. This OS version must be defined using the _WIN32_WINNT macro
and similar ones. This must happen _BEFORE_ including the headers, best
define it consistently for all source files. It causes your program not to
run on earlier versions of the OS, since that version doesn't support the
API.

Uli

--
C++ FAQ: http://parashift.com/c++-faq-lite

Sator Laser GmbH
Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932
From: Rayne on
On Dec 7, 4:12 pm, David Lowndes <Dav...(a)example.invalid> wrote:
> >...
> >and I get the errors
>
> >error C2065: 'ComputerNameDnsHostname': undeclared identifier
> >error C3861: 'GetComputerNameEx': identifier not found, even with
> >argument-dependent lookup
>
> In the remarks section of the documentation on GetComputerNameEx it
> says:
>
> "To compile an application that uses this function, define the
> _WIN32_WINNT macro as 0x0500 or later. For more information, see Using
> the Windows Headers.
> "
>
> Have you done that?
>
> Dave

I'm new to VS. I've tried to do this by going to Project -> Properties
-> Configuration Properties -> C/C++ -> Command Line. Under Additional
Options, I added /D "_WIN32_WINNT 0x0500"

But I still get the errors.
From: Rayne on
On Dec 7, 4:34 pm, Rayne <lancer6...(a)yahoo.com> wrote:
> On Dec 7, 4:12 pm, David Lowndes <Dav...(a)example.invalid> wrote:
>
>
>
> > >...
> > >and I get the errors
>
> > >error C2065: 'ComputerNameDnsHostname': undeclared identifier
> > >error C3861: 'GetComputerNameEx': identifier not found, even with
> > >argument-dependent lookup
>
> > In the remarks section of the documentation on GetComputerNameEx it
> > says:
>
> > "To compile an application that uses this function, define the
> > _WIN32_WINNT macro as 0x0500 or later. For more information, see Using
> > the Windows Headers.
> > "
>
> > Have you done that?
>
> > Dave
>
> I'm new to VS. I've tried to do this by going to Project -> Properties
> -> Configuration Properties -> C/C++ -> Command Line. Under Additional
> Options, I added /D "_WIN32_WINNT 0x0500"
>
> But I still get the errors.

I decided to just add #define _WIN32_WINNT 0x0500 to my header file
and the errors are gone. But I would still like to know if using /D
can achieve the same goal.

Thanks!