|
charu123 wrote:
NIC Address:
IP Address:
To get the MAC address, use GetAdaptersInfo() . To get the IP address, use gethostname() followed by gethostbyname() .
charu123 wrote:
Browser Information:
Since more than one browser can be present, this question cannot be answered directly. One approach would be to call FindExecutable() with the name of some .html file. Then query that executable using GetFileVersionInfo() and VerQueryValue() .
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Hi
I am having some problem...
please see this code and tell me whr I am going wrong.
LPTSTR lptstrFilename;<br />
char buffer[BUF]="C:\\Program Files\\Internet Explorer\\iexplore.exe";<br />
lptstrFilename = (char *) malloc( sizeof(BUF) );<br />
strcpy(lptstrFilename,buffer);<br />
DWORD dwHandle=NULL;<br />
DWORD lpdwHandle= -1;<br />
DWORD dwLen=0;<br />
void *lpData;<br />
<br />
dwLen= GetFileVersionInfoSize(lptstrFilename,&lpdwHandle);<br />
lpData = malloc(dwLen);<br />
DWORD dwError = GetLastError();<br />
BOOL bRet = GetFileVersionInfo(lptstrFilename,NULL,dwLen,&lpData);<br />
PUINT lplpBuffer;<br />
PUINT puLen;<br />
<br />
VerQueryValue(lpData, <br />
TEXT("\\VarFileInfo\\Translation"), <br />
&lpBuffer, <br />
&dwBytes);<br />
I am getting an error when i reach the VerQueryValue.
Can u please point out the mistake.
U get wht u Give
|
|
|
|
|
|
I am not able to implement GetAdaptersInfo becoz it is not recognizing some header files.
Is there any other way i can implement it.
Probably read from some file etc.
Can u tell me how to get CPU speed.
Thanks
U get wht u Give
|
|
|
|
|
charu123 wrote:
I am not able to implement GetAdaptersInfo becoz it is not recognizing some header files.
This makes no sense. Functions do not have the ability or capacity to recognize anything compiler-related. Perhaps you meant that the compiler is unable to locate a particular header file.
charu123 wrote:
Can u tell me how to get CPU speed.
There are several ways of doing this, some better than others.
Here is a Delphi example (it's a trivial exercise to convert to C). You can also look in the registry at HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0. I'ved used the following before:
unsigned __int64 start, stop;
unsigned __int64 nCtr, nFreq, nCtrStop;
QueryPerformanceFrequency((LARGE_INTEGER *) &nFreq);
_asm _emit 0x0F
_asm _emit 0x31
_asm mov DWORD PTR start, eax
_asm mov DWORD PTR [start + 4], edx
QueryPerformanceCounter((LARGE_INTEGER *) &nCtrStop);
nCtrStop += nFreq;
do
{
QueryPerformanceCounter((LARGE_INTEGER *) &nCtr);
} while (nCtr < nCtrStop);
_asm _emit 0x0F
_asm _emit 0x31
_asm mov DWORD PTR stop, eax
_asm mov DWORD PTR [stop + 4], edx
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
I am getting an error sayin
The data area passed to a system call is too small.
theSIZE i have declared is 5000.
please tell m ewhr i am going wrong in this code snippet.
char DevName[100];
sprintf(DevName,"%s",(LPCTSTR)dlg.GetDeviceName());
HANDLE phPrinter=NULL;
DWORD dwBytesNeeded;
PRINTER_INFO_2 *pst;
BYTE pPrinter;
DWORD sizeReq=SIZE;
OpenPrinter(DevName,&phPrinter,NULL);
GetPrinter(phPrinter, 2, &pPrinter, sizeReq, &dwBytesNeeded);
pst=(PRINTER_INFO_2 *)malloc(dwBytesNeeded);
char j[SIZE];
sprintf(j,"%l",pst->AveragePPM);
U get wht u Give
|
|
|
|
|
hi david,
I ma getting the following error
" the instruction at a memory location reference memory at <location>. the memory could not be written."
Could u point out where I am going wrong.
<br />
char b[1000],a[1000],file[1000]="trial.html";<br />
char path[1000]="C:\\Documents and Settings\\bhoomika.WIPHP_DOMAIN\\Desktop";<br />
LPTSTR data;<br />
data=(char*)malloc(1000);<br />
VS_FIXEDFILEINFO *pFileInfo;<br />
UINT BufLen;<br />
FindExecutable(file,path,data);<br />
DWORD dwHandle, dwLen;<br />
dwLen = GetFileVersionInfoSize (data, &dwHandle);<br />
LPTSTR lpData;<br />
lpData=(char*)malloc(sizeof(BUF));<br />
if (!GetFileVersionInfo (data, dwHandle, dwLen, lpData)) {<br />
free (lpData);<br />
lpData = NULL;<br />
AfxMessageBox ("VersionInfo: not found\n");<br />
<br />
}<br />
<br />
if (!VerQueryValue(lpData,"\\",(LPVOID*) &pFileInfo,(PUINT) &BufLen)) {<br />
printf ("VersionInfo: not found\n");<br />
}<br />
else <br />
{<br />
sprintf (a,"MajorVersion: %d", HIWORD(pFileInfo->dwProductVersionMS));<br />
m_ctrlBrowser.SetWindowText(a);<br />
sprintf (b,"MinorVersion: %d\n",LOWORD(pFileInfo->wProductVersionMS));<br />
}<br />
<br />
<br />
free(data);<br />
return TRUE; <br />
Thanks For all the help.
U get wht u Give
|
|
|
|
|
charu123 wrote:
lpData=(char*)malloc(sizeof(BUF));
I think this should be lpData=(char*)malloc(dwLen).
charu123 wrote:
sprintf (b,"MinorVersion: %d\n",LOWORD(pFileInfo->wProductVersionMS));
The compiler should have complained about this one as wProductVersionMS is not a valid member name.
Other than that, and the lack of error checking, what you have should work. You do, however, seem to be confused as to when to use MFC and when not to. Unless there is no MFC equivalent for some Win32 function, it really makes no sense to mix the two.
Here is a modified version of your code:
VS_FIXEDFILEINFO *pFileInfo;
LPCTSTR pszFile = "trial.html",
pszPath = "C:\\Documents and Settings\\bhoomika.WIPHP_DOMAIN\\Desktop";
CString strExecutable,
strResult;
DWORD dwHandle,
dwVerSize;
LPBYTE pBuffer;
UINT uBufLen;
FindExecutable(pszFile, pszPath, strExecutable.GetBuffer(_MAX_PATH));
strExecutable.ReleaseBuffer();
dwVerSize = GetFileVersionInfoSize(strExecutable, &dwHandle);
if (dwVerSize > 0)
{
pBuffer = new BYTE[dwVerSize];
if (NULL != pBuffer)
{
if (GetFileVersionInfo(strExecutable, dwHandle, dwVerSize, pBuffer) != FALSE)
{
if (VerQueryValue(pBuffer, "\\", (LPVOID *) &pFileInfo, &uBufLen) != FALSE)
{
strResult.Format("MajorVersion: %u\nMinorVersion: %u",
HIWORD(pFileInfo->dwProductVersionMS),
LOWORD(pFileInfo->dwProductVersionMS));
}
else
strResult.Format("VerQueryValue() failed. Error = %lu", GetLastError());
}
else
strResult.Format("GetFileVersionInfo() failed. Error = %lu", GetLastError());
delete [] pBuffer;
}
}
else
strResult.Format("GetFileVersionInfoSize() failed. Error = %lu", GetLastError());
AfxMessageBox(strResult);
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
i am new to the exceptions world, while i have been coding for a while in c++ and MFC but never used exceptions in my Production code been using return values primarily for error detection
now i want to use exceptions but i got confused as to which flavor is the best there are lots of __try and TRY and try out there which one should i use and some link to the docs would be much appreciated
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
|
|
|
|
|
TRY /CATCH are obsolete MFC constructs that were invented before C++ exceptions were standardized. Don't use them in new code.
__try marks the beginning of a SEH (structured exception handling) block. It matches up with an __except or __finally block. Limited use in C++ because __try can't exist in a scope that requires stack unwinding.
try /catch are used for handling C++ exceptions.
IMAO* I advise you to stick with error codes, exceptions are immensely harder to use correctly.
*In My Arrogant Opinion
--Mike--
Visual C++ MVP
LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ
Strange things are afoot at the U+004B U+20DD
|
|
|
|
|
Michael Dunn wrote:
IMAO* I advise you to stick with error codes, exceptions are immensely harder to use correctly.
Now all the fellow programmers will look down on me
i just want to do something when a function in my constructor fails any ideas
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
|
|
|
|
|
It depends for what !
Sometimes exceptions are much much more easy to use and reduce your code. For example if in one function you need to do a lot of operations (by calling the same function everytime), instead of each time looking for return value, you just encapsulate this in a try/catch block...
Also it's nice when you have a lot of classes 'nestled' (I mean a class that uses a class, that uses a class, ....) and you just need to know in the first class that an error occured in the 'last' class, then you don't need to check for error return at each function called. You just put a try/catch statement in the first class and that's it
|
|
|
|
|
hummm, it reminds me a conversation that took place on that forum yesterday...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
I really don't see what you are talking about
|
|
|
|
|
|
Just because it is modern doesn't mean it is good. There is still a HUGE debate over exceptions. In my life, we have tried to use exceptions many times but found that they just don't scale very well. We are producing much higher quality software without exceptions than we ever did with exceptions.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Tim Smith wrote:
Just because it is modern doesn't mean it is good.
That's true. But in general modern C++ is superior to older C++. I'd still go for exceptions over error codes. However, some languages, e.g., Eiffel, have a different and arguably a superior take on exceptions than say C# and Java.
Kevin
|
|
|
|
|
Hi,
As we know, we can write a COM object with VB6, which can be refered in C#
.NET project. My question is, can I do so with VC6, other than VB6?
In VB6, it is easy to create a COM object: Wizard->ActiveX DLL.
But how to do this in VC6?
I created a DLL in VC6: MFC AppWizard -> Regular DLL with MFC static..(with
Automation checked). I refered it in my C# .NET prj, BUT any classes of it
can NOT be seen. Why?
Thank you in advance.
Dave
|
|
|
|
|
|
Thanks. It is a good idea.
|
|
|
|
|
Is is possible to give an XP look to programs written for win 2000 through manifesting?
|
|
|
|
|
|
|
Salam...
I am making a splitter in my drawing SDI. I want that anything that i draw in one pane should also be drawn in other pane. I am using the same view class. But it does not draw in the other pane. If any one could help me in this regard. I am pasting the code in OnClientCreate(...) function.
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
CRect rect;
GetClientRect(&rect);
m_splitter.CreateStatic(this,1,2);
m_splitter.CreateView(0,0,RUNTIME_CLASS
(CMyPaintBrushView),CSize(rect.Width()/2,rect.Height ()),pContext);
m_splitter.CreateView(0,1,RUNTIME_CLASS (CMyPaintBrushView),CSize(rect.Width()/2,rect.Height()),pContext);
return TRUE;
}
|
|
|
|
|
Hello all
I am working on internationalization of an application and tried using some of the functions that I could see as relevant in this context:
1)IsValidLocale() returns always true, with my 2nd argument being LCID_INSTALLED
2)Tried also using the pair EnumUILanguages() and the associated callback required, BUT could not find anywhere an example of what this call back should have inside it….
Any help will be appreciated
Thanks
Alex
|
|
|
|
|