473,402 Members | 2,055 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,402 software developers and data experts.

PInvoke restriction: can not return variants

Any ideas why the following error occurs when "BuildExplicitAccessWithName"
is called?

PInvoke restriction: can not return variants

-----------------------------------------------------

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Auto, Pack:=4)> _
Public Structure EXPLICIT_ACCESS
Dim grfAccessPermissions As Integer
Dim grfAccessMode As Integer
Dim grfInheritance As Integer
Dim Trustee As TRUSTEE
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Auto, Pack:=4)> _
Public Structure TRUSTEE
Dim pMultipleTrustee As IntPtr
Dim MultipleTrusteeOperation As Integer
Dim TrusteeForm As Integer
Dim TrusteeType As Integer
Dim ptstrName As String
End Structure

Public Enum ACC_PERM
UserFullControl = &H10000000
UserExecute = &H20000000
UserRead = &H80000000
UserWrite = &H40000000
End Enum

Declare Function BuildExplicitAccessWithName Lib "advapi32.dll" Alias
"BuildExplicitAccessWithNameA" ( _
ByRef pExplicitAccess As EXPLICIT_ACCESS, _
ByVal pTrusteeName As String, _
ByVal AccessPermissions As Integer, _
ByVal AccessMode As Integer, _
ByVal Inheritance As Integer)

Const SET_ACCESS = 2&

' Inheritance Flags
Const CONTAINER_INHERIT_ACE = &H2

Const OBJECT_INHERIT_ACE = &H1

'Example to a calling Function
----------------------------------------

Public Function BuildExAcc() as EXPLICIT_ACCESS

Dim ea as EXPLICIT_ACCESS = New EXPLICIT_ACCESS()

Dim strUserName as String = "USERDOMAIN\USER" 'Replace with something valid

BuildExplicitAccessWithName(ea, strUserName, ACC_PERM.UserFullControl,
SET_ACCESS, CONTAINER_INHERIT_ACE Or OBJECT_INHERIT_ACE)

' If succesfull it will return "ea" with the "EXPLICIT_ACCESS"

Return ea
End Sub

Nov 21 '05 #1
2 8051
"Sterling" <St******@discussions.microsoft.com> schrieb:
Any ideas why the following error occurs when
"BuildExplicitAccessWithName"
is called?

PInvoke restriction: can not return variants
[...]
Declare Function BuildExplicitAccessWithName Lib "advapi32.dll" Alias
"BuildExplicitAccessWithNameA" ( _
ByRef pExplicitAccess As EXPLICIT_ACCESS, _
ByVal pTrusteeName As String, _
ByVal AccessPermissions As Integer, _
ByVal AccessMode As Integer, _
ByVal Inheritance As Integer)


'Function' -> 'Sub'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #2
Thanks very much. That was it. I wasn't paying attention. You are the man.

Sterling

"Herfried K. Wagner [MVP]" wrote:
"Sterling" <St******@discussions.microsoft.com> schrieb:
Any ideas why the following error occurs when
"BuildExplicitAccessWithName"
is called?

PInvoke restriction: can not return variants
[...]
Declare Function BuildExplicitAccessWithName Lib "advapi32.dll" Alias
"BuildExplicitAccessWithNameA" ( _
ByRef pExplicitAccess As EXPLICIT_ACCESS, _
ByVal pTrusteeName As String, _
ByVal AccessPermissions As Integer, _
ByVal AccessMode As Integer, _
ByVal Inheritance As Integer)


'Function' -> 'Sub'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #3

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

Similar topics

3
by: Brett Robichaud | last post by:
I have created a simple background thread to make one pinvoke call into a DLL I've created. My Winforms app spawns the thread in the form load event then go about it's business. The problem is...
8
by: promko | last post by:
Hi! I need to call the following unmanged method: HFCI __cdecl FCICreate( void FAR* pv) I have written the next managed declaration: public static extern IntPtr FCICreate( IntPtr pv );
5
by: vertigo | last post by:
Hello I use some win 32 API function for example: HANDLE CreateFile( LPCTSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD...
5
by: Bruce D | last post by:
I have a VB .NET appl that I'm trying to run on another machine and I keep getting errors. I'm sure it has to do with the GlobalLock()?? The error I receive is: PInvoke restrictions: can not...
3
by: msnews.microsoft.com | last post by:
Hi i am using User32.dll in Visual stdio 2005. public static extern long SetActiveWindow(long hwnd); public static extern long keybd_event(byte bVk, byte bScan, long dwFlags,
6
by: Pucca | last post by:
I have a program that originally compiles into a exe file. I changed the compile option to generate dll file. This program calls a com component. Can I use pinvoke in C# to call it? The...
0
by: mseeger | last post by:
My concrete problem is this (it is a bit special, but there may be other instances of it): I'd like to create a class for vectors (say: Vector), exporting math. methods, say v.foo(...). I'd like...
10
by: Raj | last post by:
I need a VB function to return array of collections like Private Type Employee empname as string address as string salary as integer deptno as integer End Type dim employees() as Employee
14
by: Mohamed Mansour | last post by:
Hey there, this will be somewhat a long post, but any response is appreciated! I have done many PInvoke in the past from C++ to C#, but I did PInvoke within C# not C++/CLI. Can someone explain...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.