473,327 Members | 2,065 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Using win32 API function in C#

hello everyone,
i need to use api function named RegSetKeySecurity in my C# program.
This function require ADVAPI32.DLL, but i cannot add this reference.
I tried to use Microsoft.Win32.Registry Namespace but it doesn't give
te ability to modify Security descriptors.

Please help
thanks.
Nov 15 '05 #1
2 5178
Calling Win32 DLLs in C# with P/Invoke
http://msdn.microsoft.com/msdnmag/is...T/default.aspx
I
have noticed a trend in my programming of late, and that trend has inspired
the topic of this month's column. Recently, I have done a fair amount of
Win32® Interop in my Microsoft® .NET Framework-based apps. I am not saying
that my apps are full of custom interop code, but from time to time I bump
into a minor, but nagging, inadequacy in the .NET Framework Class Library
that can quickly be alleviated by a call into the Windows® API.
As I think about it, any feature limitation in the .NET Framework version
1.0 or 1.1 class library that is not shared by Windows doesn't come as a
huge surprise. After all, 32-bit Windows, in all of its incarnations, is a
mature operating system that has served a wide breadth of customers for over
a decade. The .NET Framework is, in comparison, a newcomer.
As an increasing developer base moves its production applications to
managed code, it seems only natural that there will be even more occasions
for developers to dip down into the underlying operating system for some
critical tidbit of functionality-at least for the time being.
Thankfully, the interop features of the common language run-time (CLR),
called Platform Invoke (P/Invoke), are very complete. In this column I am
going to focus on the practical use of P/Invoke for calling Windows API
functions. P/Invoke is used as a noun when referring to the COM Interop
functionality of the CLR and is used as a verb when referring to the use of
this feature. I am not going to address COM Interop directly because it is
paradoxically both more accessible and more complex than P/Invoke, making it
less straightforward as a column topic.
--
Greetz,
Jan
__________________________________
Read my weblog: http://weblogs.asp.net/jan
"Dov P" <dp*******@yahoo.com> schreef in bericht
news:b9**************************@posting.google.c om...
hello everyone,
i need to use api function named RegSetKeySecurity in my C# program.
This function require ADVAPI32.DLL, but i cannot add this reference.
I tried to use Microsoft.Win32.Registry Namespace but it doesn't give
te ability to modify Security descriptors.

Please help
thanks.

Nov 15 '05 #2
i need to use api function named RegSetKeySecurity in my C# program.
This function require ADVAPI32.DLL, but i cannot add this reference.
I tried to use Microsoft.Win32.Registry Namespace but it doesn't give
te ability to modify Security descriptors.


This should hopefully work

[DllImport("advapi32.dll")]
static extern uint RegSetKeySecurity(HandleRef hKey, uint
SecurityInformation, IntPtr pSecurityDescriptor);

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Karuna | last post by:
Hi everybody, I have been trying to write a simple mail script using PHP and apache on Windows XP. Eventhough the script is saying that the mail is successfully sent, I am unable get it in my...
4
by: ZhangZQ | last post by:
Is it possible to dynamicaly to local and call a function in Win32 dll(not a ..net assembly dll) in C# at run time, for example, a C# program popup a dialogbox to let use input which Win32 dll to...
34
by: Dennis | last post by:
I would like to dynamically allocate in a sub a 2 dimensional Array float *myarray = new float ; of course I get an error. How do you allocate a 2D array using the New operator? I...
5
by: Claire | last post by:
How do I use the TempFileCollection class please? The m/s halp files say i can use it to generate temp files but looking through the help files, i can't actually see an obvious method that does...
3
by: Leith Bade | last post by:
I have been trying to use the new Visual C++ Toolkit 2003 with the VC6 IDE I set up the executable, inlcude, and library directories to point to the new compilers I had to fix a few errors in the...
3
by: mehul | last post by:
Hi, I am trying to use Active Reports v1.1 (Build 1.1.0.84) in a ASP.NET application. Is it possible to use it through the COM interlop as Crystal Reports for .NET which comes built in with...
9
by: Martin Ortiz | last post by:
I want to use the Win32 API function : SendMessageToDescendants I want to use it in a VB.Net app, but I have a few questions..... 1) Can one use Win32 API functions in VB.Net 2) Is doing so a...
10
by: Bob | last post by:
Hi there, Can anyone point me to anything relating to using XP's built-in CD writing support from VB.Net... or even C#, or classic VB...? I just want to write files to the CD and finalise the...
0
by: Vidyasagara Guntaka | last post by:
Hi, I'm not able to compile libpq for Windows environment using the 8.0.0 beta 1 source tree. I got the following errors (The entire compilation output is listed below): ...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.