Discussion:
mempcpy and uname
(too old to reply)
Rayne
2009-12-04 07:51:24 UTC
Permalink
Hi all,

I would like to know if there are Windows-equivalent functions for
mempcpy() and uname(). I'm using VS .NET 2003.

Thank you.
David Lowndes
2009-12-04 09:50:38 UTC
Permalink
Post by Rayne
I would like to know if there are Windows-equivalent functions for
mempcpy() and uname(). I'm using VS .NET 2003.
memcpy is a standard 'C' run-time function. Which parts returned by
uname are you interested in? There are Windows APIs such as
GetComputerName.

Dave
Giovanni Dicanio
2009-12-04 16:29:53 UTC
Permalink
Post by David Lowndes
Post by Rayne
I would like to know if there are Windows-equivalent functions for
mempcpy() and uname(). I'm using VS .NET 2003.
memcpy is a standard 'C' run-time function.
The OP asked for mem*p*cpy.

Giovanni
David Lowndes
2009-12-04 16:56:20 UTC
Permalink
Post by Giovanni Dicanio
Post by David Lowndes
Post by Rayne
I would like to know if there are Windows-equivalent functions for
mempcpy() and uname(). I'm using VS .NET 2003.
memcpy is a standard 'C' run-time function.
The OP asked for mem*p*cpy.
Missed that!

Given the description of it:

"The mempcpy() function is nearly identical to the memcpy() function.
It copies n bytes from the object beginning at src into the object
pointed to by dest. But instead of returning the value of dest it
returns a pointer to the byte following the last written byte"

It's only different if the return value is used, and can presumably be
simulated with something like:

static_cast<BYTE*>(memcpy( pDest, pSrc, Num )) + Num;

Dave
Rayne
2009-12-07 07:43:41 UTC
Permalink
Post by David Lowndes
Post by Rayne
I would like to know if there are Windows-equivalent functions for
mempcpy() and uname(). I'm using VS .NET 2003.
memcpy is a standard 'C' run-time function. Which parts returned by
uname are you interested in? There are Windows APIs such as
GetComputerName.
Dave
Thanks. I think GetComputerNameEx with ComputerNameDnsHostname is most
suitable. But I can't use the function. 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.

How do I get GetComputerNameEx to work?
Giovanni Dicanio
2009-12-07 08:06:53 UTC
Permalink
Post by Rayne
status = GetComputerNameEx(ComputerNameDnsHostname, buf, &dwSize);
and I get the errors
error C2065: 'ComputerNameDnsHostname': undeclared identifier
Did you define 'ComputerNameDnsHostname' in any place?
Post by Rayne
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
Giovanni Dicanio
2009-12-07 09:23:10 UTC
Permalink
Post by Giovanni Dicanio
Post by Rayne
error C2065: 'ComputerNameDnsHostname': undeclared identifier
Did you define 'ComputerNameDnsHostname' in any place?
Sorry: I read that it is a predefined enum value.

Giovanni
Ulrich Eckhardt
2009-12-07 08:12:22 UTC
Permalink
Post by Rayne
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
David Lowndes
2009-12-07 08:12:37 UTC
Permalink
Post by Rayne
...
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
Rayne
2009-12-07 08:34:42 UTC
Permalink
Post by David Lowndes
Post by Rayne
...
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
"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.
Rayne
2009-12-07 08:45:55 UTC
Permalink
Post by Rayne
Post by David Lowndes
Post by Rayne
...
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
"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!
Ulrich Eckhardt
2009-12-07 08:46:23 UTC
Permalink
Post by Rayne
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"
Not sure about the syntax. In any case, it would be better to add it in the
preprocessor settings of the project. BTW: which VS are you using? If the
SDK shipped with it are too old (I guess those shipped with VS98 are) then
they wouldn't even contain those declarations conditionally.

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

Sator Laser GmbH
Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932
Rayne
2009-12-07 09:19:42 UTC
Permalink
Post by Ulrich Eckhardt
Post by Rayne
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"
Not sure about the syntax. In any case, it would be better to add it in the
preprocessor settings of the project. BTW: which VS are you using? If the
SDK shipped with it are too old (I guess those shipped with VS98 are) then
they wouldn't even contain those declarations conditionally.
Uli
--
C++ FAQ:http://parashift.com/c++-faq-lite
Sator Laser GmbH
Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932
I'm using VS .NET 2003
David Lowndes
2009-12-07 10:51:55 UTC
Permalink
Post by Rayne
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"
You can add preprocessor definitions under the preprocessor options.
You need to use:

_WIN32_WINNT=0x0500

Dave
Igor Tandetnik
2009-12-07 12:45:45 UTC
Permalink
Post by Rayne
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"
The syntax is /D_WIN32_WINNT=0x0500. Or, you could enter _WIN32_WINNT=0x0500 under Properties | C/C++ | Preprocessor | Preprocessor Definitions
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not necessarily a good idea. It is hard to be sure where they are going to land, and it could be dangerous sitting under them as they fly overhead. -- RFC 1925
Loading...