No navigation frame on the left?  Click here.

Net*() and Win 95/98

If you got here, you probably want to use the Net*() API group on Windows 95 or Windows 98. Most likely, you already tried that, and it didn't work. Here are a few tips:

On Win9X, you need to include svrapi.h, not lm.h. Also, you do not link against netapi32.lib and netapi32.dll; you use svrapi.lib/svrapi.dll instead. If you have to support both NT and Win9X in one program, your best bet is to load the appropriate DLL dynamically at run-time.

Note that the Net*() functions have different calling sequences and semantics, as compared to the NT versions. In particular, all strings are ANSI; not all info levels are available; and instead of having the API allocate a buffer which you have to free, you need to reserve enough buffer space:

    // Windows NT
    BYTE *buf;
    DWORD prefmaxlen;
    // ...
    buf = NULL;
    prefmaxlen = 8192; // or whatever
    result = NetSomeFunction( ..., &buf, prefmaxlen, ... );
    // process buffer ...
    NetApiBufferFree( buf );

    // Windows 9X
    BYTE *buf;
    WORD cbBuffer;
    // ...
    cbBuffer = 8192; // or whatever
    buf = (BYTE *) malloc( cbBuffer );
    result = NetSomeFunction( ..., buf, cbBuffer ... );
    // process buffer ...
    free( buf );

Note that NT wants the address of the pointer to the future buffer (so it can return the address of the buffer it allocates), while Win9X wants the pointer to the buffer that you have allocated beforehand.