|
How could I convert a BSTR value to an enum value in a COM class???
|
|
|
|
|
switch/case?
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
Does not work on strings in C++, the switch statement will compare the pointers. This might work if you're using static strings (and the string pooling flags are set) but won't on user-supplied strings.
If you need to do string comparisons in C/C++, you have to use a multi-armed if statement with something like strcmp .
DoEvents : Generating unexpected recursion since 1991
|
|
|
|
|
A BSTR is still a pointer to an array of wide characters, so you can still pass it to any string manipulation function. If it contains string representation of an integer you can pass it to swscanf or _wtoi .
If it contains the name of the enumeration value, you're out of luck. Those aren't compiled into the program. You'll have to manually write code to handle this using string comparisons.
DoEvents : Generating unexpected recursion since 1991
|
|
|
|
|
Hello Friends,
Is it possible to delete the file which I am running from within the File??
Means the code for deleting the File should reside in the File Itself Which I want to delete.
I know in a Simple manner it will provide Access Violation Error.
please tell me if you have any Idea,
|
|
|
|
|
It is available in codeguru.com, just find it out.
Suggestion to the members:
prefix your main thread subject with [SOLVED] if it is solved.
chandu.
|
|
|
|
|
Yes but he is on CodeProject NOT Codeguru.
WPF - Imagineers Wanted
Follow your nose using DoubleAnimationUsingPath
|
|
|
|
|
thats why i redeirected him to the codeguru.com.
i dont think it is wrong, because, all of us here are open minded, and should also encourage the other programming sites.
am i right or not?
Suggestion to the members:
prefix your main thread subject with [SOLVED] if it is solved.
chandu.
|
|
|
|
|
chandu004 wrote: am i right or not?
yes, but not CodeGuru !!!
moreover, when you answer like that, take the time yourself to provide the link, or don't answer at all, because it's useless (I mean, yes, the OP should have searched at first, so you don't bring something new then)
BTW, your Signature is a bit too aggressive. you should consider reduce its size and/or add a separator because most of the time, it looks like it's part of the body of your answer
|
|
|
|
|
toxcct wrote: yes, but not CodeGuru !!!
iam sorry if it has hurt the ego of any body.
toxcct wrote: take the time yourself to provide the link,
yah you are right i would have done that. but now only i came to know that, quoting the competor site, would be inconvinient to some people.
toxcct wrote: BTW, your Signature is a bit too aggressive. you should consider reduce its size and/or add a separator because most of the time, it looks like it's part of the body of your answer
thanks for the advice, i shall do the same.
Suggestion to the members:
prefix your main thread subject with [SOLVED] if it is solved.
chandu.
|
|
|
|
|
norm .net wrote: Yes but he is on CodeProject NOT Codeguru.
Well said.;)
|
|
|
|
|
|
I know, strange advice being handed out by the newbie
WPF - Imagineers Wanted
Follow your nose using DoubleAnimationUsingPath
|
|
|
|
|
|
It will be better if you provide the Link also. Or some keywords to find the thing.
|
|
|
|
|
self deleting an application
or
"an application that deletes itself."
Suggestion to the members:
prefix your main thread subject with [SOLVED] if it is solved.
chandu.
|
|
|
|
|
Hey Thnx,
Got the link. Coming back to you after Checking.
|
|
|
|
|
Now I am using the MoveFileEx Function to delete the File at reboot. as Follows
GetModuleFileName(0,FileName,MAX_PATH);
if ( ! MoveFileEx(FileName,NULL,MOVEFILE_DELAY_UNTIL_REBOOT ) )
dError = GetLastError() ;
PostQuitMessage(0);
But the Problem is that it is Not supported in Windows 95/98/Me. MSDN has provided the solution for that also. And trying to implement it
|
|
|
|
|
Use a .bat file. It will work on all version of Windows.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
|
Notice that if you put:
del %0.bat
in a batch file and run it from a command prompt, it will remove itself. You can take advantage of this by creating a similar batch file from within the program you are wanting to delete:
:DoItAgain
del MyProg.exe
if exist MyProg.exe goto DoItAgain
rem del folder that MyProg.exe was in
del %0.bat Use CreateProcess() to run the batch file. Note that I've not actually tested this so you may have to tweak it for your situation (e.g., add paths, hide console window).
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Now I am Creating the batch File at run time and Its working fine.
|
|
|
|
|
GetModuleFileName(0,FileName,MAX_PATH);
char strFileName[MAX_PATH]= {} ;
int a = WideCharToMultiByte(CP_ACP,0,FileName,-1,strFileName,MAX_PATH,NULL,NULL);
FILE *fwin = fopen("Uninstall.bat","w+");
fprintf(fwin,"@echo off \n");
fprintf(fwin,":back \n");
fprintf(fwin,"del \"%s\"\n",strFileName);
fprintf(fwin,"if exist \"%s\" goto back: \n ",strFileName);
char Buffer[]= "%0.bat";
fprintf(fwin,"del %s \n",Buffer);
OpenProc(L"Uninstall.bat");
-- modified at 3:11 Tuesday 16th October, 2007
|
|
|
|
|
GauranG33 wrote: char Buffer[]= "%0.bat";
Use an absolute path for this. What you have now is relative to whatever the CWD happens to be at the moment.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I Need help to set unicode string in menu and dialogs in nonunicode program by enable Os Settings. Expecting any articles are suggestions.
thanks in advance!
Have A Nice Day!
Murali.M
|
|
|
|