OVH Cloud OVH Cloud

VB-->C#

6 réponses
Avatar
dips
qq'un arrive t'il a mon convertire ce code vb en c#?? moi
je connais pas du tout vb...

Declare Function SetSecurityDescriptorControl
Lib "advapi32.dll" Alias "SetSecurityDescriptorControl" _
(ByRef pSecurityDescriptor As SECURITY_DESCRIPTOR, ByVal
ControlBitsOfInterest As Integer, _
ByVal ControlBitsToSet As Integer ) _
As Long

Voila merci

6 réponses

Avatar
Sébastien Curutchet
[System.RunTime.InteropServices.DllImport("advapi32.dll")]
private static extern int SetSecurityDescriptor(ref SECURITY_DESCRIPTOR
pSecurityDescriptor, short ControlBitsOfInterest, short ControlBitsToSet);

Par contre pour la structure SECURITY_DESCRIPTOR, il faut la déclarer au
préalable : je n'ai pas de doc sous la main pour expliquer comment faire une
structure en C# (structure dans le sens struct du C++). Le struct en C#
correspond au class sealed, ce qui n'est pas du tout la même chose que le
struct du C/C++.


Sebastien Curutchet.

"dips" a écrit dans le message de
news:cea101c48a6f$115ce4c0$
qq'un arrive t'il a mon convertire ce code vb en c#?? moi
je connais pas du tout vb...

Declare Function SetSecurityDescriptorControl
Lib "advapi32.dll" Alias "SetSecurityDescriptorControl" _
(ByRef pSecurityDescriptor As SECURITY_DESCRIPTOR, ByVal
ControlBitsOfInterest As Integer, _
ByVal ControlBitsToSet As Integer ) _
As Long

Voila merci



Avatar
Gilles Di Pietrantonio
Ouais merci j'ai mis ça... mais je sais pas pourquoi
quand j'utilise la fonction il dit qu'elle existe pas
alors que je la déclare sans prob... comment tu me l'as
donnée

public struct ACL
{
public byte AclRevision;
public byte Sbz1;
public int AclSize;
public int AceCount;
public int Sbz2;
}

public struct SECURITY_DESCRIPTOR
{
public byte Revision;
public byte Sbz1;
public long Control;
public long Owner;
public long Group;
public ACL Sacl;
public ACL Dacl;
}
-----Message d'origine-----
[System.RunTime.InteropServices.DllImport


("advapi32.dll")]
private static extern int SetSecurityDescriptor(ref


SECURITY_DESCRIPTOR
pSecurityDescriptor, short ControlBitsOfInterest, short


ControlBitsToSet);

Par contre pour la structure SECURITY_DESCRIPTOR, il


faut la déclarer au
préalable : je n'ai pas de doc sous la main pour


expliquer comment faire une
structure en C# (structure dans le sens struct du C++).


Le struct en C#
correspond au class sealed, ce qui n'est pas du tout la


même chose que le
struct du C/C++.


Sebastien Curutchet.

"dips" a écrit dans le message de
news:cea101c48a6f$115ce4c0$
qq'un arrive t'il a mon convertire ce code vb en c#??




moi
je connais pas du tout vb...

Declare Function SetSecurityDescriptorControl
Lib "advapi32.dll"




Alias "SetSecurityDescriptorControl" _
(ByRef pSecurityDescriptor As SECURITY_DESCRIPTOR,




ByVal
ControlBitsOfInterest As Integer, _
ByVal ControlBitsToSet As Integer ) _
As Long

Voila merci





.



Avatar
Paul Bacelar
Avec "Depends" voici la liste des fonctions de la dll advapi32 commençant
par SetSecurityDescriptor:
-SetSecurityDescriptorControl
-SetSecurityDescriptorDacl
-SetSecurityDescriptorGroup
-SetSecurityDescriptorOwner
-SetSecurityDescriptorRMControl
-SetSecurityDescriptorSacl

Il n'y a pas de fonction "SetSecurityDescriptorControl"

Paul Bacelar

"Gilles Di Pietrantonio" wrote in
message news:d14601c48a9c$b96baf70$
Ouais merci j'ai mis ça... mais je sais pas pourquoi
quand j'utilise la fonction il dit qu'elle existe pas
alors que je la déclare sans prob... comment tu me l'as
donnée

public struct ACL
{
public byte AclRevision;
public byte Sbz1;
public int AclSize;
public int AceCount;
public int Sbz2;
}

