Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
AddPort
Message
From
14/03/2005 12:14:19
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Title:
AddPort
Environment versions
Visual FoxPro:
VFP 6 SP5
OS:
Windows XP SP2
Network:
Windows NT
Database:
Visual FoxPro
Miscellaneous
Thread ID:
00995563
Message ID:
00995563
Views:
100
Hello Everybody.

anyone know how to use/code the AddPort Api? i got this so far, and it works untill the AddPort function, which errors with "The Request is not supported"
PrinterPath = "\\KICUSTSVC13\CUST1" which is a valid path to a printer (were Cust1 is the shared printer name)
LPara ;
	PrinterPath
LOCAL ;
	str_ports, ;
	buf_needed, ;
	num_ofports, ;
	num_ofbytes, ;
	addport_result, ;
	errcode, ;
	errmsg, ;
	ReturnValue

* ***	BOOL EnumPorts(
* ***	  LPTSTR pName,       // pointer to server name
* ***	  DWORD Level,        // specifies type of port info structure
* ***	  LPBYTE pPorts,      // pointer to buffer to receive array of port
* ***	                      // info. structures
* ***	  DWORD cbBuf,        // specifies size, in bytes, of buffer
* ***	  LPDWORD pcbNeeded,  // pointer to number of bytes stored into
* ***	                      // buffer (or required buffer size)
* ***	  LPDWORD pcReturned  // pointer to number of PORT_INFO_*.
* ***	                      // structures stored into buffer
DECLARE INTEGER EnumPorts IN winspool.drv;
	STRING pName, ;
	INTEGER LEVEL, ;
	STRING @pPorts, ;
	INTEGER cbBuf, ;
	INTEGER @pcbNeeded, ;
	INTEGER @pcReturned
DECLARE INTEGER AddPort IN winspool.drv;
	STRING pName, ;
	INTEGER HWND, ;
	STRING pMonitorName

str_Ports	= ""
buf_Needed	= 0
num_OfPorts	= 0
Num_OfBytes	= 0
EnumPorts(;
	0, ;
	1, ;
	@str_Ports, ;
	m.buf_Needed, ;
	@Num_OfBytes, ;
	@num_OfPorts)
str_Ports	= SPACE(m.Num_OfBytes)
buf_Needed	= m.Num_OfBytes
EnumPorts(;
	0, ;
	1, ;
	@str_Ports, ;
	m.buf_Needed, ;
	@Num_OfBytes, ;
	@num_OfPorts)

* *** should be translated and put in an array
* *** not sure yet how to do this
* *** but for right now this should work
AddPort_Result = 1
IF !UPPER(m.PrinterPath) $ upper(m.str_Ports)
	AddPort_Result = AddPort(;
		"", ;
		THISFORM.HWND, ;
		m.PrinterPath)
	
	IF m.AddPort_Result = 0
		ErrCode = GetLastError()
	ENDIF
ENDIF

IF m.AddPort_Result = 0
	* *** failed adding a port
	ErrMsg = oToolBox.oGlobalStr.ApiErrorText(m.ErrCode)
	MESSAGEBOX(TRANS(m.ErrCode) +", "+ m.ErrMsg)
	ReturnValue = .f.
else
	ReturnValue = .t.
ENDIF

Return(m.ReturnValue)
thanks for all your help!
Next
Reply
Map
View

Click here to load this message in the networking platform