|
This is hopefully a basic question but it's been a VERY long time since I used C++ and I just need to know how I can get a file extension from a path and compare to constant extension.
I have an input:
LPCWSTR pwszPath
and a constant:
WCHAR MY_EXT[4] = L".me";
I need to know if pwszPath ends with MY_EXT but I can't think how to do it..
Any help would be great!
|
|
|
|
|
__DanC__ wrote: I need to know if pwszPath ends with MY_EXT but I can't think how to do it..
Use PathFindExtension .
Matching extension will somewhat look like this...
bool MatchExtension( LPCTSTR lpctszMyPath, LPCTSTR lpctszChkExt )
{
ASSERT( lpctszMyPath && lpctszChkExt );
LPCTSTR lpctszExt = PathFindExtension( lpctszMyPath );
return ( lpctszExt && _tcscmpi( lpctszExt + 1, lpctszChkExt ) == 0 );
}
Nibu babu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
modified on Wednesday, July 2, 2008 5:06 AM
|
|
|
|
|
That was exactly what I was looking for! Thanks!
|
|
|
|
|
__DanC__ wrote: That was exactly what I was looking for! Thanks!
I've modified my reply a bit.
Nibu babu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
|
|
|
|
|
What about PathFindExtension [^]?
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
too late buddy
|
|
|
|
|
Indeed: bits flow very slowly from Italy this morning .
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
|
Quote:
bits flow very slowly from Italy this morning
Bits? or Thoughts? :P
Regards.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
Rating helpfull answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
I don't know (maybe bits of thougths? ).
BTW apparently the same happens from Germany...;P (this thread is a bit dated)
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Yeah, I am having quite things to do and less time to do them, I am a bit away from keyboard
Regards.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
Rating helpfull answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
I am working on an existing application in VC 6.0 MFC, there are a few call in the application, which takes a very long time, I am working on placing some progress indication (play avi)on the status bar. Since there are many calls in the applicaion which takes very long, I thought of createing a thread for playing AVI file on the status bar. And the first statement of the time consuming funcions will be call to the progress indication thread. ( I dont want to place the time consuming funcion itself in thread, since there are many, I am looking for a simple solution)
Please comment advantage and disadvantage in following this method, and also suggest/advice me some good approch in doing so
|
|
|
|
|
ptr_Electron wrote: Please comment advantage and disadvantage in following this method, and also suggest/advice me some good approch in doing so
I've seen some well known applications like word, excel, powerpoint ,while printing and saving, take this approach. So should be good enough.
If it's just a random animation then you can maybe call Play else you will have to manually change each frame(Seek ) to indicate correct progress.
Here[^] is a sample on how to embed a progress bar in a statusbar. You can easily change the progress bar to CAnimateCtrl . Make sure you handle OnSize to move the animate control based on new parent window's size.
Another way is to sub class CStatusBar and embed these features.
Nibu babu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
modified on Wednesday, July 2, 2008 5:12 AM
|
|
|
|
|
Oh ok thank you very much for responce. I will take a look @ the link.
|
|
|
|
|
|
|
Okay I just saw your other question and if you are using C++\CLI then you have to install .Net framework on user's computer.
-Saurabh
|
|
|
|
|
Hello guys, this is my first post ok so here is my problem/question I would like it so when a user enters a URL into a text box and then hits the go button that it will open the URL in the default browser, here is what i got
private: System::Void GO_Click(System::Object^ sender, System::EventArgs^ e)
{
int GetWindowText(HWND urlgo,LPTSTR textout,int nMaxCount);
System::Diagnostics::Process::Start(/*start the url entered*/);
}
Oh and here is the Text box
private: System::Void urlgo_TextChanged(System::Object^ sender, System::EventArgs^ e)
{
}
any help would be much appreciated Thanks, Brock
|
|
|
|
|
|
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You/xml>
|
|
|
|
|
Hi,
Use the following statement in your code :
ShellExecute(NULL, "open", url, NULL, NULL, SW_SHOWNORMAL);
Good Luck..
|
|
|
|
|
I get error C2664: 'ShellExecuteW' : cannot convert parameter 2 from 'const char [5]' to 'LPCWSTR'
|
|
|
|
|
Might be its happening due to ur unmanaged code...
|
|
|
|
|
That's a Unicode problem. It's expecting "wide" chars. Try this: L"open"
|
|
|
|
|
Hello
Can Anybody suggest me that how to use this SaferGetLevelInformation Function to get the information about policy level......
Thankx!!!!
|
|
|
|