|
See following code:
main (....)
{
CString strPath = "*.*";
Trim (strPath);
}
void Trim (CString &strPath)
{
CFileFind Info;
CStdioFile File;
CString strRecord;
BOOL bLoop;
bLoop = Info.FindFile ((LPCTSTR)strPath, 0);
while (bLoop)
{
bLoop = Info.FindNextFile ();
if ( Info.IsDirectory ()
&& !Info.IsDots ())
{
CString strSub;
strSub = Info.GetFilePath ();
strSub += "\\*.*";
Strip (strSub);
}
else if ( !Info.IsDirectory ()
&& !Info.IsHidden ()
&& !Info.IsReadOnly ())
{
printf ("%s\n",(LPCTSTR)Info.GetFilePath ());
if (File.Open ((LPCTSTR)Info.GetFilePath (), CFile::modeReadWrite|CFile::typeBinary, NULL))
{
DWORD dwReadPosition = 0;
DWORD dwWritePosition = 0;
UINT nRecord = 0;
try
{
while (File.ReadString (strRecord))
{
dwReadPosition = File.GetPosition ();
strRecord.TrimRight ();
File.Seek (dwWritePosition, CFile::begin);
File.WriteString ((LPCTSTR)strRecord);
File.WriteString ("\r\n");
dwWritePosition = File.GetPosition ();
File.Seek (dwReadPosition, CFile::begin);
printf ("%d\r",++nRecord);
}
printf ("\n");
}
catch (CFileException *Exception)
{
Exception->Delete ();
fprintf (stderr,"\nError writing to file\n");
File.Close ();
exit (1);
}
File.SetLength (dwWritePosition);
File.Close ();
}
}
}
}
This code example expects you use MFC. If you don't, you will have to use the standard FILE * type of routines.
Good luck.
William
|
|
|
|
|
Can someone tell me how a '+' operation is internally handled by the compiler(if possible with an example). Meaning that if I say 5+10 wat happens internally and how the compiler handles it??
|
|
|
|
|
From what I understand, all a compiler does (MSVC for example) is to convert your source code into machine readable code called ASM. If you google around you can find many examples of this language, which in turn will give you a better idea of what is actually happening behind the scenes.
|
|
|
|
|
waldermort wrote: ...all a compiler does (MSVC for example) is to convert your source code into machine readable code called ASM.
Not quite. Assembly is just another language, although not as high-level as C. What the compiler and linker do is create machine code that matches the instruction set of the processor.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
|
|
|
|
|
On a very low level, you change the current in some transistors so that the resulting transistor combination of open and closed transistors is interpreted as 15 by your computer.
~RaGE();
|
|
|
|
|
this is how VC8.0 handles this:
int a, b, c;
a = 5;
<code>00416C23 mov dword ptr [a],5 </code>
b = 10;
<code>00416C2A mov dword ptr [b],0Ah </code>
c = a + b;
<code>00416C31 mov eax,dword ptr [a]
00416C34 add eax,dword ptr [b]
00416C37 mov dword ptr [c],eax</code>
codito ergo sum
|
|
|
|
|
|
his question was refering to the + sign,
-Prakash
|
|
|
|
|
Regarding these resource files I know it is possible to store just about any type of binary data, but the problem is access. I am trying to include an Excel .xls file into my project. Including this as a plain file is no problem, but when added as a resource I have trouble accessing it. Namely with functions that expect a string pointer.
This xls file is the master template for which my program would copy/fill-in/manipulate. Therefore I would prefer it to be hardcoded into the exe where it would be pretty much impossible to be deleted or edited.
Is there a workaround or a method of conversion?
|
|
|
|
|
If I'm interpreting your situation correctly, you're saying you have an 'integer' identifier (defined in resource.h) for your Excel resource and need to know how to form the 'string' value that can be used to reference it.
To convert that integer value to a 'string' (wink, wink) Microsoft provides the MAKEINTRESOURCE[^] macro.
Is this what you are looking for?
Regards,
Dan
Remember kids, we're trained professionals. Don't try this at home!
|
|
|
|
|
Exactly what I was looking for. Thankyou
|
|
|
|
|
Is this article of any help?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
|
|
|
|
|
Thanks, you answered what would have been my next question :p
|
|
|
|
|
Hi All,
How to write an email application from VC++?
Thanks in advance,
Awating your reply,
- Ramesh.
|
|
|
|
|
What you have to do ?
Do you have to just send the message or anything else.
Cheers
"Peace of mind through Technology"
|
|
|
|
|
If you just need to send an email to a specific address, you can just ShellExecute that email address (similar to how you invoke a url).
ShellExecute(hwnd, "open", "mailto:your.address@domain.com", NULL, NULL, SW_SHOW);
You can even supply a body/subject by crafting the mailto like a Query string (MSDN[^]):
mailto:your.address@domain.com?body="This is the body"&subject="Auto-generated e-mail subject"
If you need more advanced functionality (such as choosing your server), check the forum Q&A FAQ.
|
|
|
|
|
Hi,
I want To Restart A remote Computer Running Server 2003,
Ip,Copmputer Name, Admin UserName And Password Are Known.
It Can Be Done Running Aprogram on Remote that Listens to
TCP/IP Packets carring Cusom Restart Message And Restart
Remote Compter Localy.
But I Search For A Mechanism That Not Required Additional Software On Remote,
Any Idea?
Thanks a lot for Any Assistance.
M.Mehrdad.M
|
|
|
|
|
|
I am a structural engineer and novice programmer. I am working on a project in which I have created 2 views, which can be selected from the menu. These work okay, but now the tool bar and status bar have dissapeared and I don't know how to get them back. Cab anyone help?
taylorlopes
|
|
|
|
|
Hi,
Call RecalcLayout() after switching from one view to other.
Bye,
Cool Ju
Dream Ur Destiny
|
|
|
|
|
Thanks for your suggestion, but I am already calling RecalcLayout(). Any other suggestions?
|
|
|
|
|
hi, im having a problem binding data to a crystal report. but actually i think the problem is caused by ADODB from which i get the data.
The problem is, when there are field names with an underscore,
eg: U_ID
ADO doesnt bind it. I use .csv files as data source and use MS VC++ 6.0.
How do i write the Column headers in the .csv file and the Schema.ini file so that ADO doesnt mind the wildcards?
thnx!
|
|
|
|
|
I'm using access database (.mdb) using ADO classes. Anyone knows how to change comparing of strings in sql case sensitive ? (like select * from t where txt="aA"). I need it to be case sensitive only in some tables.
Thank you !
rrrado
|
|
|
|
|
Im not sure about Access, but if I need a case-sensitive comparison in MySQL, I would add the option "BINARY" to the VARCHAR in question.
Cheers,
Sebastian
--
Contra vim mortem non est medicamen in hortem.
|
|
|
|
|
Thank you now I found another way: StrComp()
rrrado
|
|
|
|