🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: CreateFile/CloseHandle increases win32 Handle Count

#311
From: Bob Gonder
Date: Thu, 05 Jun 2008 14:27
47 lines
1979 bytes
Christian Lotze wrote:

>This increases count of win32 handles every time
>  Createfile creates two handles
>  CloseHandle closes only one of theses handles
>
>(You can monitor this behaviour with processexplorer.)
>Any hints?

You must be doing something else.
This app shows only one more handle after CreateFile.
And it goes away after DeleteHandle.
Do you have PE set to show all of the handle details?

#include	"windows.h"
#include	<conio.h>

void pause(void)
{	cputs( "\r\nCheck for number of handles, then press any key");
	getch();
}

int main(void)
{	HANDLE		h;
	DWORD		written;
	char		str[1024];

	pause();
	h = CreateFile( "\\\\.\\PHYSICALDRIVE0",
                         GENERIC_READ,
                         FILE_SHARE_READ | FILE_SHARE_WRITE,
                         NULL,
                         OPEN_EXISTING,
                         0,
                         0);
	if(INVALID_HANDLE_VALUE!=h)
	{
		pause();
		SetFilePointer(h,0,NULL,FILE_BEGIN);
		pause();
		ReadFile(h,str,sizeof(str), &written,0);
		pause();
		CloseHandle(h);
		pause();
	};
	return 0;
}
Technical Details
Message-ID: <t9tf44p56a7h577cn5re908cm3i652v55l@4ax.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <484794e5@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 07:27:00 -0700
Message-ID: <t9tf44p56a7h577cn5re908cm3i652v55l@4ax.com>
References: <484794e5@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 1212676018 67.77.144.232 (5 Jun 2008 07:26:58 -0700)
Lines: 49
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail