Open the file using CreateFile, use OPEN_EXISTING for parameter
'dwCreationDisposition'.

Call GetFileSize() or GetFileSizeEx() to retrieve the file size.

Allocate a buffer using the file size, set your cml->pszKeywords to this
newly allocated buffer.

Call ReadFile to read the entire file into the buffer.

HTH
Shyan


> -----Original Message-----
> From: Danny Jackson [mailto:[EMAIL PROTECTED]
> Sent: Monday, November 08, 2004 2:53 PM
> To: [EMAIL PROTECTED]
> Subject: [c-prog] Opening and Reading a file
>
>
>
> Hello, I'm new to Win32 programming in C.
>
> What I need to do is to open a file using CreateFile, read the file
> to a global variable using ReadFile.
>
> The name of the file is C:\IDE\Lang.lng, its length is 761B
>
> This is the code I have so far.
>
> #include <stdio.h>
> #include <windows.h>
>
>
>  //Language definition
> typedef struct _CM_LANGUAGE {
>     DWORD   dwStyle;
>     BOOL    bIsCaseSensitive;
>     LPCTSTR pszKeywords;
>     LPCTSTR pszOperators;
>     LPCTSTR pszSingleLineComments;
>     LPCTSTR pszMultiLineComments1;
>     LPCTSTR pszMultiLineComments2;
>     LPCTSTR pszScopeKeywords1;
>     LPCTSTR pszScopeKeywords2;
>     LPCTSTR pszStringDelims;
>     TCHAR   chEscape;
>     TCHAR   chTerminator;
>     LPCTSTR pszTagElementNames;
>     LPCTSTR pszTagAttributeNames;
>     LPCTSTR pszTagEntities;
>  } CM_FBSL;
>
>  int CM_Fill( CM_FBSL *cml )
>  {
>   cml->pszKeywords = //I need to set this to the glogal variable
> }
>
> Any help would be greatly appreciated.
>




To unsubscribe, send a blank message to <mailto:[EMAIL PROTECTED]>.


Yahoo! Groups Sponsor
ADVERTISEMENT
click here
Web Bug from http://us.adserver.yahoo.com/l?M=295196.4901138.6071305.3001176/D=groups/S=:HM/A=2128215/rand=483918612


Yahoo! Groups Links

Reply via email to