|
-
February 15th, 2011, 05:56 AM
#1
Creating TCP/IP Port programatically
Hi, I am trying to create a TCP/IP port programatically in win32.
Here is my code.
HANDLE hXcv;PRINTER_DEFAULTS pd = {NULL, NULL, SERVER_ACCESS_ADMINISTER};TCHAR szBuf[MAX_PATH] ={0};TCHAR szMsg[512];DWORD dwLastError;::lstrcpy(szBuf, TEXT(",XcvMonitor Standard TCP/IP Port"));if(OpenPrinter(szBuf, &hXcv, &pd) != FALSE ){ OutputDebugString(TEXT("Hello. It worked....!"));}else{ dwLastError = GetLastError(); wsprintf(szMsg, TEXT("OpenPrinter return error:%d\n"), dwLastError); OutputDebugString(szMsg);}> But the problem is OpenPrinter API failing and returning
error code as 5 (ERROR_ACCESS_DENIED).
> But when I try to create the port manually (print properties), port is created.
> I have logged in as an administrator and I have all permissions.
I am working on Windows Server 2008 R2 Statndard (64 bit OS)
Note: OpenPrinter API working fine if I turn-OFF User Account Settings (UAC). Failing if UAC is ON
Please tell me what's wrong with my code.
Thank you in advance.
Regards
msr
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
|