|
|
hon can i get motherbord id and vedio card id and when i can find them
am
|
|
|
|
|
ss2006 wrote: hon can i get motherbord id and vedio card id and when i can find them
try WMI[^]
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Hi All,
I have some queries to you people. It would be of great help if someone gives me answers for them.
1. what is the difference betn, structures in C++ and class in C++
2. what is the difference betn. structures in C and structures in C++
3. what is basically a mutable member
4. how do i call a C function from a C++ program. Do I need to use any keywordexplicitly?
Thanks In Advance
|
|
|
|
|
Subramaniam s.V. wrote: what is the difference betn, structures in C++ and class in C++
a structure in C++ IS a class, which default members are set to public instead of private .
Subramaniam s.V. wrote: what is the difference betn. structures in C and structures in C++
a structure in C is only a declaration of several types disposed contiguously, encapsulated within a name. in C++, a structure is a class, which mean that it can have all the classes enhancements, like member functions, constructors/Destructors, etc...
Subramaniam s.V. wrote: what is basically a mutable member
according to the MSDN[^], a mutable member can be modified by any function that can access it, even if the function is declared as const (a function declared as const is normally not allowed to change the class members).
Subramaniam s.V. wrote: how do i call a C function from a C++ program
you mean, withing the same project ?
just as you would have done in a C program...
TOXCCT >>> GEII power [toxcct][VisualCalc 2.24][3.0 soon...]
|
|
|
|
|
First this is a school question.
1) The difference is that a C++ class defaults to private and a structure defaults to public.
2) In C there are no member functions; a structure is just a set of data. That is it represents the equivalent of a record.
3) You are learning! A mutable member is a variable that can be changed at any time. You see there are member variables that may need to be changed, while giving the impression that nothing has changed, from the user point of view.
4) All I can say is YES, depending on the compiler and what you specify in your code.
INTP
Every thing is relative...
|
|
|
|
|
Is there an easy way to check available memory before / after using *p = new int[ ] ? I tried CMemoryState, without success.
|
|
|
|
|
I am not sure if there is a single function call that can give an answer to your question. This would have been a simple question before the advent of virtual memory, but that is no longer the case. If you want to know the physical memory available then you may have to experitment, but that limits you to the machine you are on. Write your programm in such a way that it can compensate for the lack of phisycal memory, or can inform the user if it can not.
I am just saying that we no longer know the amount of memery available and you have to make sure that if it is not, your progam catches that problem before it crashes some bodies machine.
INTP
Every thing is relative...
|
|
|
|
|
Thanks John, it´s clear that new returns 0 if allocation failed. I´m just looking for a way of checking available memory before and after such operations. Due to the dynamic memory model in windows it may be impossible to get exact required data. Purpose is not implemeting it in a commercial application but memory usage demonstration to students. In DOS times ( a century ago ) we had a similar function.
|
|
|
|
|
Have a look at the GlobalMemoryStatus() function.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
I doubt it, since freed memory does not automatically go right back to the pool of available memory. Windows' memory manager is a very complex beast.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
pls give the code for getting Ip address of the computer using VC++
|
|
|
|
|
There are lots of examples here on CP about this topic, but here is some quick code:
WSADATA data;<br />
WSAStartup(MAKEWORD(2,2),&data);<br />
char szHostname[256];<br />
if (gethostname(szHostname, sizeof(szHostname)))<br />
{<br />
WSAGetLastError());<br />
}<br />
HOSTENT* pHostEnt = gethostbyname(szHostname);<br />
if (pHostEnt == NULL)<br />
{<br />
WSAGetLastError());<br />
}<br />
if (pHostEnt->h_length != 4)<br />
{<br />
}<br />
int nAdapter = 0;<br />
in_addr address;<br />
CopyMemory(&address.S_un.S_addr, pHostEnt->h_addr_list[nAdapter], pHostEnt->h_length);<br />
dwIP = MAKEIPADDRESS(address.S_un.S_un_b.s_b4, address.S_un.S_un_b.s_b3, address.S_un.S_un_b.s_b2, address.S_un.S_un_b.s_b1);
Now the address is in dwIP as a DWORD also.
Also available through the:
address.S_un.S_un_b.s_b1<br />
address.S_un.S_un_b.s_b2<br />
address.S_un.S_un_b.s_b3<br />
address.S_un.S_un_b.s_b4
as individual unsigned bytes.
this is this.
|
|
|
|
|
go thru this one.
char szHostName[128];
if( gethostname(szHostName, 128) == 0 )
{
// Get host adresses
struct hostent * pHost;
int i;
pHost = gethostbyname(szHostName);
for( i = 0; pHost!= NULL && pHost->h_addr_list[i]!= NULL; i++ )
{
CString str;
int j;
for( j = 0; j < pHost->h_length; j++ )
{
CString addr;
if( j > 0 )
str += ".";
addr.Format("%u", (unsigned int)((unsigned
char*)pHost->h_addr_list[i])[j]);
str += addr;
}
// str now contains one local IP address - do whatever you want to do with it (probably add it to a list)
}
}
viveks
|
|
|
|
|
mailsafe wrote: pls give the code for getting Ip address of the computer using VC++
Just a ?, Why you need IP address of a computer!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Using App wizard i chose to create a MDI application. In such cases when we run the program the MDI will run first. But i want to insert a dialog eg a login dialog such that when we run the project the dialog should be displayed first. And on the button(which is placed in the dialog)-click, the MDI interface should open up. pls give a solution
-- modified at 4:43 Wednesday 1st March, 2006
|
|
|
|
|
So what have you done till now? Where are you doing this?
Nibu thomas
Software Developer
|
|
|
|
|
Hi,
I am trying to use an RTP code (.lib) i downloaded from the net. When I try to use the same code as a Win32 DLL the compiler doesnot identify the ntohl and other such functions in the Winsock2.h header. I can do without the socket calls as I have to use the RTP in a C# code and I can use sockets in C#, but ntohl etc. must be used.
Can some one tell me what could be the problem and how it can be fixed?.
I have tried searching the net and came across managed and unmanaged dll's etc. But I cannot even understand what they mean by it, bcoz I am creating (and using) DLL for the first time.
Thanks
castratroi
|
|
|
|
|
I have some code that was generating compile errors. I have found the solution to fix the problem, I'm just not 100% sure I understand what the problem actually is. The (much simplified)code below should help explain the issue. I have created a decendant object from ABC that contains the implementation of function FOO
<br />
<br />
<br />
class ABC<br />
{<br />
public:<br />
virtual void FOO(BAR& foo);<br />
};<br />
<br />
<br />
class ABC<br />
{<br />
public:<br />
virtual void FOO(BAR& foo) = 0;<br />
};<br />
My question is this,
What does the "= 0" indicate?
Why is it needed?
When I die I'd like to go peacefully in my sleep like my father, not screaming in terror like his passengers!!!
|
|
|
|
|
I think I have found the answer,
The "= 0" is to indicate to the c(++) compiler that this function is purely virtual and there is no implementation in the base class, which therefore cannot be instantiated directly (which is what I intended). Is this correct?
When I die I'd like to go peacefully in my sleep like my father, not screaming in terror like his passengers!!!
|
|
|
|
|
Exact but it doesn't correspond to your error (because it was the other way: it worked if you add this '=0' and not if you retrieve it).
|
|
|
|
|
First, it is always usefull to add the exact error message when you got one. We cannot guess what the error message is (and in general they are really helpfull).
Now, to answer your question, the =0 means that this is a pure virtual function, that is a function that NEED to be redefined in the child classes. If you don't redefine them in child classes and if you try to instantiate your object, you will get an erro telling you that it cannot instantiate the class due to pure vitual function.
But in your example, I don't see why you get an unresolved external error if you don't add this =0. Maybe try to post more code and the exact error message.
|
|
|
|
|
lastgen wrote: What does the "= 0" indicate?
This means FOO is a pure virtual function, implementation for which will be provided in a derived class of the class ABC .
ABC cannot be instantiated directly. But derived classes for ABC which provide an implementation for FOO can be instantiated.
Nibu thomas
Software Developer
|
|
|
|
|
I am making an assumption that you did not define the function in the original class and that the second version worked. If you had defined the function (or method) in the first class you would not have had an error. Your could have simply declared it as this virtual void FOO (BAR& foo) {}; and there would not have been an error, you would have just had a function that did not do anything.
The second version declares a pure virtual function, which needs to be implemented by a derived class. That is you inherited the interface from the defined base class (ABC) and must provide a function for the inherited interface. What that means is in the base class you have said this function must exit in the derived class, because it does not actually exist in the base class.
Let’s try this,
If you declare a function in a class the compiler will complain if that function does not exist. Therefore you must define the function so any one using that class will have that function to call. If you make the function as a pure virtual function, then the class is designed as a base interface class that is not intended to be used by its self, but is intended to be used as a base for derived classes.
I know I sound like some text book, but I have been doing this a long time. Look up the words “pure virtual” and “virtual base class” along with “C++” on the Web; you should come up with a few decryptions. Amongst those may be instrument and car, all cars have things in common like press the accelerator, press the brake, and ect… . The base class specifies all things that classes derived from it have in common and forces all derived classes to implement those behaviors.
Think of the “= 0” as a requirement that you impose on all users of the class that you have defined.
I hope that helps,
John R. Shaw
INTP
Every thing is relative...
|
|
|
|
|
What is the difference between unions and structures .
Yaaqub
|
|
|
|