|
Soren, thanks for your help.
Here is the read code.
I did add \n after the comma to the write text.
The file as around 230 bytes, ten string entries (sample "WS2EEE,\n") and even with the iReadBytes set to 250 it get only the first string with comma attached.
I am also having some problems with using Seek to next "record", but I can work on that later.
I was hoping to read the entire file and than process it , but I'll try the CStdioFile and read one line instead.
char pbuf[1000];
UINT nBytesRead;
UINT iRunningTotal = 0;
CString strField, strExcluded;
int iReadBytes = 250;
do
{
nBytesRead = pFile->Read( pbuf, iReadBytes );
TRACE("\nBuffer %s", pbuf);
// extract to delimiting comma
strField = pbuf; // kluge need to learn how to use CString buffer
strExcluded = strField .SpanExcluding( ";,.- :");
int iLenght = strExcluded.GetLength();
iReadBytes = iLenght + 2;
pFile->Seek(iLenght +1 ,CFile::current);
iRunningTotal += nBytesRead;
}while ( iRunningTotal < dwFileLength);
|
|
|
|
|
Change your loop to:
CString strLine;
while (file.ReadString(strLine))
{
}
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
Sorry for the delay Vaclav, it has been one of those days.
I think you should do this with CStdioFile and get the text parsing all straightened out first. Follow David's advice for the read loop.
If you still want to do some testing with your current code, you need to clean up some things. You say you hope to read the whole file in and then process it. Well, then that is what you should do instead of doing both reading and processing in the loop.
I will recommend you use a CByteArray for the read buffer (I like its flexibility). Use CFile to check the size of the file, call SetSize() on the CByteArray object with that value, read the file in a single call (for now let's just assume your files will not be too large for that) and close the file. Then you use the loop to go through the buffer without doing anymore file handling.
Soren Madsen
"When you don't know what you're doing it's best to do it quickly" - Jase #DuckDynasty
|
|
|
|
|
Does anyone know a documented way to retrieve the command line of another process?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
documented ? by whom ?? - good luck
I know of no 100% foolproof way - the one way I do know of, is itself dangerous and uses CreateRemoteThread() (yes, its c++), and injects code into the running process.
The last time I needed to do this, I ended up writing a stub program with the same name of the exe I was trying to figure out (because the 3rd party involved themselves didnt know the some parameters they were passing into it dynamically, it was legacy code) - so my stub simply dumped the parameters to a log file - at least I had enough access to the system to be able to replace their exe temporarily
please let us know if you find something Richard
'g'
|
|
|
|
|
Thanks for your answer. I was afraid of that.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
|
See if this helps.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
That's a big help, thanks.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
What I am up to is resizing the bitmap from the clipboard then re send it to clipborad so it's kinda easy in VB take a look
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
My.Computer.Clipboard.SetImage(New Bitmap(bmp, CInt(bmp.Width / 2), CInt(bmp.Height / 2)))
End Sub
No how to do this under C?
So i can send the bitmap to the clipboard with these instructions
OpenClipboard(NULL);
EmptyClipboard();
SetClipboardData(CF_BITMAP, Hbitmap);
CloseClipboard();
OpenClipboard(NULL);
and for bringing it
HBITMAP hbitmap = (HBITMAP)getclipboardData(CF_BITMAP)
and i know that I should use
StretchBlt() but i do not know how to accomplice that?
|
|
|
|
|
Assume you have a HBITMAP hbitmap which already contains your clipboard data. Then you can StretchBlt that data to a destination HDC hdc as below:
1. Create a compatible HDC in memory with your destination hdc
HDC memDC= CreateCompatibleDC(hdc);
2. Select your hbitmap into the memory DC
HBITMAP hOldBmp = (HBITMAP)SelectObject(memDC, hbitmap);
3. Use StretchBlt to resize it
StretchBlt(hdc, 0, 0, new_Width, new_Height, memDC, 0, 0, org_Width, org_Height, SRCCOPY);
4. Restore the old bitmap and free memory
SelectObject(memDC, hOldBmp);
DeleteDC(memDC);
Hope it helps
|
|
|
|
|
Thanks it helped me
|
|
|
|
|
You may use the CopyImage()[^] function:
BITMAP bm;
GetObject(hBitmap, sizeof(bm), &bm);
HBITMAP hCopy = (HBITMAP)CopyImage(hBitmap, IMAGE_BITMAP,
bm.bmWidth / 2, bm.bmHeight / 2,
LR_COPYDELETEORG);
SetClipboardData(CF_BITMAP, hCopy);
|
|
|
|
|
Thanks I did not know that!
gonna check that out
|
|
|
|
|
Can you guys pl explain me how to call (Syntax) a single query directly through visual studio C++ code and stored Procedures (syntax for multiple queries)? What is the difference between them in calling?
|
|
|
|
|
hi all,
I want to read a excel file on pc where Office is not installed.
any idea how can I do this.
thanks.
|
|
|
|
|
You can use OLE DB[^].
Use the best guess
|
|
|
|
|
is oledb register on all pc.
I search on using excel and find this
http://exceldatareader.codeplex.com/[^]
they provide a dll.
but here example shows use in c# and vb.net how can I use it.
modified 29-Jun-13 6:29am.
|
|
|
|
|
Unfortunately it is not easy, as all the samples I have seen relate to C#/VB.NET. You could use C++/CLI to access the data and then hand it back to your unmanaged code. There are also some articles here on CodeProject[^] that may help you.
Use the best guess
|
|
|
|
|
Hi,I want to parse a csv file using Regex,It contains
1.string Contains "",for example,"It's a "word"" ;
2.string Conatains \r\n
|
|
|
|
|
I would start choosing the right forum.
Veni, vidi, vici.
|
|
|
|
|
What? I can not understand,sorry
|
|
|
|
|
This is the C/C++/MFC forum, while you asked about C# .
As a side note, a quick Google search gave me about 830,000 results[^].
Veni, vidi, vici.
|
|
|
|
|
You can google for that.
Also, if it matters, a parser is probably faster than a regex.
|
|
|
|
|
you can post it at the c# forum
moonman
|
|
|
|