|
-
May 17th, 2001, 04:49 AM
#1
Thread Starter
Retired VBF Adm1nistrator
Im confused ...
Howdy.
I got this piece of code off the microsoft site.
I tried converting it to VB, but that didnt work. So I decided id compile as is and shell out to it from vb.
Anyway, it is just not happening.
Info regarding it can be found on :
http://msdn.microsoft.com/library/ps...lmapi_1sdb.htm
Code:
#include <stdio.h>
#include <windows.h>
#include <svrapi.h>
int main(int argc, char FAR * argv[])
{
char FAR * pszServerName = NULL;
short nLevel = 50;
struct share_info_50* pBuf = NULL;
unsigned short cbBuffer;
NET_API_STATUS nStatus;
//
// ServerName can be NULL to indicate the local computer.
//
if ((argc < 3) || (argc > 4))
{
printf("Usage: %s [\\\\ServerName] ShareName SharePath\n", argv[0]);
exit(1);
}
if (argc == 4)
pszServerName = argv[1];
//
// Allocate the memory required to specify a
// share_info_50 structure.
//
cbBuffer = sizeof(struct share_info_50);
pBuf = malloc(cbBuffer);
if (pBuf == NULL)
printf("No memory\n");
//
// Assign values to the share_info_50 structure.
//
strcpy(pBuf->shi50_netname, argv[argc-2]);
pBuf->shi50_type = STYPE_DISKTREE;
pBuf->shi50_flags = SHI50F_FULL;
pBuf->shi50_remark = NULL;
pBuf->shi50_path = argv[argc-1];
pBuf->shi50_rw_password[0] = '\0'; // No password
pBuf->shi50_ro_password[0] = '\0'; // No password
//
// Call the NetShareAdd function
// specifying information level 50.
//
nStatus = NetShareAdd(pszServerName,
nLevel,
(char FAR *)pBuf,
cbBuffer);
//
// Display the result of the function call.
//
if (nStatus == NERR_Success)
printf("Share added successfully\n");
else
fprintf(stderr, "A system error has occurred: %d\n", nStatus);
//
// Free the allocated memory.
//
if (pBuf != NULL)
free(pBuf);
return 0;
}
Any ideas on how to get it to work ?
All I want to to is be able to shell an executable that will share the current system's C:\ (well, the drive that windows is on, but c:\ will do).
Thanks,
Jamie.
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
May 17th, 2001, 08:30 AM
#2
The pBuf->shi50_path member must be in all UPPER CASE.
Best regards
-
May 17th, 2001, 08:34 AM
#3
Thread Starter
Retired VBF Adm1nistrator
Em you may want to look at this too :
http://www.vbforums.com/showthread.p...3&goto=newpost
It points back to this one, but there's more info there.
- jamie
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|