🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #11195

CreateFile and ReadFile

#11195
From: ray
Date: Thu, 19 Feb 2004 16:42
21 lines
1612 bytes
Hi,
i can use the following code to read a drive, but it just allows me to read
512*n bytes (sector size) every time.
how can i read 1 byte every time?

//=================================
char drivename[]="\\\\.\\c:";
  HANDLE hDevice = CreateFile(drivename,
        GENERIC_READ,   FILE_SHARE_READ,
        NULL, OPEN_EXISTING,   0,      NULL    );
    SetFilePointer (hDevice, addr, NULL, FILE_BEGIN);

    char* buffer = (char*)malloc(size);
    ReadFile(hDevice, buffer, size, &bytesread, NULL);
//=================================

i change the size to 1 or lest than 512, it don't work.



.
Technical Details
Message-ID: <4034e792$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!news-out1.nntp.be!propagator4-cogent.newsfeed.com!propagator2-sterling!news-in.nuthinbutnews.com!xmission!logbridge.uoregon.edu!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,a2e178d9fedcf99e,start
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2004-02-19 09:07:11 PST
Reply-To: "ray" <srayray@hotmail.com>
From: "ray" <srayray@hotmail.com>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: CreateFile and ReadFile
Date: Fri, 20 Feb 2004 00:42:58 +0800
Lines: 23
Organization: ray
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: 203.176.133.70
Message-ID: <4034e792$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1077208978 203.176.133.70 (19 Feb 2004 08:42:58 -0800)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!news-out1.nntp.be!propagator4-cogent.newsfeed.com!propagator2-sterling!news-in.nuthinbutnews.com!xmission!logbridge.uoregon.edu!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail