Click to See Complete Forum and Search --> : Printer Sharing Win NT/2000


CJC
October 27th, 1999, 02:06 PM
I am trying to share a printer programatically in NT, but I am having some probs.
I have gotten this to work with drives, but not printers.

Here is a code snipit:

SHARE_INFO_502 theShareInfo;

theShareInfo.shi502_type = STYPE_PRINTQ;
theShareInfo.shi502_netname = wszNetName; //L"Bull"
theShareInfo.shi502_remark = wszRemark; //L"CommentText"
theShareInfo.shi502_path = wszPath; //L"Bull 1023"
theShareInfo.shi502_passwd = NULL;
theShareInfo.shi502_max_uses = SHI_USES_UNLIMITED;
theShareInfo.shi502_current_uses = dwNumConn; //0
theShareInfo.shi502_reserved = 0;
//pSD is set with one ACE: (Everyone, PRINTER_ALL_ACCESS)
theShareInfo->shi502_security_descriptor = pSD;

dwResult = NetShareAdd(NULL, 502, (LPBYTE)&theShareInfo,&dwParam);
SHChangeNotify(SHCNE_NETSHARE, SHCNF_PRINTER, lpLocalName, 0);
SHChangeNotify(SHCNE_UPDATEITEM, SHCNF_PRINTER, lpLocalName, 0);



NetShareAdd(...) returns NERR_Success.
If I call GetLastError() right after the NetShareAdd(...) call, it returns NO_ERROR as well.

The problem is that if you go look at the printer, it is not shared.

If I call NetShareEnum(...) after all of this, a share with the shareName that I passed in was ennumerated. I can also call NetShareDel(...) and it successfully unshares this phantom Printer that I am not really seeming to share.

Any ideas?