|
or do i need to do some assembly programmin gto achieve that?
Thanks
|
|
|
|
|
Read on http://codeguru.earthweb.com/system/ReadSector.html
Papa
Murex Co
|
|
|
|
|
Hi,
do you know some MFC or Win32 function that could help to determine whether the given file is text or binary?
Thanks
R.
|
|
|
|
|
A text file and a binary file are the same... what exactly do you mean by binary and text?
|
|
|
|
|
i have to find some info (words, sentences) in files on the local disk which is meaningless eg for pictures, and executables.
That why I wanna to check beforhand whether it is meaningful to search for my data.
|
|
|
|
|
hmm, you could search for null, i don't think there's null in normal text files.
|
|
|
|
|
yeh, but that is not a life insurance.
However your answer implies that there is no such function. That means I have to find another solution like extension checking
Thanx
R.
|
|
|
|
|
there IS no way of telling if a given file is so called 'text' or so called 'binary', therefor you have to guess it.
|
|
|
|
|
You could open in binary mode and read a block, then test for certain characteristics. ASCII doesn't use any bytes larger than 127, and lines are terminated with CRLF. Finding a block of perhaps 1 KB that contains no bytes >127 would be a strong indication that the file is probably text.
Let's Put The Fun Back In Dysfunctional! - My Darts Team T-shirt
|
|
|
|
|
I think you're on your own.
Suggestions:
1) Open the file and read first 1-2K and check for ASCII < 20 and ASCII > 127. (By far the simplest.)
2) Open the file and read first 1-2K and look for SPACES and puntuation (,.!?'";). I would expect the length of words on average to be pretty small (<20 letters).
3) Open the file, check first 1-2K for words in a dictionary. If most words found are not in the dictionary, it's probably binary.
|
|
|
|
|
10x for the excellent ideas
R.
|
|
|
|
|
Open the file. Read the first 1024 bytes. You can bet yourself that if it's a binary file there will be a few bytes within the first 1024 that are not alphanumeric or punctuation.
Nish
p.s. If you have UNICODE text files you have a problem though
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Buy it, read it and admire me
|
|
|
|
|
We are facing a problem of :
We call a VC++ exe (Form View single document application) from C#
But we want to close it after it’s execute
We tried after
WaitForProcess
Process.CloseMainWindow
&
Process.Close
|
|
|
|
|
The following C++ code waits for the app to terminate before continuing. It may be of some help
HANDLE hProcess = NULL;
SHELLEXECUTEINFO shellInfo;
::ZeroMemory(&shellInfo, sizeof(shellInfo));
shellInfo.cbSize = sizeof(shellInfo);
shellInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
shellInfo.nShow = SW_HIDE;
shellInfo.lpFile = _T("anyapp.exe");
shellInfo.lpParameters = args;
if(::ShellExecuteEx(&shellInfo))
{
hProcess = shellInfo.hProcess;
if (hProcess != NULL)
{
::WaitForSingleObject(hProcess, INFINITE);
::CloseHandle(hProcess);
}
}
|
|
|
|
|
|
I am displaying a modeless dialog in my app...everything related to the dialog works fine. However, there is a button in the Windows taskbar with no text displayed and it is associated with the modeless dialog.
How do I get the button not to appear in the taskbar when the modeless dialog is launched?
|
|
|
|
|
There is an article here on CP that Chris Maunder wrote.
And Mike Dunn: This question should be in the FAQ!
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C# and C++!
|
|
|
|
|
Read :-
http://www.codeproject.com/useritems/dlgboxtricks.asp
There is a tip there called "Removing the task bar icon of your dialog based App"
Use the same technique mentioned there.
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Buy it, read it and admire me
|
|
|
|
|
Thanks for the reply. I found an easier way (in a reply to an article)...just set the dialog style to Tool Window. Now I have another problem to work through...I want the modeless dialog window to always be on top, so I made it the topmost window...works fine. I want to keep it from grabbing the focus every time I move or resize the MDI Mainframe window... the mainframe window is the dialog's parent.
Any Ideas?
Also, the dialog remains on top when I switch to other applications like Word or Excel...Does anyone now how to stop this behavior?
|
|
|
|
|
if you make the desktop the parent of the dialog (ie. use NULL as the parent), it will be completely independent of the application's focus.
-c
Cheap Oil. It's worth it!
|
|
|
|
|
I tried what you suggested...It made no difference...The modeless dialog still grabs focus when I resize the mainframe window and it is still in front of other, non application, windows when when I switch to other applications
|
|
|
|
|
Let's say you are using MFC, and have a function that accepts a constant string as its argument. Which is better style:
1. int SomeFunction(LPCTSTR stringArgument);
2. int SomeFunction(const CString &stringArgument);
Most MFC functions use a form of number 1, but it seems number 2 is more "object oriented", at least by appearance. I guess number 2 would have to create a CString object on the fly if you specifiy a constant string, so there may be a performance difference..?
Or am I just being anal and it doesn't make that much of a difference in real life?
No generalization is 100% true.
Not even this one.
|
|
|
|
|
/me eagerly waits others opinions..
i'd say number 2, because i hate 'LPCTSTR', i do my best to avoid that damn keyword .. prolly cause im scured..
-dz
|
|
|
|
|
dazinith wrote:
i'd say number 2, because i hate 'LPCTSTR', i do my best to avoid that damn keyword .. prolly cause im scured..
Yeah I know what you mean, Windows and it's butt-ugly keywords. But it is nice to have something that'll work with Unicode, multi-byte, and ANSI builds.. otherwise I'd just good old const char *.
No generalization is 100% true.
Not even this one.
|
|
|
|
|
const CString& sParam.
There is a good aricle in MSJ now MSDN magazine around '95/'95 which describe the best method calls with LPSTR/LPCSTR/CString/CString& I think the article could be by Jeff Process/Jeff Richter or even Paul De Loucia - sorry Paul if I spelt your name wrong.
Normski. - Professional Windows Programmer
|
|
|
|