Article View: borland.public.cppbuilder.nativeapi
Article #115Re: CreateFile/CloseHandle increases win32 Handle Count
From: Bob Gonder
Date: Thu, 05 Jun 2008 16:09
Date: Thu, 05 Jun 2008 16:09
42 lines
2169 bytes
2169 bytes
Christian Lotze wrote:
>Using BDS 2007:
>Just setup new VCL form application put button onto form and copy your
>code (except Pause function) to that button handler. During debug
>session Handle Count in PE increases by 2 at CreateFile and decreases by
>1 at CloseHandle
>
>Installed trial version of TaskInfo (http://www.iarsn.com/taskinfo.html)
Using TCE2006 and PE 5.24.1
Compile/run from IDE, 45 handles.
Press Button3, 46 handles.
Press again, 45 handles.
\Device\Harddisk0\DR0
//---------------------------------------------------------------------------
HANDLE h = 0;
void __fastcall TForm1::Button3Click(TObject *Sender)
{
if( h )
{ CloseHandle(h);
h = 0;
}else{
DWORD written;
char str[1024];
h = CreateFile( "\\\\.\\PHYSICALDRIVE0",
GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
0,
0);
if(INVALID_HANDLE_VALUE!=h)
{
SetFilePointer(h,0,NULL,FILE_BEGIN);
ReadFile(h,str,sizeof(str), &written,0);
};
};
}
//---------------------------------------------------------------------------
Technical Details
Message-ID:
<rr3g449i9qrmfumdgakq81ot6b3a29aebg@4ax.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nac.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<484794e5@newsgroups.borland.com> <t9tf44p56a7h577cn5re908cm3i652v55l@4ax.com> <4847fc2a$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,93e619dfbda10652 X-Google-Attributes: gid10cc67,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: Bob Gonder <none@nowhere.invalid> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: CreateFile/CloseHandle increases win32 Handle Count Date: Thu, 05 Jun 2008 09:09:17 -0700 Message-ID: <rr3g449i9qrmfumdgakq81ot6b3a29aebg@4ax.com> References: <484794e5@newsgroups.borland.com> <t9tf44p56a7h577cn5re908cm3i652v55l@4ax.com> <4847fc2a$1@newsgroups.borland.com> X-Newsreader: Forte Agent 1.93/32.576 English (American) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 67.77.144.232 X-Trace: newsgroups.borland.com 1212682154 67.77.144.232 (5 Jun 2008 09:09:14 -0700) Lines: 45 Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nac.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail X-Original-Bytes: 2015