[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

windows firewall priviligies code problem

Posted on 2008-10-12
2
Medium Priority
?
268 Views
Last Modified: 2012-05-05
Hello Experts,
i am trying to put a useful coding regarding the windows firewall but i am getting some problem,it doesn't work.




ps
i checked with "regedit" for the right path and everything seems ok
char path[512];
char dspname[] = "Winservice";
 
 
 
int AddToWindowsFirewall(char *displayname,char * path)
{
    
    
    HKEY hKey;
    
    char filedata[MAX_PATH] = "";
 
    wsprintf(filedata,"%s:*:Enabled:%s",path,displayname);
 
    if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,"System\\ControlSet001\\Services\\SharedAccess\\Parameters\\FirewallPolicy\\StandardProfile\\AuthorizedApplications\\List",0,KEY_ALL_ACCESS,&hKey)) return 0;
    //if(RegSetValueEx(hKey,path,0,REG_SZ,(unsigned char*)filedata,sizeof(filedata),37)) 
    if(RegSetValueEx(hKey,path,0,REG_SZ,reinterpret_cast<const BYTE*>(filedata),58)) return 0;
    
    RegCloseKey(hKey);
    
}    
 
 
 
int WINAPI WinMain( HINSTANCE,  HINSTANCE, LPSTR, int)
    
 
{
  some code here
 
  AddToWindowsFirewall(dspname,path);
 
 other code here
 
 
}

Open in new window

0
Comment
Question by:kagami01
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 6

Accepted Solution

by:
ChristianWimmer earned 1200 total points
ID: 22710697
I think you need to use the Firewall COM API : http://msdn.microsoft.com/en-us/library/aa366453(VS.85).aspx
There is also an example available: http://msdn.microsoft.com/en-us/library/aa364726(VS.85).aspx

If you can read Delphi code you can also check out the whole usage of this API:
http://jedi-apilib.svn.sourceforge.net/viewvc/jedi-apilib/jwscl/trunk/source/JwsclFirewall.pas?revision=645&view=markup
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question