NetShareEnum prob

Hello, I am having this very annoying problem with NetShareEnum:

int GetShares(char *ip)
{
SHARE_INFO_502 BufPtr;
unsigned long res;
unsigned long er = 0, tr = 0, resume = 0;
wchar_t server[256];

mbstowcs(server, ip, 256 );

res = NetShareEnum(ip, 502, (BYTE **)&BufPtr, 8192, &er, &tr, &resume);

Code compiles fine, but NetShareEnum always returns 1113 which is some kind of unicode error. I know the error is in the first parameter as I tried to change it to NULL, and then the function returned 0. I read that NetShareEnum only accepts widechars as first parameter, hence the mbstowcs function, but still I'm having no luck. What's wrong with my code?
[726 byte] By [Mesi] at [2007-11-18 18:28:37]