Category : Files from Magazines
Archive   : PCTV4N3.ZIP
Filename : PRFILE.C

 
Output of file : PRFILE.C contained in archive : PCTV4N3.ZIP
þ7#çç $ $ $ $ $ 2 R R R R
\
f f˜
þx Rv –Ñ*û $Ѭ%ÑÑû ÑÑÑÑÑÑ/* prfile.c
* Provides an example of how to map a file into
* your address space under Windows NT.
* Copyright (C) 1993 by Nicholas Wilt. All rights reserved.
*/

#include
#include

#define PFILE_ER_BADFILENAME 1
#define PFILE_ER_FILESIZE 2
#define PFILE_ER_TOOBIG 3
#define PFILE_ER_MAPPING 4
#define PFILE_ER_MAPVIEW 5

int
PrintFile(char *filename)
{
HANDLE hFile;
OFSTRUCT os;
HANDLE fileMap;
LPVOID baseaddr;
DWORD loBytes, hiBytes;
char *sc;

/* First, open the file for reading */
hFile = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (! hFile)
return -PFILE_ER_BADFILENAME;

/* Figure out how big the file is */
loBytes = GetFileSize(hFile, &hiBytes);
if (loBytes == -1)
return -PFILE_ER_FILESIZE;

/* PrintFile doesn't support files greater than 4 GB */
if (hiBytes)
return -PFILE_ER_TOOBIG;

/* Create the file mapping object */
fileMap = CreateFileMapping(hFile, NULL, PAGE_READONLY,
0, 0, NULL);
if (! fileMap)
return -PFILE_ER_MAPPING;

/* Map the file into our address space */
sc = baseaddr = MapViewOfFile(fileMap, FILE_MAP_READ, 0, 0, 0);
if (! baseaddr)
return -PFILE_ER_MAPVIEW;

/* Scan through the file and print each
* character in it.
*/
while (loBytes--) {
printf("%c", *sc++);
}

UnmapViewOfFile(baseaddr);
CloseHandle(fileMap);
CloseHandle((HANDLE) hFile);
return 0;
}

int
main(int argc, char *argv[])
{
int ret;
if (argc != 2) {
fprintf(stderr, "Usage: %s file\n", argv[0]);
exit(1);
}
if (ret = PrintFile(argv[1]))
fprintf(stderr, "PrintFile returned error: %d\n", ret);
return 0;
}

uas‚…redˆ‚ÿçêúô
@
:F  <c £¤¹ÌÍì#>YZ^xz‹›®ÂÝêëT’¢ÁÂê+JK†–³´ÜCUst¡ä÷>U\sŒ‘’°Ééöøùý(<kuz›×äæçûûûûûûûûûûûûûûûûûûûûûûûûûûûûûûûûûûûûûûûûûûööööööööööööööööööööööööööööööööööö!ÀM€
Þçç÷çPÿÿ@ÿÿêç
!"€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ®¯°³ÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÚÛÝ Ó#$()GH]^_` ¶ÅÆ"""""<">"?"@"P"‹"Œ"‘"’"“"”"¼"½"¾"¿"À"Á"Â"Ã"Ç"È"É"Ê"Ë"Ì"Í"â"ã"ä"å"æ"ç"è"é"ì"í"î"ï"ý"þ"ÿ#*å*æ*ç*è3(3)3*3+3,3-3.3P3Q3R3S3T3U3a3b3c3d3¥3¦3§3¨8Î8Ï8Ð8Ñ8Ò8Ó8Ô8Õ8Ö8×8Ø8Ù8Ú8Û8Ü8Ý8à8á8â8ã8ê8ë9‰9Š9‹9Œ9ø9ù9ú9û9ü9ý:E:F:G:H:O:P:Q:µ:·:¸HHÚ(ÿáÿâùFG(üHHÚ(d'@=à/Р ÐRBH
-:LaserWriter
€Times:FB Letter Gothic BoldÀüü€€ü(eü(Bü Cool Barbara Cool Barbara

  3 Responses to “Category : Files from Magazines
Archive   : PCTV4N3.ZIP
Filename : PRFILE.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/