|
Hi all
I've resolved it! Basically, a toolbar button ID won't appear in the Events list. All you need to do is have, for example, an ID accelerator and then give the button the same ID.
David
|
|
|
|
|
Hello friends,
I have created my own NT Service, it works fine in Win 2000 and WinXP.
In Vista,Its register in ServiceManager and showing in the services list but unable to run after PC boots.
The reason might be UAC in Vista.
Please tell me the way that I can run my service in Vista successfully.
If possible please provide some source achieve it.
abhi
|
|
|
|
|
You should run your service in a Service User Account[^]
that has the permissions it needs to run the service.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hello everyone,
In the following multiple inheritance sample code, I have tested in class Derived, there are two __vfptr, pointing to the virtual function table for Foo and Goo repectively -- i.e. 8 bytes, 2 pointer on 32-bit machine.
My questions,
1. Why two __vfptr is needed? Why not just one?
2. class Derived has its own virtual method func2, why it does not have its own virtual function table pointer?
class Foo {
public:
virtual int func() {return 1;};
};
class Goo {
public:
virtual int func() {return 2;};
};
class Derived: Foo, Goo {
public:
virtual int func2() {return 3;};
int increase() {return -1;};
int decrease() {return -2;};
};
int main()
{
Derived d;
int size;
size = sizeof (d);
return 0;
}
thanks in advance,
George
|
|
|
|
|
Well this is realy a question on how the compiler designers decided how the compiler should lay out the code, and why. The answer takes a Lazy chair, a glass of wine and a cigar, but there we go.
When the Ancestors of both Foo and Goo were written, No one was aware (at least conceptually) that at a later date someone might want to combine both in a single multiple inherrited decendant. So, the compiler has to lay out the code inrespect of both Foo and Goo in the conventional way, i.e. with the __vtable pointer at the head of the class. with multiple inheritance, we include a copy of each base class in the decendant. The Casting operator is implemented at compile time, so (Foo*)(&Derived) effectively returns a Pointer to the 'Foo' part of the Derrived class. As as stated before the Ancestors of Foo are unaware of the Derived Class, they would expect the __vtable to be at the head of what the cast points at. And of course, the same would apply to Goo. To combine the two __vtable's into one sounds like a good idea, BUT:
The ancestral code for Foo and Goo may well reside in a library to which there is no access when 'Derived' is compiled. The solution with the two __vtable pointers leaves the problem of calling the correct virtual function at the place where it belongs, namely there where the Derived Multiple Inheritance is compiled into code. In a nutshell I cannot see a way of combining the two vtables, without also having to recompile ancestrial code.
Hope this explains it clearly (sort of)
Regards,
Bram van Kampen
|
|
|
|
|
Thanks Bram van Kampen,
I agree with your theory, but it does not cover one of my confusions, which is, where is class Derived's own __vfptr (points to its own virtual methods)? From debugging, I can not find it out by adding a new method in Derived which is not in Foo and Goo. Like, we add a new virtual method called func_derived.
virtual int func_derived() {return 4;}
regards,
George
|
|
|
|
|
I need to write my version of code similar to CString::Empty() function for char*. Is it enough if i just free the memory of the string to implement the function. How do i empty the string otherwise?
Thanks in advance
|
|
|
|
|
If you are talking C or working directly with C style string in C++, then you do not need a function.
char* pData = (char*)malloc(size of data required);
if( pData )
free(pData);
pData = NULL;
if( pData )
else
You do not really need a function, unless you are designing your own sting class.
Good Luck!
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
gReaen wrote: Is it enough if i just free the memory of the string to implement the function. How do i empty the string otherwise?
Yes and No!
After you free it you must NEVER again refer to that section of memory. The way I usually do it is:
char* p=(char*)malloc(size);...... free(p); p=NULL;
At least you get a definite runtime error if you try to do something with p after freeing, instead of an obscure runtime bug.
Bram van Kampen
|
|
|
|
|
Actually if you designed your string as a class then you don't even need to free memory, you can just mark the string as empty: this way avoiding memory deallocation/rellaocation if there is chance the string will be used again.
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.
[my articles]
|
|
|
|
|
i want to hide / show menubar on an command click.
my application is an mfc mdi app.
i tried using setmenu(null) to hide and then loadmenu again to show.
but his has a problem that the maximize/ minimize/close buttons of the child disappears once u show back the menu. also when the document is closed and opened again, i get two sets of maximize/minimize/close buttons one set of which is unusable.
can anyone guide me on this how to show / hide ?
thanks
|
|
|
|
|
I am drawing some thing on picture box . Now I need to save the
Bitmap image of picture box how can I do it. can I use another control
for it .
Trioum
|
|
|
|
|
Do you want to save to a file?
|
|
|
|
|
yes want to save in file , and also use some another module
Trioum
|
|
|
|
|
You can use of CImage class like this
CImage m;
m.Attach(hbitmap);
m.save("c:\\1.jpg");
|
|
|
|
|
I have 3 different applications that generate similar data. This data is grouped into different categories. I would like to have an option so that the user can export this data HTML or XML format. Also, for each format (HTML or XML) the user should be allowed to choose which data categories to export. For example, in HTML, the user may select certain optios. In XML, the user may choose other options. I decided to create 2 property pages each with the same options (check boxes): one for xml and one for html. When displayed on a propertysheet, both look identical (as expected).
I implemented this on one of the 3 applications and it works fine. But as I started to implement this on the second application, I noticed that i had to recreate the property page dialogs and classes (each property page dialog includes about 40 controls). If I continue this way, I will be duplicating a lot of code.
Can the property page dialogs (resources) and classes be placed in a central location where they can be used (referenced) by any number of applications without having to duplicate the code in each app?
LA
|
|
|
|
|
You can always create a resource DLL, you can find articles on the internat about that.
Also you can use two projects in the same workspace and one of the projects can have the fnctionality you want to share, the most interesting way to proceed would be the DLL as in that case you can change the DLL without having to rebuild everything and you can get an upgrade...
Hope this helps.
|
|
|
|
|
Thanks for the info. However, one more question: Do I need to worry about my resource ID's in the DLL to make sure they are not the same as other resources used in the application that uses the DLL?
LA
|
|
|
|
|
|
I know how to get it with commands "netsh ipsec static show all"
but i don't know how to get the settings with c++ or windows API
X|X|X|X|
|
|
|
|
|
As part of a Licencing Setup Program, I create Exe File immages on a remote Target drive, and try to execute.
Which of all the flavours of the various api's to do this will cause the code to execute on the target machine. (I am looking for a CPU Id. Sofar I'm getting the CPU Id from the Machine I launched from.)
More Precisely, the Code I inject on the remote machine intends to find the Hardware Serial Number of the Drive, and would do so if it ran on That machine. I find every time that it finds quite successfully the hardware serial number of My Own Drive, meaning that my invocation made it run om My Machine. I Well understand that there are security issues attached to this. However, it is assumed that I have full administrator level access to All Machines involved. (I tested it on my own LAN with the above results).
Bram van Kampen
|
|
|
|
|
I am using some code to develop an Autoplay handler based on this application note.
http://msdn2.microsoft.com/en-us/library/bb776827.aspx
As described in this article, I would want to enable or disable the Autoplay feature by using code like this .
<br />
typedef HRESULT (*CREATEHARDWAREEVENTMONIKER)(REFCLSID clsid, LPCWSTR pszEventHandler, IMoniker **ppmoniker);<br />
<br />
HRESULT RegisterComponent(IUnknown* punk, DWORD* dpwToken)<br />
{<br />
HRESULT hr = E_FAIL;<br />
HINSTANCE hinstShSvcs = LoadLibrary(TEXT("shsvcs.dll"));<br />
<br />
if (hinstShSvcs)<br />
{ <br />
CREATEHARDWAREEVENTMONIKER fct = (CREATEHARDWAREEVENTMONIKER)GetProcAddress(hinstShSvcs, "CreateHardwareEventMoniker");<br />
if (fct)<br />
{<br />
IMoniker* pmoniker;<br />
<br />
<big>hr = fct(CLSID_App, TEXT("VideoCameraArrival"), &pmoniker);</big><br />
<br />
if (SUCCEEDED(hr))<br />
{<br />
IRunningObjectTable *prot;<br />
<br />
if (SUCCEEDED(GetRunningObjectTable(0, &prot)))<br />
{<br />
hr = prot->Register(ROTFLAGS_ALLOWANYCLIENT | ROTFLAGS_REGISTRATIONKEEPSALIVE, punk, pmoniker, &_dwRegisterROT);<br />
prot->Release();<br />
}<br />
pmoniker->Release();<br />
}<br />
CoRegisterClassObject(CLSID_App, static_cast<IClassFactory *>(this), CLSCTX_LOCAL_SERVER, REGCLS_MULTIPLEUSE, &_dwRegisterClass;<br />
}<br />
FreeLibrary(hinstShSvcs);<br />
}<br />
return hr;<br />
}<br />
<br />
However I find that there is an exception occuring in this line
hr = fct(CLSID_App, TEXT("VideoCameraArrival"), &pmoniker);
The exception is as follows :
Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.
I am debugging this on Visual Studio 2005 and have no clue as to why this is happenning .
help is appreciated .
Engineering is the effort !
|
|
|
|
|
I am reading c plus plus primer 4th edition in 10 chapter,there are a example TextQuery.I wanted to realizd it.I build a project TextQuery,and added TextQuery.cpp,TextQuery.h and querymain.cpp which were supplied by the book.I compiled ,there was no error.But I run it ,it showed "No input file!".That means the file of Alice_stroy was not read.I want to know how to get the correct answer.
|
|
|
|
|
While someone here may have the book, I bet many of us do not...
You may get more help if you show some code or explain what the code does.
Does this "Alice_stroy" exist? If not, does it need to? If it exists, is it
in the folder the app expects it to be?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
jianfengshxy wrote: I want to know how to get the correct answer.
You probably need to supply the correct path along with the file.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|