Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

76 lines
2.2 KiB

// fpnw.cpp : Implementation of shares for Novell NetWare
#include "stdafx.h"
#include <fpnwapi.h>
#define FUNCNAME_FPNWVOLUMEGETINFO "FpnwVolumeGetInfo"
#define FUNCNAME_FPNWVOLUMEADD "FpnwVolumeAdd"
#define FUNCNAME_FPNWAPIBUFFERFREE "FpnwApiBufferFree"
typedef DWORD (CALLBACK *PFPNWVOLUMEGETINFO) (LPWSTR, LPWSTR, DWORD, LPBYTE*);
typedef DWORD (CALLBACK *PFPNWVOLUMEADD)(LPWSTR, DWORD, LPBYTE);
typedef DWORD (CALLBACK *PFPNWAPIBUFFERFREE)(LPVOID);
BOOL
FPNWShareNameExists(
IN LPCTSTR lpszServerName,
IN LPCTSTR lpszShareName,
IN HINSTANCE hLib
)
{
BOOL bReturn = FALSE;
DWORD dwRet = NERR_Success;
PFPNWVOLUMEGETINFO pFPNWVolumeGetInfo = NULL;
PFPNWAPIBUFFERFREE pFPNWApiBufferFree = NULL;
if ((pFPNWVolumeGetInfo = (PFPNWVOLUMEGETINFO)GetProcAddress(hLib, FUNCNAME_FPNWVOLUMEGETINFO)) &&
(pFPNWApiBufferFree = (PFPNWAPIBUFFERFREE)GetProcAddress(hLib, FUNCNAME_FPNWAPIBUFFERFREE)) )
{
FPNWVOLUMEINFO *pInfo = NULL;
dwRet = (*pFPNWVolumeGetInfo)(
const_cast<LPTSTR>(lpszServerName),
const_cast<LPTSTR>(lpszShareName),
1,
(LPBYTE*)&pInfo);
if (NERR_Success == dwRet)
{
bReturn = TRUE;
(*pFPNWApiBufferFree)(pInfo);
}
}
return bReturn;
}
DWORD
FPNWCreateShare(
IN LPCTSTR lpszServer,
IN LPCTSTR lpszShareName,
IN LPCTSTR lpszSharePath,
IN PSECURITY_DESCRIPTOR pSD,
IN HINSTANCE hLib
)
{
DWORD dwRet = NERR_Success;
PFPNWVOLUMEADD pFPNWVolumeAdd = NULL;
if (!(pFPNWVolumeAdd = (PFPNWVOLUMEADD)GetProcAddress(hLib, FUNCNAME_FPNWVOLUMEADD)))
{
dwRet = GetLastError();
} else
{
FPNWVOLUMEINFO_2 VolumeInfo2;
ZeroMemory(&VolumeInfo2, sizeof(VolumeInfo2));
VolumeInfo2.lpVolumeName = const_cast<LPTSTR>(lpszShareName);
VolumeInfo2.dwType = FPNWVOL_TYPE_DISKTREE;
VolumeInfo2.dwMaxUses = -1; // unlimited
VolumeInfo2.lpPath = const_cast<LPTSTR>(lpszSharePath);
VolumeInfo2.FileSecurityDescriptor = pSD;
dwRet = (*pFPNWVolumeAdd)(const_cast<LPTSTR>(lpszServer), 2, (LPBYTE)&VolumeInfo2);
}
return dwRet;
}