Ik haal via een PInvoke de "all users" directory van het start menu op.
Dit doe ik met de volgende code:
Als ik nu lijn 20 wil aanroepen krijg ik een foutmelding. The path is not of a legal form.
De work directory veranderd niet want dit geeft wel een goed resultaat:
label2.Text = Environment.CurrentDirectory.ToString();
Wat gaat er fout of wat mis ik?
Dit doe ik met de volgende code:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| public const int CSIDL_COMMON_STARTMENU = 0x0016;
[DllImport("shell32.dll",EntryPoint="SHGetSpecialFolderLocation",ExactSpelling=false,
CharSet=CharSet.Unicode,SetLastError=true)]
static extern int SHGetSpecialFolderLocation(IntPtr hwndOwner,int nFolder,out IntPtr ppidl);
[DllImport("shell32.dll",EntryPoint="SHGetPathFromIDList",ExactSpelling=false,
CharSet=CharSet.Unicode,SetLastError=true)]
static extern int SHGetPathFromIDList(IntPtr ppidl,string nFolder);
private void button1_Click(object sender, System.EventArgs e)
{
IntPtr ir = (IntPtr)0;
IntPtr ir1;
string s = "";
SHGetSpecialFolderLocation(ir,CSIDL_COMMON_STARTMENU,out ir1);
SHGetPathFromIDList(ir1,s);
MessageBox.Show(this,s);
//label2.Text = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) +
"\\Tagger\\";
} |
Als ik nu lijn 20 wil aanroepen krijg ik een foutmelding. The path is not of a legal form.
De work directory veranderd niet want dit geeft wel een goed resultaat:
label2.Text = Environment.CurrentDirectory.ToString();
Wat gaat er fout of wat mis ik?
[ Voor 10% gewijzigd door Verwijderd op 27-04-2004 16:33 ]