|
hi, i am trying to retrieve domain and user name by the following code
#include "windows.h"
LPTSTR lpszSystemInfo;
DWORD cchBuff = BUFSIZE;
TCHAR tchBuffer[bufsize];
lpszSystemInfo = tchBuffer;
if( GetComputerName(lpszSystemInfo, &cchBuff) )
m_machineName = _bstr_t(lpszSystemInfo);
cchBuff = BUFSIZE;
if (GetComputerNameEx(ComputerNameDnsDomain, lpszSystemInfo, &cchBuff))
m_domain = _bstr_t(lpszSystemInfo);
cchBuff = BUFSIZE;
if( GetUserName(lpszSystemInfo, &cchBuff) )
m_osUsername = _bstr_t(lpszSystemInfo);
This is a part of the code.
When i compile it, I get the following error:
error C2065: 'GetComputerNameEx' : undeclared identifier
error C2065: 'ComputerNameDnsDomain' : undeclared identifier
Can anyone help me solve it?
Moonis
-- modified at 21:39 Sunday 3rd June, 2007
|
|
|
|
|
Please put any code inside < pre>< /pre> tag to view it correctly.
Before including <windows.h> you should define _WIN32_WINNT greater than or equal to 0x500;
#define _WIN32_WINNT 0x0500
#include <windows.h>
--
=====
Arman
|
|
|
|
|
Hi,
I did the above settings to enable the macro but the problem still persists. My modified code is here:
#define _WIN32_WINNT 0x0500
#include "windows.h"
#include "stdio.h"
#include "iostream.h"
#include "tchar.h"
int main()
{
LPTSTR lpszSystemInfo;
DWORD cchBuff=sizeof(lpszSystemInfo);
if (GetComputerNameEx(ComputerNameDnsDomain, lpszSystemInfo, &cchBuff))
cout<<"Domain Name is : "<<cchBuff<<endl;
char acUserName[100];
DWORD nUserName = sizeof(acUserName);
if (GetUserName(acUserName, &nUserName)) {
cout << "User name is " << acUserName << "." << endl;
}
else {
cerr << "Failed to lookup user name, error code " <<
GetLastError() << "." << endl;
}
return 0;
}
I am new to VC++ programming so please point out any other errors if there are.
Moonis
|
|
|
|
|
Which version of platform SDK are you using?If not download the latest platform SDK from the microsoft site.
|
|
|
|
|
Hi,
I am using MS Visual C++ 6.0 running on Windows 2000 Server.
Is the problem related to the above version that i am running?
Moonis
|
|
|
|
|
declaration of this file dosent come with the vc 6. You neeed to download the latest platform SDK
|
|
|
|
|
You have to define the _WIN32_WINNT version to 0x0500 or greater. for this Take
project settings->c++->Preprocessor definition.
In that edit box add _WIN32_WINNT=0x0500
|
|
|
|
|
Hi,
In the msdn documentation for GetComputerNameEx it is given
"To compile an application that uses this function, define the _WIN32_WINNT macro as 0x0500 or later"
have to confirmed it and it required to include windows.h
|
|
|
|
|
hai,
i want to create a dll that loads bitmap.i am a beginner to a dll.anyone please help me. i read http://www.codeproject.com/vbscript/LoadBMPFromDLL.asp".
but they are not giving the vc++ code part .Any please give any basic idea
|
|
|
|
|
What's giving you trouble - loading a bitmap or creating a DLL?
Loading a bitmap is the same in a DLL as in an EXE.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
But why you want to load bitmaps of a dll?
|
|
|
|
|
I am running five instances of an exe simultaneously. will there be any memory sharing or memory over writings. Suppose i have a strcuture in the code . when i am running five instances will the memory allocated for that structure will be different for each instance? i am not not using "new" operator. i am just taking an object for the structure.
ex:
struct sample{
CString name;
};
sample s;
Anil Jillella
|
|
|
|
|
anilkrupakar wrote: I am running five instances of an exe simultaneously. will there be any memory sharing or memory over writings.
No.
anilkrupakar wrote: Suppose i have a strcuture i the code . when i am running five instances will memory allocated for that structure will be different?
Yes.
You have to explicitely handle shared memory if you need it.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Hi all,
Is there a way to allow only a specified program to load a dll.
For example: There is a dll called "test.dll" and I don't want other programs loading it except "test.exe". Is there a way to check the caller in dll main function and denide access if the caller is not authorized.
thanks.
Arun
|
|
|
|
|
Hi Toxcct,
toxcct wrote: that's stupid...
You're not playing well with others in the sandbox...
I've received the same sort of answers before (from PhD's no less). It made no sense because there was no context of the problem domain. What do you know of the OP's problem domain or project requirements? I did not see it in the original post.
Perhaps the OP has developed an RSA Integer Factorization algorithm he wants to use in his work only: the first being his RSA modulous generation program (to test that n = p * q ), and a second to factor other's moduli. In this case he may not want to share the functionality - for example, the NSA[^] has threatened him with bodily harm.
Finally, what if the DLL is actually a resource of custom graphics or messages...
Jeff
|
|
|
|
|
Hi,
I am not sure whether we can deny access to dll using system control.
But you can do that in your way.
For instance if your dll export a function
CYourDllClass *CreateInstance();
and the object it returns is needed for further processing.
you can do this
CYourDllClass *CreateInstance(yourSecurityKey)
{
if (Authorised(yourSecurityKey))
{
return new CYourDllClass();
}
else
{
return NULL;
}
}
Best Regards
-- modified at 6:42 Friday 1st June, 2007
|
|
|
|
|
|
|
No problem BusaBird. Apparently, others did not think so highly of the response - I received two 1.0's. Ouch!
Perhaps one of the poster's who I criticized for the content of their message has taken revenge. Oh well.
Jeff
|
|
|
|
|
|
do you have any other error before this one ?
moreover, what compiler do you use exactly ?
|
|
|
|
|
|
then, as CPallini suggested, haven't youremoved a #include <windows.h> directive in your stdafx.h header ?
|
|
|
|
|
|
Your test code compiles fine on my system (VS 2003).
Have you involuntarily modified any standard header file?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|