Yes, this is exactly what I was trying to do.. Thanks a lot, all of you :-D
laksh2204
Posts
-
problem in memory allocation for a pointer -
problem in memory allocation for a pointerLike this??? void fun(int* ptr){ ptr = (int*)malloc(sizeof(int)); } int main(){ int ptr; fun(&ptr); ptr = 5; cout<<ptr; } I dont think so.. probably you mean something else.. that i am not getting.
modified on Monday, September 29, 2008 8:40 AM
-
problem in memory allocation for a pointerok then what change is required here. so that i can i can put some value into memory allocated in fun() function.
-
problem in memory allocation for a pointerHi all, I am getting seg fault when trying this piece of code. I'm not getting what is went wrong here. void fun(int* ptr){ ptr = (int*)malloc(sizeof(int)); } int main(){ int *ptr = NULL; fun(ptr); *ptr = 5; //seg fault cout<<*ptr; }
-
Bitmaps on Tabs of TabControlchk this link. http://www.codeproject.com/KB/tabs/XPTabApp.aspx?display=Print[^]
-
diamond problem and virtual inheritanceI have some queries here.. 1. By making the inheritance virtual how the ambiguity is actually resolved? I mean, what this virtual inheritance does internally? Does it create another vptr of another vtable? if it is so how does the new vtable looks like?? 2. And as the diamond problem says that there is an ambiguity that whether D will have path A->B->D or A->C->D A / \ B C \ / D So after removing ambiguity which path is taken?
-
Array Variable initializationI think you are trying to do something like this.. class A{ int TModels[3]; public: A():TModels[1](0){} }; int main(){ A a; } which is giving you above error: As per my knowledge there is no (standard) C++ way of doing this. Array initializers do not exist for classes. So prob you can do it somewhat like this: class A{ int TModels[3]; public: A(){ for(int i=0; i<3; i++) TModels[i] = 0; } }; int main(){ A a; } Hope it helps you
-
who can give me a example in C++ using Factory PatternCheck this link. I hope this will help you. http://www.codeguru.com/forum/showthread.php?t=327982[^]
-
Need help in instantiating abstract classThis is working fine in linux as well But, Did you define the function "baseLinux::bool get()" anywhere? as below: class baseLinux : public Abase { public: virtual bool get(){} } ----- laksh
-
Need your helpI hope this link will help you.... http://datastructures.itgo.com/lists/dynamic/sort.htm[^] However, in c++ you can use stl::list which have its sort function inbuilt. check this... http://msdn.microsoft.com/en-us/library/kz841ss7(VS.71).aspx[^] Laksh
-
Arrayint main(){ char see[3]; see[0] = 's'; see[1] = 'e'; see[2] = 'e'; // or you can do above 3 steps in loop also for (int a=0; a<3; a++) { cout<<"enter a character:"; cin>>see[i]; } for(int i=0; i<3; i++) { cout<<see[i]; } return 0; } Try this and start with any of book suggested by sandip.
-
WaitForSingleObject and SetEventHi Everyone, I have some confusion with WaitForSingleObject. Is it necessary for a thread to be in wait state to handle an event? for example, Thread1 { SetEvent(event); } Thread2{ while(true) { if(WaitForSingleObject(event, INFINITE)){ SetEvent(event); //event raised again, but handler thread 2 is not in wait now } } } Thanks laksh
-
Inhertance Diamond problemOK, thats nice explanation.. one more issue comes into my mind. A / \ B C \ / D In the same diamond structure if my declaration is like: class A; class B : virtual public A; class C : virtual public A; class D : public B, public C; now when i do A *d = new D; //it will work as ambiguity is removed by virtual. But, which path will be followed?? A->B->D or A->C->D?? or something else...
-
Inhertance Diamond problemHi, I have a very famous problem with multiple inheritance here. class A{ public: A(){ cout<<"A"<
-
Function CallingIf you are saying that you have a class and inside that you have a public member function, then you need to create an object of the class at the place where you want to call it. And then using that object you can call the function. You need to include the .h file in which you have created your class. Well this is like targeting in dark.. If you can put the problem in detail. You may get right solution.
-
Can I create a process in Windows service in MFC?I think its not a bad idea in general scenario. But might not be good idea in my scenario. As according to my problem when a particular service is down, the user which is logged in must have a process running which can handle the situation. In this way, that user is required to be logged in permanently. Which for me doesn't seems to be a good idea. In other words, What if no user is logged in and one of those services goes down. No one will be there to handle the situation. However, "Winsta0\default" looks quite different to me. May be like someone who is always there. In this case it should work. I'll try it out. Thanks everyone for your valuable time. This forum is really one of the bests I've ever seen. :)
-
Can I create a process in Windows service in MFC?Actually, I have a service running on Windows Server2003 sp2 called locator. This service keeps a control over another 4 services in the system. If any one of these four is down, I am supposed to run a process say Handler which is yet to be developed. So I was trying with an existing like cmd,calc etc... Now As Mark is saying use CreateProcessAsUser() and lpDesktop, I have a problem that I am new to windows domain. I don't know what should be the value for lpDesktop or for hToken i.e. first parameter of CreateProcessAsUser(). I am getting error 6 INVALID_HANDLE. I think, The discussion stopped due to timezone difference. --Arun
-
Can I create a process in Windows service in MFC?I am trying to do something like this: > STARTUPINFO si; > PROCESS_INFORMATION pi; > BOOL bRes = false; > DWORD dwCode = 0; > ZeroMemory ( &si, sizeof ( STARTUPINFO)); > si.cb = sizeof ( STARTUPINFO); > si.dwFlags = STARTF_USESHOWWINDOW; > si.wShowWindow = SW_SHOWNORMAL; > > bRes = CreateProcess( NULL, > (char *)it->second.c_str(), // some exe > NULL, > NULL, > TRUE, // also tried FALSE > NORMAL_PRIORITY_CLASS, //also tried 0 > NULL, > NULL, > &si, > &pi > ); > DWORD error = GetLastError(); > XERROR1( "ExecuteFailoverCommand :after execution Error=%d", error); > if( bRes == false ) > { > XERROR3( "ExecuteFailoverCommand :Error=%d, Could not invoke process %s > for service %s", error, it->second.c_str(), ServiceName.c_str()); > } > else > { > XTRACE2("ExecuteFailoverCommand : executed command %s on failure of %s > returned %d", it->second.c_str(), ServiceName.c_str(),bRes); > return true; > } This is working fine when I am calling CreateProcess from an exe but same is not working when it is being called from a running service. This may be due to reason that service puts the UI on a different desktop. So, is there any other solution to this problem. thanks in Adv