Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
AddPort
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Title:
Environment versions
Visual FoxPro:
VFP 6 SP5
OS:
Windows XP SP2
Network:
Windows NT
Database:
Visual FoxPro
Miscellaneous
Thread ID:
00995563
Message ID:
00995974
Views:
19
>Hi Gunnar,
>
>I will be trying to use DeletePort and AddPort functions within a couple of days.
>
>The EnumPorts works Ok. Though a quick try of the DeletePort was not successful, each time it returned 50=ERROR_NOT_SUPPORTED error code. So far I'm not completely sure, is it a driver, or a print monitor or the API call itself that does not support this functionality.


Hi Anatoliy

About the DeletPort:

the following works fine, in the background, no dialog box. However, the printer must be deleted first (done manually for this test) otherwise windows re-installs the port withing 1-2 seconds. you can see that by running this test (fill in your own port name) withing 1 second twice. it will error, also when you go to printers the port will always be there. but after deleting the printer (and checking the port through enumPort or just look for it on another printer) and then running this test, the port is gone.
* *** ***************************************************************
* *** test for DeletePort
* *** ***************************************************************
* ***	BOOL DeletePort(
* ***	  LPTSTR pName,      // pointer to server name
* ***	  HWND hWnd,         // handle to window that displays dialog box
* ***	  LPTSTR pPortName   // pointer to port name
* ***	)
DECLARE INTEGER GetLastError IN kernel32
DECLARE INTEGER FindWindow ;
	IN user32.DLL ;
	STRING @, ;
	STRING @
DECLARE INTEGER DeletePort IN winspool.drv;
	STRING pName, ;
	INTEGER HWND, ;
	STRING pPortName

IF TYPE("_SCREEN.Hwnd") <> "N"
	_SCREEN.ADDPROPERTY("Hwnd", FindWindow(0, _SCREEN.CAPTION))
ENDIF

cServerName	= ""
cPortName	= "\\Print01\Plan1"
nResult		= DeletePort(m.cServerName, _Screen.HWnd, m.cPortName)
	ErrCode	= GetLastError()
?nResult
IF nResult = 0
	*ErrMsg	= oToolBox.oGlobalStr.ApiErrorText(m.ErrCode)
	*MESSAGEBOX(TRANS(m.ErrCode) +", "+ m.ErrMsg)
	?ErrCode
ENDIF

return
Previous
Reply
Map
View

Click here to load this message in the networking platform