Creating TCP/IP Port programatically [modified]
-
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
modified on Monday, February 14, 2011 6:29 AM
-
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
modified on Monday, February 14, 2011 6:29 AM
There is nothing wrong in your code and also do not turn off UAC. Try to execute you application in admin privileges. select RequireAdminstration as a property. For future reference: Google this keyword "Windows7GATrainingKitForDevelopers.Setup.exe" and run this exe. Its a training kit for developer working on Windows 7. It is awesome.
I believe in LOVE AT FIRST SIGHT... Bcoz I have loved my Mother... even since I opened my eyes...(ICAN)
-
There is nothing wrong in your code and also do not turn off UAC. Try to execute you application in admin privileges. select RequireAdminstration as a property. For future reference: Google this keyword "Windows7GATrainingKitForDevelopers.Setup.exe" and run this exe. Its a training kit for developer working on Windows 7. It is awesome.
I believe in LOVE AT FIRST SIGHT... Bcoz I have loved my Mother... even since I opened my eyes...(ICAN)
Hi, "select RequireAdminstration as a property" I have not understood the above statement. Cab you just explain me how to do this? Regards msr
-
Hi, "select RequireAdminstration as a property" I have not understood the above statement. Cab you just explain me how to do this? Regards msr
- Open Project property page Project->Property or use shortcut key (Alt + f7). 2) Select Linker->Manifest File, There is one property UAC Execution level. select this option as requireAdminstration. When you do this than your application is self elevated and run under admin privilege.
I believe in LOVE AT FIRST SIGHT... Bcoz I have loved my Mother... even since I opened my eyes...(ICAN)
-
- Open Project property page Project->Property or use shortcut key (Alt + f7). 2) Select Linker->Manifest File, There is one property UAC Execution level. select this option as requireAdminstration. When you do this than your application is self elevated and run under admin privilege.
I believe in LOVE AT FIRST SIGHT... Bcoz I have loved my Mother... even since I opened my eyes...(ICAN)
Hi, thanks for the reply. But in vs2008 there is no such option (Linker -> Manifest fie)for vc++ win32 projects. Regards msr
-
Hi, thanks for the reply. But in vs2008 there is no such option (Linker -> Manifest fie)for vc++ win32 projects. Regards msr
-
No I am able to view this property on VS2008 with win32. What are you doing ?? Please explain....
I believe in LOVE AT FIRST SIGHT... Bcoz I have loved my Mother... even since I opened my eyes...(ICAN)
But I am building a static library. I think Linker option is not applicable. Regards msr
modified on Wednesday, February 16, 2011 11:15 PM