|
No, because that GetFileTitle() returns a CString. You'll need to save the return value to a CString and call GetBuffer() on that string to get a non-const pointer to the filename.
--Mike--
"COM didn't solve the old version of DLL hell - it just provided us with a new and improved version of hell."
-- John Simmons, 1/22/2002
My really out-of-date homepage
Sonork - 100.10414 AcidHelm
Big fan of Alyson Hannigan.
|
|
|
|
|
Wowsers... didn't read the spec completely. What the hell type of function modifies a string buffer in place?
I suppose the GetBuffer() would be safe since PathRemoveExtension() shouldn't try to expand the string at all.
CFile f("c:\program files\microsnot\wankitywank.txt", CFile::modeRead);
CString strTitle = f.GetFileTitle();
PathRemoveExtension(strTitle.GetBuffer(0));
strTitle.ReleaseBuffer();
Except, now I need to link in shlwapi.lib... I'm going back to my ReverseFind('.')...
Thanks though.
J
|
|
|
|
|
If you're using the code snippet above, be aware that it will break if the filename is something like "C:\abc\foo.1\bar" You need to find the last dot and last backslash, and make sure the dot is after the backslash before truncating at the dot.
--Mike--
"COM didn't solve the old version of DLL hell - it just provided us with a new and improved version of hell."
-- John Simmons, 1/22/2002
My really out-of-date homepage
Sonork - 100.10414 AcidHelm
Big fan of Alyson Hannigan.
|
|
|
|
|
I'm in need of a program or class that will check a remote website for new versions of the program files, and update them if needed (check against the timestamps?).
This is so generic, I cannot believe that it hasn't been implemented already.
Thanks in advance.
Jim
|
|
|
|
|
How do I display an animated gif on a dialog box.
Help needed !
|
|
|
|
|
|
How do I break out of my main processing loop(OnOk)when the user selects the Cancel button. I was thinking along the lines that I should use:
MSG message; // declared out side the loop
for ( int t=0; t< mpData.GetSize(); t++ ) {
if (::PeekMessage(&message, NULL, 0, 0, PM_REMOVE)){
::TranslateMessage(&message);
::DispatchMessage(&message);
}
}
This does not seem to work. When I omit this piece of code and user hits Cancel, the program just runs until completed.
Any suggestions on how to remedy?
CD
|
|
|
|
|
In Cancel button message handler set Cancel flag to TRUE. In your loop check this flag value after you processing messages. If it is TRUE, break out of loop.
|
|
|
|
|
I do windows programming both using WinMain approach and MFC approach.
If we use WinMain approach, the window is created using CreateWindow() function and we have to register window class etc etc. However, I don't want a window created by CreateWindow() function. I want to make custom window for example that of sonork messenger. I got the source code of sonork and it is complex enough to understand. Can you tell me a source or a book from where I can learn the step-by-step approach of making custom windows ???
Zia Khan
|
|
|
|
|
Err, unless I'm completely mistaken, ALL windows are created with the CreateWindow() function. I don't think there's another way. Even MFC uses it.
There are several books around on plain Win32 programming, but they might not be in print anymore. Try an Amazon search for "Win32".
J
|
|
|
|
|
Hi,
Is there anyway to monitor an already opened serial port's activity?
Any help would be highly appreciated,
Cheers,
Mehdi
|
|
|
|
|
Hmmm, I would propose to write a kind of driver which grabs the data flow between the application and the rs232-driver.
There are many ways to do that. If you are not really in writing win32 drivers try api-hooking. That means you have to do a kind of overwriting functions used to handle the serial port like CreateFile(), ReadFile(), WriteFile() and so on.
If you did the application doesn`t really call the functions from user32.dll or whatever but yours, keep the data and then call the original functions from system dlls and no one will worry.
Take a look at "Programming Applications for MS Windows" by Jeffrey Richter - you will find some chapters about api-hooking, dll injecting and things like that.
So far ...
CU Mario ///
---------------------------------
www.klangwerker.de
Look out for free Win32
Serial Communication Module
for VC++ or Borland C++ Builder
---------------------------------
|
|
|
|
|
This link could maybe get you started?
Click here
Cheers,
/Fredrik
Sonork ID: 100.11430:PhatBoy
|
|
|
|
|
Hi,
I´m running Ms Word embedded, and I need to resize and move the Word window to make it fit in a place but...
I have a problem, when Word starts by default maximized there is no way to resize it ( even shows an error message telling that the window is maximized...), I have Tried this code:
m_app.CreateDispatch("Word.Application")
oDocs = m_app.GetDocuments();
oDoc = oDocs.Add(vOpt, vOpt, vOpt, vOpt);
(...)
m_app.Activate();
oDoc.Activate();
m_app.SetWindowState(wdWindowStateNormal);
m_app.SetLeft(93);
m_app.Resize(677, (szScreen.cy - 30));
But it shows the fu... message..., Thanks in advance
Braulio
|
|
|
|
|
Hello Braulio, that Word Automation thing must be a real pain in the ass. I know close to nothing about the subject, but from the similar code I've seen on the net, maybe you should try calling WindowState(wdWindowStateNormal) on oDoc before doing the same with m_app . If what I'm saying is absolute nonsense, please accept my apologies
Good luck!
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hola Joaquin !, Gracias por la info !
The thing was to call activate and SetWindowState before any SetTop or Left or... ( and... sh*t I forgot a SetTop(0)... in the code somewhere... ).
But anyway Automation and Office thing is a real pain in the ass... we are having a lot of problems here with that ( it´s a nightmare when you try to run the same things with 97 or 2000, and for some stuff... it´s like... well Word do what you want....).
Thanks again and Seeya !
Braulio
|
|
|
|
|
can anyone give some advice how to debug a service running on win2k. i tried this thing adding a debugger value to the registry key
"Image File Execution Option"
but i didn`t get it to run in the debugger at all.
What is the value I have to add to this key if I want to use the VC++ Debugger ?
CU Mario ///
---------------------------------
www.klangwerker.de
Look out for free Win32
Serial Communication Module
for VC++ or Borland C++ Builder
---------------------------------
|
|
|
|
|
When I want to step into a service, I use the task manager. Select the service .exe and click Debug from the context menu.
Hope this helps,
Bill
|
|
|
|
|
Does realloc free memory if it fails?
according to msdn HeapReAlloc does not free memory and the original pointer/handle are still valid.
char* pTemp = (char*)realloc(m_pMem, 100); }
testing the function with either try/catch or NULL return to indicate a failure, would the following be acceptable?
m_pMem = pTemp;
I'm assuming this works with HeapReAlloc() but i can't find anything that says realloc does the same...?
TIA
"An expert is someone who has made all the mistakes in thier field" - Niels Bohr
|
|
|
|
|
as i remember, realloc stamps on your pointer if it fails, so yeh i used to do something like
//orig mem
pMem=malloc(42);
...
//need more?
pTry=realloc(pMem,142);
if (pTry)
{
pMem=pTry;
}
else
{
MessageBox(0,"no more mem, but i'll bash on regardless",0,0);
// but pMem is still valid (unless instead of 142 you sent zero!)
}
|
|
|
|
|
the temp return is working i just wanted to know if maybe i was seeing things and if it's really acceptable.
But if you've done it and it worked and it's working for, then i guess it must work.
None of the examples i've seen show testing the return of realloc/HeapReAlloc so i dunno what i'm suppose to think.
if anything they all
if(!ret) AfxMessageBox(" ")
not exactly the direction i want
Thanx again! and for the speedy response
"An expert is someone who has made all the mistakes in thier field" - Niels Bohr
|
|
|
|
|
realloc returns a void pointer to the reallocated (and possibly moved) memory block. The return value is NULL if the size is zero and the buffer argument is not NULL, or if there is not enough available memory to expand the block to the given size. In the first case, the original block is freed. In the second, the original block is unchanged.
Philip Patrick
"Two beer or not two beer?" (Shakesbeer)
Web-site: www.saintopatrick.com
|
|
|
|
|
So realloc could be used as a substitute for free..? I did not know that...cool
So it is acceptable to do what i was doing and Brandy has suggested is possible...?
store the return in a temp and copy the temp to the original if successful...?
Thanx again
"An expert is someone who has made all the mistakes in thier field" - Niels Bohr
|
|
|
|
|
Yup What is Brandy wrote is right.
But don't understand why to use ralloc to free the memory? lol
And HeapReAlloc() is called inside realloc()
Philip Patrick
"Two beer or not two beer?" (Shakesbeer)
Web-site: www.saintopatrick.com
|
|
|
|
|
hi guys,
i am trying to load the data of a file which is 100MB large in to a List Control. But during the loading Procedure the app does not respond anymore. If i use i a file which is not so large, it works fine. How can i solve the prob ?
I am using CStdioFile
Best Regards
Sonu
|
|
|
|