|
CFile::GetPosition() returns a DWORD, not a ULONGLONG. Plus, the MFC source code asserts if it returns (DWORD)-1, so if you're not asserting, then that is probably not being returned.
The error is probably in using a 64-bit variable to hold a 32-bit result. Try changing the ULONGLONG to a DWORD and printing using a %u instead of %I64 and see what happens.
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
From the MSDN:
MFC Library Reference CFile::GetPositionSee AlsoCFile Overview | Class Members | Hierarchy ChartObtains the current value of the file pointer, which can be used in subsequent calls to Seek.virtual ULONGLONG GetPosition( ) const;Return ValueThe file pointer as a 32-bit doubleword.Example
I tried with DWORD and %u before my first post. And I tried again right now:
<br />
char szBuf[255];<br />
CStdioFile file("unix.file", CFile::modeRead);<br />
file.ReadString(szBuf, 255);<br />
DWORD dwPos = (DWORD)file.GetPosition();<br />
TRACE("dwPos=%u\n", dwPos);
file.SeekToBegin();<br />
file.Close();<br />
As I shown before the problems come only if CStdioFile object is reading a text file with UNIX's new lines (i.e. no \r).
But such file is read actualy correct. In while(file.ReadString(szBuf, 255) loop it reads line by line not all the file context as one line.
If there is the assertion you are talking about but why it asserts only with unix text files?
Seems like a usual Micro$oft's dirty trick.
Just try to compile this little code and you'll see what I'm talkig about.
My box is Win2000 Server with VS 7.0.
|
|
|
|
|
I only have VS6, so GetPosition() only returns a DWORD. I have come across a similar situation when I was using a ULONGLONG. Obviously the situation is different on VS7.
Have a look at the source. It might help explain the situation.
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
check the handle "file".. NULL?
|
|
|
|
|
wheregone wrote:
check the handle "file".. NULL?
No, if file is null I cannot call ReadString().
As I have told already ReadString works fine and gets line by line in while() loop.
|
|
|
|
|
I have tried.. it does not work too..
SO I think you'd better change the file format to DOS format at first.
|
|
|
|
|
I did it first time I have beed sure about the bug is exactly a bug.
So... I'm sure this is just a dirty Microsoft's trick.
|
|
|
|
|
for data file "00000000h: 31 31 31 31 31 31 3D 0A ..."
my function returns "111111="
for the second time, it returns "", I think I should increase g_fPosition.
But the GetPosition is OK anyway.
/////////////////////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////////////////////
char gchOneLineNews[1024];
FILETIME g_ftWrite = { 0, 0 };
ULONGLONG g_fPosition = 0;
char * GetOneLineNews(char * pFile);
/////////////////////////////////////////////////////////////////////////////////////////////
// Get One Line News from the File, (read next line, check the write time)
/////////////////////////////////////////////////////////////////////////////////////////////
char * GetOneLineNews(char * pFile)
{
#if 1
FILETIME ftWrite;
UINT rt = 0;
CStdioFile file;
CFileException ex;
if (file.Open(pFile, CFile::modeRead, &ex))
{
if (GetFileTime(file, NULL, NULL, &ftWrite))
{
if(0 != CompareFileTime( &ftWrite, &g_ftWrite )) // not same
{
g_fPosition = 0;
g_ftWrite.dwLowDateTime = ftWrite.dwLowDateTime;
g_ftWrite.dwHighDateTime = ftWrite.dwHighDateTime;
}
file.Seek( g_fPosition, CFile::begin );
if ( NULL == file.ReadString( gchOneLineNews, 1023 ))
{
g_fPosition = 0;
file.Seek( g_fPosition, CFile::begin );
file.ReadString( gchOneLineNews, 1023 );
}
g_fPosition = file.GetPosition();
}
else
{
rt = -2;
}
file.Close();
}
else
{
rt = -1;
}
|
|
|
|
|
Hi, all.
I wrote a code to execute file with shellexecute function.
Since I wanna find the executable program of specific file, I use FindExecutable function.
However, I wanna make sure that the result of FindExecutable fuction is really executable program name.
I found PathIsExe function in MSDN Library, but it can't be run in Win 95 or Win 98 according to MSDN Library.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/functions/shellexecute.asp
I can't remember the function name that does the same work as PathIsExe.
Could you please help me to find API or other function that does determine whether a file is an executable by examining the file extension?
Thanx in advance.
|
|
|
|
|
"FindExecutable retrieves the name of and handle to the executable (.exe) file associated with the specified file name." (MSDN). Calling PathIsExe after FindExecutable seems redundant to me. Maybe I am not understanding your question properly.
// Afterall, I realized that even my comment lines have bugs
When one cannot invent, one must at least improve (in bed).-My latest fortune cookie
|
|
|
|
|
First of all, Thanks for reply.
Actually, I wrote a code just with FindExecutable and Shellexecute.
However, FindExecutable sometimes doesn't return properly executable program name and path.
So I want to check whether the result that FindExecutable returns is properly executable program name (i.e. by examining the extension)
And I found "PathIsExe" function, but it only supports Win2000 ir higher.
As a result, I'm looking for API or some kinds of function that does the same work as PathIsExe.
Sorry for ambiguous question.
|
|
|
|
|
You are welcome. Sorry but I can't really help you because I have never used PathIsExe.
// Afterall, I realized that even my comment lines have bugs
When one cannot invent, one must at least improve (in bed).-My latest fortune cookie
|
|
|
|
|
There's little magic behind PathIsExe , the docs say that it
returns TRUE if the file extension is .cmd, .bat, .pif, .scf, .exe, .com, or .scr. Returns FALSE otherwise.
So, you shouldn't have any problem with writing your home-made version of PathIsExe .
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi,
I used RasDial function for dial up connection.
It’s works fine in win2000, winXP and some of the win98.
My problem is, some of the win98 machine it doesn’t work.
Could you tall me, why didn't work in win98.
Here is my code:
DWORD dwRet = RasDial(NULL, NULL, &rdParams, 0L, RasDialFunc, &g_hRasConn );
|
|
|
|
|
Which value has dwRet upon error?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thank you for reply.
error is: "Cannot find the phone book entry."
this error is only occur in win98.
if you know the solution then please reply.
|
|
|
|
|
I've got a hunch. There's a well known bug n Win95 (maybe it has survived in 98) that causes RasDial to fail with this error code when:- No entry name is specified
- and no dial-up connection is set up in the system.
The only solution I can come up with would involve creating a dummy entry (with RasSetEntryProperties ) even if you don't use it later on. Please report back if you try this.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
hi,
i try with RasSetEntryProperties but it return error code 87.
here is my code.
RASENTRY RasEntry;
DWORD dwEntryInfoSize, dwRet;
memset(&RasEntry, 0, sizeof(RASENTRY));
RasEntry.dwSize = sizeof(RASENTRY);
dwEntryInfoSize = sizeof(RasEntry);
sprintf(RasEntry.szLocalPhoneNumber, "89188888");
dwRet = RasSetEntryProperties(NULL, "MY CONNECTION", &RasEntry, dwEntryInfoSize, NULL, 0);
now what can i do?
|
|
|
|
|
Hey Friends Can someone suggest how we can customize the Grippers displayed when using CRectTracker class.
I wish to use the Style ,any suggestion for using the style CRectTracker::resizeOutside,how about using multiple selection and multiple control tracking .
|
|
|
|
|
Your best bet is to derive a class from CRectTracker and override the "Draw" function. Copy and paste the existing CRectTracker::Draw code and then modify as desired.
If you want multiple selection then search CP - I'm sure there have been articles that cover this.
When I am king, you will be first against the wall.
|
|
|
|
|
Dear Robert Edward Caldecott
I tried the Copy And Paste But.............
In the debug mode the execution goes in OnDraw but the Output is the same old one even if I simply put a return statement ie no code for My CRectTracker inherited Draw Function.Can U Pl give it a one more try .
|
|
|
|
|
Then try overriding DrawTrackerRect instead.
When I am king, you will be first against the wall.
|
|
|
|
|
Wollah ..................
Yes You Were Right at the First Place.
Actually I Suppose Draw is Not a Virtual Function And I Was Creating an object of CMyRectTracker but using a Pointer of CRectTracker,I figured it out ,tried it again and Yes It is Working I am able to draw RED Coloured Grippers which I suppose I can change according to my need,
Thanks,Thanks ,Thanks.................................................
|
|
|
|
|
Hi~~
i have a string containing an hex number and i want to convert it to an integer.
--------------------------------------------------------------
char *temp = "0x3e40";
i want to convert it to an interger.. which is 15936
how do i do that?
Thanks
|
|
|
|
|
unsigned long nValue = 0;
long nConverted = sscanf (temp, "%x", &nValue);
if (nConverted != 1) {
failure;
} /ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|