Board index » cppbuilder » Create a shared network folder. part 2?

Create a shared network folder. part 2?


2006-06-29 05:04:28 AM
cppbuilder88
Hi
The code below now compiles fine but on running I get error 53 yet c:\DTT
does exist, any thoughts please folks?
void __fastcall TmainForm::create_share_drive(void)
{
NET_API_STATUS res;
SHARE_INFO_2 p;
DWORD parm_err = 0;
wchar_t *pFolder = L"C:\\DTT";
wchar_t *pShare = L"DTTServer";
p.shi2_netname = pShare;
p.shi2_type = STYPE_DISKTREE; // disk drive
p.shi2_remark = pShare;
p.shi2_permissions = ACCESS_ALL;
p.shi2_max_uses = -1;
p.shi2_current_uses = 0;
p.shi2_path = pFolder;
p.shi2_passwd = NULL; // no password
res=NetShareAdd(pShare, 2, (LPBYTE) &p, &parm_err);
}
--
Nevikski
www.kevsbox.com
 
 

Re:Create a shared network folder. part 2?

"nivekski" < XXXX@XXXXX.COM >wrote in message
Quote
The code below now compiles fine but on running I get
error 53 yet c:\DTT does exist, any thoughts please folks?
53 is ERROR_BAD_NETPATH. You are specifying the remote machine's name as
the share where you should be specifying the name of the actual share that
the remote computer has defined. You are also not including backslashes in
the server name
Try this instead (untested):
void __fastcall TmainForm::create_share_drive(void)
{
SHARE_INFO_2 p = {0};
DWORD parm_err = 0;
p.shi2_netname = TEXT("TheShareName");
p.shi2_type = STYPE_DISKTREE; // disk drive
p.shi2_remark = TEXT("TheShareName test");
p.shi2_permissions = ACCESS_ALL;
p.shi2_max_uses = -1;
p.shi2_current_uses = 0;
p.shi2_path = TEXT("C:\\DTT");
p.shi2_passwd = NULL; // no password
NetShareAdd(TEXT("\\\\DTTServer"), 2, (LPBYTE) &p, &parm_err);
}
Gambit
 

Re:Create a shared network folder. part 2?

Ah, thanks
--
Nevikski
www.kevsbox.com
"Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >wrote in message
Quote

"nivekski" < XXXX@XXXXX.COM >wrote in message
news: XXXX@XXXXX.COM ...

>The code below now compiles fine but on running I get
>error 53 yet c:\DTT does exist, any thoughts please folks?

53 is ERROR_BAD_NETPATH. You are specifying the remote machine's name as
the share where you should be specifying the name of the actual share that
the remote computer has defined. You are also not including backslashes
in
the server name

Try this instead (untested):

void __fastcall TmainForm::create_share_drive(void)
{
SHARE_INFO_2 p = {0};
DWORD parm_err = 0;

p.shi2_netname = TEXT("TheShareName");
p.shi2_type = STYPE_DISKTREE; // disk drive
p.shi2_remark = TEXT("TheShareName test");
p.shi2_permissions = ACCESS_ALL;
p.shi2_max_uses = -1;
p.shi2_current_uses = 0;
p.shi2_path = TEXT("C:\\DTT");
p.shi2_passwd = NULL; // no password

NetShareAdd(TEXT("\\\\DTTServer"), 2, (LPBYTE) &p, &parm_err);
}


Gambit


 

{smallsort}