public struct SECURITY_DESCRIPTOR
{
public byte Revision;
public byte Sbz1;
public long Control;
public long Owner;
public long Group;
public ACL Sacl;
public ACL Dacl;
}
-----Message d'origine-----
[System.RunTime.InteropServices.DllImport


("advapi32.dll")]
private static extern int SetSecurityDescriptor(ref


SECURITY_DESCRIPTOR
pSecurityDescriptor, short ControlBitsOfInterest, short


ControlBitsToSet);

Par contre pour la structure SECURITY_DESCRIPTOR, il


faut la déclarer au
préalable : je n'ai pas de doc sous la main pour


expliquer comment faire une
structure en C# (structure dans le sens struct du C++).


Le struct en C#
correspond au class sealed, ce qui n'est pas du tout la


même chose que le
struct du C/C++.


Sebastien Curutchet.

"dips" a écrit dans le message de
news:cea101c48a6f$115ce4c0$
qq'un arrive t'il a mon convertire ce code vb en c#??




moi
je connais pas du tout vb...

Declare Function SetSecurityDescriptorControl
Lib "advapi32.dll"




Alias "SetSecurityDescriptorControl" _
(ByRef pSecurityDescriptor As SECURITY_DESCRIPTOR,




ByVal
ControlBitsOfInterest As Integer, _
ByVal ControlBitsToSet As Integer ) _
As Long

Voila merci





.



Avatar
Sébastien Curutchet
LOL,
c'est la première de ta liste :-)

"Paul Bacelar" a écrit dans le message
de news:%
Avec "Depends" voici la liste des fonctions de la dll advapi32 commençant
par SetSecurityDescriptor:
-SetSecurityDescriptorControl
-SetSecurityDescriptorDacl
-SetSecurityDescriptorGroup
-SetSecurityDescriptorOwner
-SetSecurityDescriptorRMControl
-SetSecurityDescriptorSacl

Il n'y a pas de fonction "SetSecurityDescriptorControl"

Paul Bacelar

"Gilles Di Pietrantonio" wrote in
message news:d14601c48a9c$b96baf70$
Ouais merci j'ai mis ça... mais je sais pas pourquoi
quand j'utilise la fonction il dit qu'elle existe pas
alors que je la déclare sans prob... comment tu me l'as
donnée

public struct ACL
{
public byte AclRevision;
public byte Sbz1;
public int AclSize;
public int AceCount;
public int Sbz2;
}

public struct SECURITY_DESCRIPTOR
{
public byte Revision;
public byte Sbz1;
public long Control;
public long Owner;
public long Group;
public ACL Sacl;
public ACL Dacl;
}
>-----Message d'origine-----
>[System.RunTime.InteropServices.DllImport
("advapi32.dll")]
>private static extern int SetSecurityDescriptor(ref
SECURITY_DESCRIPTOR
>pSecurityDescriptor, short ControlBitsOfInterest, short
ControlBitsToSet);
>
>Par contre pour la structure SECURITY_DESCRIPTOR, il
faut la déclarer au
>préalable : je n'ai pas de doc sous la main pour
expliquer comment faire une
>structure en C# (structure dans le sens struct du C++).
Le struct en C#
>correspond au class sealed, ce qui n'est pas du tout la
même chose que le
>struct du C/C++.
>
>
>Sebastien Curutchet.
>
>"dips" a écrit dans le message de
>news:cea101c48a6f$115ce4c0$
>> qq'un arrive t'il a mon convertire ce code vb en c#??
moi
>> je connais pas du tout vb...
>>
>> Declare Function SetSecurityDescriptorControl
>> Lib "advapi32.dll"
Alias "SetSecurityDescriptorControl" _
>> (ByRef pSecurityDescriptor As SECURITY_DESCRIPTOR,
ByVal
>> ControlBitsOfInterest As Integer, _
>> ByVal ControlBitsToSet As Integer ) _
>> As Long
>>
>> Voila merci
>>
>
>
>.
>




Avatar
Sébastien Curutchet
Chez moi ça compile.
Après à l'exécution c'est autre chose. Comme indiqué dans ma première
réponse le struct de C# est n'a RIEN à coir avec celui du C++. Donc tes
structures sont fausses, il faut faire attention à ça. Il y a des attributs
à utilsier mais je ne les connais pas.

Bon courage.


