Calling a cpp function from d

2015-06-16 Thread C2D via Digitalmars-d-learn

Hi,
I encountered the following error:

Error: function files.SHGetFolderPath (void* hwndOwner, int 
nFolder, void* hToken, uint dwFlags, char* pszPath) is not 
callable using argument types (typeof(null), int, typeof(null), 
int, immutable(char)*)


When I'm try to run this code:
...
{
import std.utf : toUTF8;
static string cache;

wchar[MAX_PATH + 2] buf;

BOOL result = SHGetFolderPath(null, 0x23, null, 0, cache.ptr);

return cache;
}
...
extern(Windows) HRESULT SHGetFolderPath(HWND hwndOwner, int 
nFolder, HANDLE hToken, DWORD dwFlags, LPTSTR pszPath);


I tried everything I know about D and CPP. What can be the 
solution?


Re: Calling a cpp function from d

2015-06-16 Thread C2D via Digitalmars-d-learn

On Tuesday, 16 June 2015 at 12:31:23 UTC, John Chapman wrote:

On Tuesday, 16 June 2015 at 12:26:45 UTC, C2D wrote:

BOOL result = SHGetFolderPath(null, 0x23, null, 0, cache.ptr);


That should be:

BOOL result = SHGetFolderPath(null, 0x23, null, 0, buf.ptr);


Thanks, but I'm still getting the same error -
Error: function files.SHGetFolderPath (void* hwndOwner, int 
nFolder, void* hToken, uint dwFlags, char* pszPath) is not 
callable using argument types (typeof(null), int, typeof(null), 
int, wchar*)