|
You could always wrap up CString::Replace() in a little program.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Why not just write one in about 20 lines of code?
EX (error checking omitted for brevity):
<br />
int main(int argc, char *argv[])<br />
{<br />
if (argc != 4)<br />
{
printf("Missing Parameters");<br />
exit(1);<br />
}<br />
<br />
FILE *fp = fopen(argv[1],"rb");<br />
if (fp)<br />
{<br />
CString cFileData;<br />
char caBuf[4096];<br />
int iSize = fread(caBuf,1,sizeof(caBuf)-1,fp);<br />
while (iSize > 0)<br />
{<br />
caBuf[iSize] = 0;<br />
cFileData += caBuf;<br />
iSize = fread(caBuf,1,sizeof(caBuf)-1,fp);<br />
}<br />
<br />
fclose(fp);<br />
<br />
cFileData.Replace(argv[2],argv[3]);<br />
<br />
fp = fopen(argv[1],"wb");<br />
if (fp)<br />
{<br />
fwrite((LPCSTR)cFileData,1,cFileData.GetLength(),fp);<br />
fclose(fp);<br />
}<br />
}<br />
<br />
return 0;<br />
}<br />
onwards and upwards...
|
|
|
|
|
Here's one with 10 lines of code:
if (argc < 4) return (1);
CFile file(argv[1], CFile::modeRead);<br />
CString Buffer;<br />
file.Read(Buffer.GetBuffer(file.GetLength()), file.GetLength());<br />
Buffer.ReleaseBuffer(file.GetLength());<br />
file.Close();<br />
Buffer.Replace(argv[2],argv[3]);<br />
file.Open(argv[1], CFile::modeCreate|CFile::modeWrite);<br />
file.Write((LPCTSTR)Buffer, Buffer.GetLength());<br />
file.Close();<br />
Top ten member of C++ Expert Exchange.
http://www.experts-exchange.com/Programming/Programming_Languages/Cplusplus/
|
|
|
|
|
I guess I did straight C for too long....can't get out of fopen/fread mode...:->
onwards and upwards...
|
|
|
|
|
Cool thanks, I think I'll use that. Although I may de-MFCify it to make the app more lightweight.
Joel Holdsworth
"Outlook not so good"
That magic 8-ball knows everything! I'll ask about Exchange Server next
|
|
|
|
|
I don't know what the problem may be, but have you hovered over the IDS_SOMESTRINGID to see what its value is? Also make sure you don't have a resource defined with the same id.
My articles
www.stillwaterexpress.com
BlackDice
|
|
|
|
|
I have a worker thread and need to start and stop a timer.
As I understand there are two ways to do this, using CWnd class and handling OnTimer()or SetTimer(hWnd, ....) API call, but both rely on having a UI to receive WM_TIMER messages. Is this correct?
If yes what is the best way to implement a timer in a worker thread, that does not interact with the UI at all?
|
|
|
|
|
no_reg_name wrote:
sing CWnd class and handling OnTimer()or SetTimer(hWnd, ....) API call, but both rely on having a UI to receive WM_TIMER messages. Is this correct?
Very Much Correct ,No problem using timer in UI
no_reg_name wrote:
what is the best way to implement a timer in a worker thread, that does not interact with the UI at all?
You have to use Sleep api to simulate the Timer in worker thread.
"I Think this Will Help"
<h5
alok="" gupta="" <br=""> visit me at http://www.thisisalok.tk
|
|
|
|
|
Look at CreateWaitableTimer and use WaitForSingleObject or else WaitForMultipleObjects, if you have another event or such to signal your thread to exit or to perform some other work.
Instead of using Sleep() os LeepEx() which will lock up your thread until the sleep has timed out.
|
|
|
|
|
There are two ways to use the SetTimer API. The first is as you said where you specify an HWND that will recieve the WM_TIMER message. The second is to use the CALLBACK function that you specify in the fourth parameter of the SetTimer() function. See SetTimer[^] and TimerProc[^] in MSDN for more info.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
I guess you can type faster than me.... Beat me by two seconds...
onwards and upwards...
|
|
|
|
|
basementman wrote:
I guess you can type faster than me
Yeah, my two fingers do move pretty fast
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
You do not have to have a window to create a timer. You can create a timer if you supply NULL for the hWnd and supply a callback proc.
onwards and upwards...
|
|
|
|
|
Is there a simple way to disable only the menubar ( and toolbar ) of the main frame of an MDI application ? while keeping a couple of them available ( like "quit" ).
I have an operation that, when run, needs to diable some operations, while keeping the different views active.
I could have ON_UPDATE_COMMAND_UI handlers for all menu commands that will check a state variable, but that will mean a lot of code change, but on the other hand it's failsafe.
Thanks.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Maximilien wrote:
ON_UPDATE_COMMAND_UI handlers for all menu commands
That's the recommended approach. I don't think this will require a lot of code changes. Code addition maybe, but no modifications.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Have a look at ON_UPDATE_COMMAND_UI_RANGE. This will allow you to create a single function to handle enabling/disabling of an entire range of IDs.
onwards and upwards...
|
|
|
|
|
This needs to have a sequentially continuous ID range; which is something I cannot be sure of.
I will go with the other suggestion, add one ON_UPDATE_COMMAND_UI for each menu item; luckilly, all my commands are in a couple files.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
if any one can help me to obtain any vc++ project.
pleeeeeeeeeeeese
Anas_zet
|
|
|
|
|
don't know if I should laugh or cry ...
What exactly do you want ?
Can't you create your own ? Can't you download any of Code Project samples and examples ? or any of Microsoft samples ?
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
thank you for you'r praise,
i know that but i didn't understand the code of these project's, it's hard to understand.
in abstraction i want som simple & good project
Anas_zet
|
|
|
|
|
Help me,
To any one read this thread if can help me to obtain any any VC++ project for my matter.
pleeeeeeez
Anas_zet
|
|
|
|
|
for my matter
whats ur matter?
|
|
|
|
|
|
I'm writing a utility which uses files which reside on a network drive. In order for the application to run correctly the first time, the user must (outside of my application) open up the network drive in Windows Explorer to authenticate.
In my application, if the user is not authenticated, fopen(), etc just returns false citing improper access or whatever. Is there a way I can force windows to display the authenticate dialog before failing at fopen()?
Its a standard win32 app...
Thanks.
Mike.
doner at obtain.com
|
|
|
|
|
While I've not ever tried it in this context, do NetShareAdd() , CreateProcessAsUser() , or NetUseAdd() help?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|