--
Sébastien Curutchet
MVP VB (répond aussi aux question .NET et C# : faut bien se reconvertir ;) )
Membre de la communauté dotnet.developpez.com


"Gilles Di Pietrantonio" a écrit dans
le message de news:d14601c48a9c$b96baf70$
Ouais merci j'ai mis ça... mais je sais pas pourquoi
quand j'utilise la fonction il dit qu'elle existe pas
alors que je la déclare sans prob... comment tu me l'as
donnée

public struct ACL
{
public byte AclRevision;
public byte Sbz1;
public int AclSize;
public int AceCount;
public int Sbz2;
}

public struct SECURITY_DESCRIPTOR
{
public byte Revision;
public byte Sbz1;
public long Control;
public long Owner;
public long Group;
public ACL Sacl;
public ACL Dacl;
}
-----Message d'origine-----
[System.RunTime.InteropServices.DllImport


("advapi32.dll")]
private static extern int SetSecurityDescriptor(ref


SECURITY_DESCRIPTOR
pSecurityDescriptor, short ControlBitsOfInterest, short


ControlBitsToSet);

Par contre pour la structure SECURITY_DESCRIPTOR, il


faut la déclarer au
préalable : je n'ai pas de doc sous la main pour


expliquer comment faire une
structure en C# (structure dans le sens struct du C++).


Le struct en C#
correspond au class sealed, ce qui n'est pas du tout la


même chose que le
struct du C/C++.


Sebastien Curutchet.

"dips" a écrit dans le message de
news:cea101c48a6f$115ce4c0$
qq'un arrive t'il a mon convertire ce code vb en c#??




moi
je connais pas du tout vb...

Declare Function SetSecurityDescriptorControl
Lib "advapi32.dll"




Alias "SetSecurityDescriptorControl" _
(ByRef pSecurityDescriptor As SECURITY_DESCRIPTOR,




ByVal
ControlBitsOfInterest As Integer, _
ByVal ControlBitsToSet As Integer ) _
As Long

Voila merci





.



Avatar
Paul Bacelar
Fatigué moi ;-)
Effectivement, le problème doit venir de la signature de la fonction.

Paul Bacelar

"Sébastien Curutchet" wrote in message
news:
LOL,
c'est la première de ta liste :-)

"Paul Bacelar" a écrit dans le message
de news:%
> Avec "Depends" voici la liste des fonctions de la dll advapi32


commençant
> par SetSecurityDescriptor:
> -SetSecurityDescriptorControl
> -SetSecurityDescriptorDacl
> -SetSecurityDescriptorGroup
> -SetSecurityDescriptorOwner
> -SetSecurityDescriptorRMControl
> -SetSecurityDescriptorSacl
>
> Il n'y a pas de fonction "SetSecurityDescriptorControl"
>
> Paul Bacelar
>
> "Gilles Di Pietrantonio" wrote in
> message news:d14601c48a9c$b96baf70$
> Ouais merci j'ai mis ça... mais je sais pas pourquoi
> quand j'utilise la fonction il dit qu'elle existe pas
> alors que je la déclare sans prob... comment tu me l'as
> donnée
>
> public struct ACL
> {
> public byte AclRevision;
> public byte Sbz1;
> public int AclSize;
> public int AceCount;
> public int Sbz2;
> }
>
> public struct SECURITY_DESCRIPTOR
> {
> public byte Revision;
> public byte Sbz1;
> public long Control;
> public long Owner;
> public long Group;
> public ACL Sacl;
> public ACL Dacl;
> }
> >-----Message d'origine-----
> >[System.RunTime.InteropServices.DllImport
> ("advapi32.dll")]
> >private static extern int SetSecurityDescriptor(ref
> SECURITY_DESCRIPTOR
> >pSecurityDescriptor, short ControlBitsOfInterest, short
> ControlBitsToSet);
> >
> >Par contre pour la structure SECURITY_DESCRIPTOR, il
> faut la déclarer au
> >préalable : je n'ai pas de doc sous la main pour
> expliquer comment faire une
> >structure en C# (structure dans le sens struct du C++).
> Le struct en C#
> >correspond au class sealed, ce qui n'est pas du tout la
> même chose que le
> >struct du C/C++.
> >
> >
> >Sebastien Curutchet.
> >
> >"dips" a écrit dans le message de
> >news:cea101c48a6f$115ce4c0$
> >> qq'un arrive t'il a mon convertire ce code vb en c#??
> moi
> >> je connais pas du tout vb...
> >>
> >> Declare Function SetSecurityDescriptorControl
> >> Lib "advapi32.dll"
> Alias "SetSecurityDescriptorControl" _
> >> (ByRef pSecurityDescriptor As SECURITY_DESCRIPTOR,
> ByVal
> >> ControlBitsOfInterest As Integer, _
> >> ByVal ControlBitsToSet As Integer ) _
> >> As Long
> >>
> >> Voila merci
> >>
> >
> >
> >.
> >
>
>