comp.lang.ada
 help / color / mirror / Atom feed
* Pointers, C, Win32 API
@ 2005-04-19 23:13 Steve
  2005-04-20  0:00 ` Stephen Leake
  0 siblings, 1 reply; 4+ messages in thread
From: Steve @ 2005-04-19 23:13 UTC (permalink / raw)


Hi,

I am fairly new to ADA and have a query.
I am writing a program in ADA to monitor a directory for any changes
using a notification API.

MSDN Samples have a solution called FWATCH and I am basing my code on
this. I understand the C code but I am having problems converting it to
ADA.

Firstly, the C code:

// this is the all purpose structure that contains
// the interesting directory information and provides
// the input buffer that is filled with file change data
typedef struct _DIRECTORY_INFO {
		HANDLE      hDir;
		TCHAR       lpszDirName[MAX_PATH];
		CHAR        lpBuffer[MAX_BUFFER];
		DWORD       dwBufLength;
		OVERLAPPED  Overlapped;
	} DIRECTORY_INFO, *PDIRECTORY_INFO, *LPDIRECTORY_INFO;

DIRECTORY_INFO  DirInfo;

...

    // Set up a key(directory info)
    hCompPort=CreateIoCompletionPort( DirInfo.hDir,
                                      hCompPort,
                                      (DWORD) &DirInfo,
                                       0);


    // Start watching the directory of interest
    ReadDirectoryChangesW( DirInfo.hDir,
                           DirInfo.lpBuffer,
                           MAX_BUFFER,
                           TRUE,
                           FILE_NOTIFY_CHANGE_LAST_WRITE,
                           &DirInfo.dwBufLength,
                           &DirInfo.Overlapped,
                           NULL);

----------------------------------------
Great, all is well. Now here is my attempt at the ADA version:

type DIRECTORY_INFO_T is record
	hDir         :  Win32.Winnt.HANDLE;
        lpszDirName  :	Win32.TCHAR;
        lpBuffer     :	Win32.CHAR;
        dwBufLength  :  Win32.DWORD;
        lpOverlapped :  Win32.Winbase.LPOVERLAPPED;
end record;

DirInfo : DIRECTORY_INFO_T;

...

     // Set up a key(directory info)
     hCompPort := Winbase.CreateIoCompletionPort(
                       FileHandle                => DirInfo.hDir,
                       ExistingCompletionPort    => hCompPort,
                       CompletionKey             => ?????,
                       NumberOfConcurrentThreads => 0);


In ADA how do I do what the 'C' example is doing:
--->    (DWORD) &DirInfo,

Cheers

Steve




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-04-20 23:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-04-19 23:13 Pointers, C, Win32 API Steve
2005-04-20  0:00 ` Stephen Leake
2005-04-20  2:44   ` Steve
2005-04-20 23:29     ` Stephen Leake

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox