On Tue, 08 Feb 2011 01:10:02 -0600, Andrew Wiley wrote: > I'm trying to use the Windows file change notification API from D, and > I'm having trouble translating Microsoft's macro-laden signatures into > D. I thought I had it figured out, but optlink says otherwise: The > original function is this: > > HANDLE WINAPI FindFirstChangeNotification( > __in LPCTSTR lpPathName, > __in BOOL bWatchSubtree, > __in DWORD dwNotifyFilter > ); > > I translated it into: > > extern(Windows) { > uint FindFirstChangeNotification( > const(char)* lpPathName, > bool bWatchSubtree, > uint dwNotifyFilter > ); > } > > Optlink is giving me undefined symbol errors, but I can't seem to figure > out what I have wrong. Any help would be appreciated.
I think you have to use either the FindFirstChangeNotificationW function (Unicode) or FindFirstChangeNotificationA function (ANSI) -- probably the former. Also, if you import core.sys.windows.windows, you can use the Windows API types directly: import core.sys.windows.windows; extern(Windows) HANDLE FindFirstChangeNotification( LPCWSTR lpPathName, BOOL bWatchSubtree, DWORD dwNotifyFilter ); Note that I replaced LPCTSTR with LPCWSTR, which is a UTF-16 string, i.e. an alias for const(wchar)* and not const(char)*. This means that you have to use the std.utf.toUTF16z() function to convert normal strings before passing them to the function. -Lars