Déclaration de SHSetFolderPath

Résolu
cs_Willi Messages postés 2375 Date d'inscription jeudi 12 juillet 2001 Statut Modérateur Dernière intervention 15 décembre 2018 - 18 mai 2006 à 15:59
cs_Willi Messages postés 2375 Date d'inscription jeudi 12 juillet 2001 Statut Modérateur Dernière intervention 15 décembre 2018 - 18 mai 2006 à 17:06
Bonjour amis CSharpiens,

D'après la msdn en vb.net je déclare SHSetFolderPath de cette manière:

Private
Declare
Unicode
Function SHSetFolderPathW
Lib
"shell32"
Alias
"#232" (
ByVal csidl
As
Integer,
ByVal hToken
As
Integer,
ByVal dwFlags
As
Integer,
ByVal pszPath
As IntPtr)
As
Integer

En C# je ne vois pas comment la déclarer.
Quelqu'un à t-il une idée ?

Merci

6 réponses

Lutinore Messages postés 3246 Date d'inscription lundi 25 avril 2005 Statut Membre Dernière intervention 27 octobre 2012 41
18 mai 2006 à 17:04
Ouaip j'ai vu ça qu'après..

[ DllImport( "Shell32.dll", CharSet = CharSet.Unicode, EntryPoint = "#232" ) ]
private static extern int SHSetFolderPath( int csidl, IntPtr hToken, uint flags, string path );
3
Lutinore Messages postés 3246 Date d'inscription lundi 25 avril 2005 Statut Membre Dernière intervention 27 octobre 2012 41
18 mai 2006 à 16:46
Salut,

Pour le dernier paramètre ça depend si la chaine est en entrée ou en entree/sortie..

[ DllImport( "Shell32.dll", CharSet = CharSet.Unicode ) ]
private static extern int SHSetFolderPath( int csidl, IntPtr hToken, uint flags, string path );
0
Lutinore Messages postés 3246 Date d'inscription lundi 25 avril 2005 Statut Membre Dernière intervention 27 octobre 2012 41
18 mai 2006 à 16:50
lol je viens de lire ça dans la MSDN.. bon attends alors..

Remarks



SHSetFolderPath is not exported by name from Shell32.dll. To use the function, you must call GetProcAddress with ordinal 231 for SHSetFolderPathA (for ANSI strings) or ordinal 232 for SHSetFolderPathW (for Unicode strings) to obtain a function pointer.



It is recommended that the paths be expressed as Unicode strings because folder names may contain Unicode characters not expressible in ANSI.
0
Lutinore Messages postés 3246 Date d'inscription lundi 25 avril 2005 Statut Membre Dernière intervention 27 octobre 2012 41
18 mai 2006 à 16:54
Ca devrait passer :

[ DllImport( "Shell32.dll", EntryPoint = "#232" ) ]
private static extern int SHSetFolderPathW( int csidl, IntPtr hToken, uint flags, string path );
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
cs_Willi Messages postés 2375 Date d'inscription jeudi 12 juillet 2001 Statut Modérateur Dernière intervention 15 décembre 2018 22
18 mai 2006 à 17:02
Sa aurait été simple si la déclaration pour SHSetFolderPath se faisait de cette manière en c#.
Mais il est bien dit dans la msdn que SHSetFolderPath dans Shell32 n'a pas de point d'entrée par ce nom.
C'est pourquoi j'ai utiliser l'ordinal 232 dans ma déclaration vb.
0
cs_Willi Messages postés 2375 Date d'inscription jeudi 12 juillet 2001 Statut Modérateur Dernière intervention 15 décembre 2018 22
18 mai 2006 à 17:06
Lol sa passe ta 2ième solution.
J'y comprend plus rien je l'avais déclarée de cette manière et sa ne passais pas....
Ah les mystères....
0
Rejoignez-nous