Project

General

Profile

Patch #984 » main.c

sample code to demonstrate the problem - Axel Waggershauser, 27 Aug 2014 08:06

 
1
#include <stdio.h>
2
#include <windows.h>
3

    
4
int main(int argc, char** argv)
5
{
6
	printf("Opening file '%s' with FILE_SHARE_DELETE acess...\n", argv[1]);
7

    
8
	HANDLE hFile = CreateFile(argv[1], GENERIC_READ,
9
			FILE_SHARE_DELETE|FILE_SHARE_READ|FILE_SHARE_WRITE,
10
			NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,	NULL);
11

    
12
	if (hFile == INVALID_HANDLE_VALUE) {
13
		printf("failed to open file\n");
14
		return -1;
15
	}
16

    
17
	sleep(10);
18

    
19
	CloseHandle(hFile);
20

    
21
	return 0;
22
}
23

    
(2-2/4)