|
I don't have any sample code for you.
But to manipulate large files, you should throw C functions away, and
use Windows API to do it, open, seek, get file size, read/write, etc.
It's not difficult to learn those APIs by yourself.
|
|
|
|
|
Koms Bomb wrote:
It's not difficult to learn those APIs by yourself.
Okay, just one question:
C-Runtime provide feof, what is the windows API version of this?
regards,
Rich
"Programming today is a race between software engineers striving to build bigger and
better idiot-proff programs, and the Universe trying to produce bigger and better idiots.
So far the Universe is winning." -- Rich Cook
|
|
|
|
|
RichardS wrote:
C-Runtime provide feof, what is the windows API version of this?
When using ReadFile() , consider this from MSDN:
If the return value is nonzero and the number of bytes read is zero, the file pointer was beyond the current end of the file at the time of the read operation. However, if the file was opened with FILE_FLAG_OVERLAPPED and lpOverlapped is not NULL, the return value is FALSE and GetLastError returns ERROR_HANDLE_EOF when the file pointer goes beyond the current end of file.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Hi David,
Thanks for the info
regards,
Rich
"Programming today is a race between software engineers striving to build bigger and
better idiot-proff programs, and the Universe trying to produce bigger and better idiots.
So far the Universe is winning." -- Rich Cook
|
|
|
|
|
Another way,
GetFileSize to get the file size,
Then use SetFilePointer to 'seek' the file pointer, but you should only seek with zero offset from currect point, then that API will tell you where the currect pointer is.
Now compare that pointer with the file size...
So you don't need to read to the end of the file.
|
|
|
|
|
I've not ever used FAT32, but it supports a maximum file size of 232-1 bytes. That would prohibit your 5GB file from working on Windows 98.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Hi David,
You are quite right. That's why the C-runtime calls were working well as you could seek 2GB - 2 distance. But now with XP/2000/NT we have the problems.
regards,
Rich
"Programming today is a race between software engineers striving to build bigger and
better idiot-proff programs, and the Universe trying to produce bigger and better idiots.
So far the Universe is winning." -- Rich Cook
|
|
|
|
|
And for whatever it is worth, if you install the C runtime library source code and trace through it far enough, you will find it just ends up mapping all the standard C file flags and functions into calls into the Win32 API anyways.
I had to use that as defense to the argument when someone tried to tell me the C runtime was faster than the Win32 API - how could it be, after a slew of mapping operations, the C runtime functions ended up calling the Win32 API functions anyways...
|
|
|
|
|
Hi Everybody,
In my rich edit application, I just discovered CFM_LINK and am enjoying having clickable links in my CRichEditCtrl. However, when I use streamOut and streamIn to save my control contents to disk and back, all the RTF formatting is preserved except for the links. Please guide me how to save the RTF document along with the hyperlink.
Regards,
Prakash.
A Journey of thousand miles must begin with a single step.
|
|
|
|
|
XP, no SP, the WMP is the one binds with XP.
I put a WMP control on a MFC dialog, then I play it, and adjust the volume.
I want to save the volume when exits, so I tried GetVolume, but it always
returns -600 (the default volume value).
Why? What have I missed? Did any one experience this?
I've post this in MS newsgroup, but got no answers.
Thanks.
|
|
|
|
|
Can you provide some code?
P.
|
|
|
|
|
Sorry, the code is in my home and I'm in office now.
My steps are,
1, Right click on th dialog then select Insert ActiveX control,
2, Select Windows Media Player and put it on the dialog,
3, Run the app and play something,
4, When a button click, I call the Medial Player's GetVolume to get the volume, but the result is always -600 even I've change the volume bar.
|
|
|
|
|
I am receiving a binary buffer in big endian on a little endian machine.
Is there an SDK func that can convert big buffers from big endian to little endian???
Thx for any help,
Greetings,
Davy
|
|
|
|
|
Hi Davy,
I don't know of a SDK to do it, but switching endian's isn't a big deal. You can do the following:
<br />
typedef struct _tagByteBreak<br />
{<br />
unsigned char bUpperByte;<br />
unsigned char bMiddleByte1;<br />
unsigned char bMiddleByte2;<br />
unsigned char bLowerByte;<br />
} BYTE_BREAK;<br />
<br />
typedef union _tagEndianSwitch<br />
{<br />
BYTE_BREAK stBreak;<br />
unsigned long int ulFull;<br />
} ENDIAN_SWITCH;<br />
<br />
void UTIL_SwitchEndian (unsigned long int *pulIn)<br />
{<br />
ENDIAN_SWITCH Endian;<br />
unsigned char btemp;<br />
<br />
Endian.ulFull = *pulIn;<br />
<br />
btemp = Endian.stBreak.bLowerByte;<br />
Endian.stBreak.bLowerByte = Endian.stBreak.bUpperByte;<br />
Endian.stBreak.bUpperByte = btemp;<br />
btemp = Endian.stBreak.bMiddleByte1;<br />
Endian.stBreak.bMiddleByte1 = Endian.stBreak.bMiddleByte2;<br />
Endian.stBreak.bMiddleByte2 = btemp;<br />
<br />
*pulIn = Endian.ulFull;<br />
}<br />
This code takes a unsigned long int (32-bits) at swops the endian (either direction). Now all you need is a loop:
<br />
void ConvertEndian (unsigned long int szLen, unsigned long int *pulBuf)<br />
{<br />
for (unsigned long int i = 0; i < szLen; ++i)<br />
{<br />
UTIL_SwitchEndian (&pulBuf[i]);<br />
}<br />
}<br />
This will convert the buffer to the opposite endian system. It should be easy to modify for 16-bits.
regards,
Rich
"Programming today is a race between software engineers striving to build bigger and
better idiot-proff programs, and the Universe trying to produce bigger and better idiots.
So far the Universe is winning." -- Rich Cook
|
|
|
|
|
Thanks for the thorough answer!
Greetings,
Davy
|
|
|
|
|
You have to know the layout of the buffer.
If it is just an array of numbers than you do something like what Richard suggests.
More often though the buffer is the contents of a struct or class.
In that case you have to swap the members.
e.g.
struct ST {
long l;
short s;
float f;
double d;
};
You get a buffer:
char *buff = ...;
Cast buffer to structure:
struct ST *st = (struct ST*)buff;
Swap members:
st->l = SWAP4(st->l);
st->s = SWAP2(st->s);
st->f = SWAP4(st->f);
st->d = SWAP8(st->d);
where SWAP*() swaps the specified number of bytes.
e.g.
#define SWAP2(x) ( ((x) << 8) | ((x) >> 8) )
#define SWAP4(x) ( ((x) << 24) | ((x) >> 24) | \
( ((x) & 0x0000ff00) << 8 ) | \
( ((x) & 0x00ff0000) >> 8 ) \
)
#define SWAP8(x) ( ((x) << 56) | ((x) >> 56) | \
( ((x) & 0x000000000000ff00) << 40 ) | \
( ((x) & 0x0000000000ff0000) << 24 ) | \
( ((x) & 0x00000000ff000000) << 8 ) | \
( ((x) & 0x000000ff00000000) >> 8 ) | \
( ((x) & 0x0000ff0000000000) >> 24 ) | \
( ((x) & 0x00ff000000000000) >> 40 ) \
)
...cmk
Save the whales - collect the whole set
|
|
|
|
|
Hi!
I'm having trouble using this API callback function, EnumSystemLanguageGroups.
When I compile I get this error message:
c:\Documents and Settings\bsosla\Desktop\Regional Settings Plugin\Regional Settings\Regional Settings\regionalSettingsPlugin.cpp(457): error C3861: 'EnumSystemLanguageGroups': identifier not found, even with argument-dependent lookup
Reading a little about this callback function I see that I have to include winnls.h and windows.h, adding the library kernel32.lib.
All this is done but without any results.
What am I doing wrong?
Thanks!
|
|
|
|
|
Hachaso wrote:
...error C3861: 'EnumSystemLanguageGroups': identifier not found, even with argument-dependent lookup
This is not a Visual Studio v6 error. Are you using Visual Studio v7.x instead?
Have you seen this?
Hachaso wrote:
Reading a little about this callback function I see that I have to include winnls.h and windows.h...
Actually, only winnls.h is required. You get that one by default if you are already including windows.h .
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Hi!
Thanks for helping me!
I'm using Visual Studio .NET 2003. I guess that its version 7.
Do you think that the problem can be related to what kind of project I've started?
When I create a Win32 project, letting the Wizard create the base code, then add my lines I get no compile error. But adding the same lines to another existing project returns an error. This is why I'm wondering if it has to do with what kind of project I start?
Thanks!
|
|
|
|
|
At this point, I would compare the project settings of the one that works with the one that doesn't work.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Hi Again!
Thank you once more for helping me out.
I've compared and can't find any difference that would solve the problem.
I've looked at the weblink you gave me. That's the page that I've been looking at all
the time. My problem is that they explain what the function does and what the different
parameters do but they don't give you any example code.
For example, BOOL EnumSystemLanguageGroups(
LANGUAGEGROUP_ENUMPROC pLangGroupEnumProc, // callback function
DWORD dwFlags, // language groups
LONG_PTR lParam // callback parameter
);
LANGUAGEGROUP_ENUMPROC is retrieved from another function called EnumLanguageGroupsProc.
When I try, using the headerfiles needed and kernel32.lib I come to the conclusion that
It may not exist anymore. Cause it doesn't recognize it.
Could you maybe help med with some example how to implement the different parameters, so
that I can understand what I'm doing wrong.
Thanks!
|
|
|
|
|
Hachaso wrote:
I've compared and can't find any difference that would solve the problem.
I provided you two different links. They are completely different.
Hachaso wrote:
LANGUAGEGROUP_ENUMPROC is retrieved from another function called EnumLanguageGroupsProc.
Huh? LANGUAGEGROUP_ENUMPROC is a typedef from winnls.h .
Hachaso wrote:
Could you maybe help med with some example how to implement the different parameters, so
that I can understand what I'm doing wrong.
BOOL CALLBACK EnumProc(
LGRPID LanguageGroup,
LPTSTR lpLanguageGroupString,
LPTSTR lpLanguageGroupNameString,
DWORD dwFlags,
LONG_PTR lParam
)
{
return TRUE;
}
...
EnumSystemLanguageGroups(EnumProc, LGRPID_INSTALLED, 0);
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Hi!
Hope I'm not to much trouble.
I'm kind of new to this so thanks for all the help.
DavidCrow wrote:
Huh? LANGUAGEGROUP_ENUMPROC is a typedef from winnls.h.
I hope I understand this right:
How do I use this typedef?
LANGUAGEGROUP_ENUMPROC EnumProc; (like this ??)
Then declare the callback function:
BOOL CALLBACK EnumProc(
LGRPID LanguageGroup,
LPTSTR lpLanguageGroupString,
LPTSTR lpLanguageGroupNameString,
DWORD dwFlags,
LONG_PTR lParam
)
{
return TRUE;
}
Then send this to EnumSystemLanguageGroups:
EnumSystemLanguageGroups(EnumProc, LGRPID_INSTALLED, 0);
Is this how it is supposed to be used??
I read a remark in the page link you gave me;
This function can carry out any desired task. An application registers an EnumLanguageGroupsProc function by passing its address to the EnumSystemLanguageGroups function.
I'm really new to all this, so please explain in details.
Thanks!
|
|
|
|
|
Hachaso wrote:
How do I use this typedef?
LANGUAGEGROUP_ENUMPROC EnumProc; (like this ??)
Not necessary.
Hachaso wrote:
Is this how it is supposed to be used??
Yes, just like the code snippet I provided.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
How to share a variable between two classes?
Please give me a answer.
Thank you very much!
|
|
|
|