Baffled: SHGetSpecialFolderLocation throws MissingMethodExceptionon Compact Framework

M

Michael Senf

Hi,

I working on a very simple prototype to intercept file system change
messages on my Pocket PC.

When I use the SHGetSpecialFolderLocation function, I get a
MissingMethodException.

What am I doing wrong? If anybody has sample code how to receive fife system
notifiations, tat would be even better..

Here's my code:

[DllImport("shell32.dll")]
private static extern uint SHGetSpecialFolderLocation(IntPtr hWnd,
int nFolder, out IntPtr Pidl);

public static IntPtr GetPidlFromFolderID(IntPtr hWnd, int Id)
{
IntPtr pIdl = IntPtr.Zero;

uint myvalue = SHGetSpecialFolderLocation(hWnd, Id, out pIdl);

}

Thanks,

michael
 
P

Paul G. Tobey [eMVP]

Are you sure there is a shell32.dll? SHGetSpecialFolderPath is in
coredll.dll. That's actually a more-universally-available function, if you
can use it.

Paul T.
 
M

Michael Senf

Thanks for the quick reply. :=)

I tried coredll.dll too, but I get the same result. :=(

I think I need SHGetSpecialFolderLocation to call SHChangeNotifyRegister. Is
there an easier way?

THanks again,

michael


Paul G. Tobey said:
Are you sure there is a shell32.dll? SHGetSpecialFolderPath is in
coredll.dll. That's actually a more-universally-available function, if you
can use it.

Paul T.

Michael Senf said:
Hi,

I working on a very simple prototype to intercept file system change
messages on my Pocket PC.

When I use the SHGetSpecialFolderLocation function, I get a
MissingMethodException.

What am I doing wrong? If anybody has sample code how to receive fife system
notifiations, tat would be even better..

Here's my code:

[DllImport("shell32.dll")]
private static extern uint SHGetSpecialFolderLocation(IntPtr hWnd,
int nFolder, out IntPtr Pidl);

public static IntPtr GetPidlFromFolderID(IntPtr hWnd, int Id)
{
IntPtr pIdl = IntPtr.Zero;

uint myvalue = SHGetSpecialFolderLocation(hWnd, Id, out pIdl);

}

Thanks,

michael
 
P

Paul G. Tobey [eMVP]

I don't see why you would need to use SHGetSpecialFolderLocation in order to
use SHChangeNotifyRegister. Why do you think so?

Paul T.

Michael Senf said:
Thanks for the quick reply. :=)

I tried coredll.dll too, but I get the same result. :=(

I think I need SHGetSpecialFolderLocation to call SHChangeNotifyRegister. Is
there an easier way?

THanks again,

michael


Paul G. Tobey said:
Are you sure there is a shell32.dll? SHGetSpecialFolderPath is in
coredll.dll. That's actually a more-universally-available function, if you
can use it.

Paul T.

Michael Senf said:
Hi,

I working on a very simple prototype to intercept file system change
messages on my Pocket PC.

When I use the SHGetSpecialFolderLocation function, I get a
MissingMethodException.

What am I doing wrong? If anybody has sample code how to receive fife system
notifiations, tat would be even better..

Here's my code:

[DllImport("shell32.dll")]
private static extern uint SHGetSpecialFolderLocation(IntPtr hWnd,
int nFolder, out IntPtr Pidl);

public static IntPtr GetPidlFromFolderID(IntPtr hWnd, int Id)
{
IntPtr pIdl = IntPtr.Zero;

uint myvalue = SHGetSpecialFolderLocation(hWnd, Id, out pIdl);

}

Thanks,

michael
 
M

Michael Senf

I thought SHChangeNotifyRegister needs tyhe PIDL for the folder I'm
interested in.

Here's my call to SHChangeNotifyRegister:

notifyid = SHChangeNotifyRegister(
hWnd,
SHCNF.SHCNF_TYPE | SHCNF.SHCNF_IDLIST, SHCNE.SHCNE_ALLEVENTS |
SHCNE.SHCNE_INTERRUPT, WM_SHNOTIFY,
1,
ref changeentry);


where changeentry is a struct:

[StructLayout(LayoutKind.Sequential)]
public struct SHChangeNotifyEntry
{
public IntPtr pIdl;
public bool Recursively;
}

And I need to provide the pointer to iIdl.

If there is an easier way, that would be great!

Thanks so much for your help!


Paul G. Tobey said:
I don't see why you would need to use SHGetSpecialFolderLocation in order to
use SHChangeNotifyRegister. Why do you think so?

Paul T.

Michael Senf said:
Thanks for the quick reply. :=)

I tried coredll.dll too, but I get the same result. :=(

I think I need SHGetSpecialFolderLocation to call
SHChangeNotifyRegister.
Is
there an easier way?

THanks again,

michael


Paul G. Tobey said:
Are you sure there is a shell32.dll? SHGetSpecialFolderPath is in
coredll.dll. That's actually a more-universally-available function,
if
you
can use it.

Paul T.

Hi,

I working on a very simple prototype to intercept file system change
messages on my Pocket PC.

When I use the SHGetSpecialFolderLocation function, I get a
MissingMethodException.

What am I doing wrong? If anybody has sample code how to receive fife
system
notifiations, tat would be even better..

Here's my code:

[DllImport("shell32.dll")]
private static extern uint SHGetSpecialFolderLocation(IntPtr hWnd,
int nFolder, out IntPtr Pidl);

public static IntPtr GetPidlFromFolderID(IntPtr hWnd, int Id)
{
IntPtr pIdl = IntPtr.Zero;

uint myvalue = SHGetSpecialFolderLocation(hWnd, Id, out pIdl);

}

Thanks,

michael
 
P

Paul G. Tobey [eMVP]

You're passing more parameters to that call than appear in my version of the
help! I have the following prototype for the call:

BOOL WINAPI SHChangeNotifyRegister(
HWND hwnd,
SHCHANGENOTIFYENTRY* pshcne
); And the following declaration for SHCHANGENOTIFYENTRY:typedef struct
tagSHCHANGENOTIFYENTRY {
DWORD dwEventMask;
LPTSTR pszWatchDir;
BOOL fRecursive;
} SHCHANGENOTIFYENTRY;If I were you, I'd write a simple test in C/C++ and
make sure of the parameters and their meanings, then translate to C#.Paul
T."Michael Senf said:
I thought SHChangeNotifyRegister needs tyhe PIDL for the folder I'm
interested in.

Here's my call to SHChangeNotifyRegister:

notifyid = SHChangeNotifyRegister(
hWnd,
SHCNF.SHCNF_TYPE | SHCNF.SHCNF_IDLIST, SHCNE.SHCNE_ALLEVENTS |
SHCNE.SHCNE_INTERRUPT, WM_SHNOTIFY,
1,
ref changeentry);


where changeentry is a struct:

[StructLayout(LayoutKind.Sequential)]
public struct SHChangeNotifyEntry
{
public IntPtr pIdl;
public bool Recursively;
}

And I need to provide the pointer to iIdl.

If there is an easier way, that would be great!

Thanks so much for your help!


Paul G. Tobey said:
I don't see why you would need to use SHGetSpecialFolderLocation in
order
to
use SHChangeNotifyRegister. Why do you think so?

Paul T.

Michael Senf said:
Thanks for the quick reply. :=)

I tried coredll.dll too, but I get the same result. :=(

I think I need SHGetSpecialFolderLocation to call
SHChangeNotifyRegister.
Is
there an easier way?

THanks again,

michael


message Are you sure there is a shell32.dll? SHGetSpecialFolderPath is in
coredll.dll. That's actually a more-universally-available function, if
you
can use it.

Paul T.

Hi,

I working on a very simple prototype to intercept file system change
messages on my Pocket PC.

When I use the SHGetSpecialFolderLocation function, I get a
MissingMethodException.

What am I doing wrong? If anybody has sample code how to receive fife
system
notifiations, tat would be even better..

Here's my code:

[DllImport("shell32.dll")]
private static extern uint SHGetSpecialFolderLocation(IntPtr hWnd,
int nFolder, out IntPtr Pidl);

public static IntPtr GetPidlFromFolderID(IntPtr hWnd, int Id)
{
IntPtr pIdl = IntPtr.Zero;

uint myvalue = SHGetSpecialFolderLocation(hWnd, Id, out pIdl);

}

Thanks,

michael
 
P

Peter Foot [MVP]

I believe that the IntPtr in the structure is a pointer to a string
containing the full path to be watched. You could take a look at the source
for the FileSystemWatcher Alex Yakhnin wrote as part of the Smart Device
Framework:-
http://www.opennetcf.org/sourcebrow...root/Source/OpenNETCF/IO/FileSystemWatcher.cs

Or download and use the binaries:-
www.opennetcf.org/sdf/

Peter

--
Peter Foot
Windows Embedded MVP
OpenNETCF.org Senior Advisor
www.inthehand.com | www.opennetcf.org

Michael Senf said:
I thought SHChangeNotifyRegister needs tyhe PIDL for the folder I'm
interested in.

Here's my call to SHChangeNotifyRegister:

notifyid = SHChangeNotifyRegister(
hWnd,
SHCNF.SHCNF_TYPE | SHCNF.SHCNF_IDLIST, SHCNE.SHCNE_ALLEVENTS |
SHCNE.SHCNE_INTERRUPT, WM_SHNOTIFY,
1,
ref changeentry);


where changeentry is a struct:

[StructLayout(LayoutKind.Sequential)]
public struct SHChangeNotifyEntry
{
public IntPtr pIdl;
public bool Recursively;
}

And I need to provide the pointer to iIdl.

If there is an easier way, that would be great!

Thanks so much for your help!


Paul G. Tobey said:
I don't see why you would need to use SHGetSpecialFolderLocation in order to
use SHChangeNotifyRegister. Why do you think so?

Paul T.

Michael Senf said:
Thanks for the quick reply. :=)

I tried coredll.dll too, but I get the same result. :=(

I think I need SHGetSpecialFolderLocation to call
SHChangeNotifyRegister.
Is
there an easier way?

THanks again,

michael


message Are you sure there is a shell32.dll? SHGetSpecialFolderPath is in
coredll.dll. That's actually a more-universally-available function, if
you
can use it.

Paul T.

Hi,

I working on a very simple prototype to intercept file system
change
messages on my Pocket PC.

When I use the SHGetSpecialFolderLocation function, I get a
MissingMethodException.

What am I doing wrong? If anybody has sample code how to receive fife
system
notifiations, tat would be even better..

Here's my code:

[DllImport("shell32.dll")]
private static extern uint SHGetSpecialFolderLocation(IntPtr hWnd,
int nFolder, out IntPtr Pidl);

public static IntPtr GetPidlFromFolderID(IntPtr hWnd, int Id)
{
IntPtr pIdl = IntPtr.Zero;

uint myvalue = SHGetSpecialFolderLocation(hWnd, Id, out pIdl);

}

Thanks,

michael
 
M

Michael Senf

I've got this working now.

Thanks all for the help. This newsgroup rocks!

michael

Peter Foot said:
I believe that the IntPtr in the structure is a pointer to a string
containing the full path to be watched. You could take a look at the source
for the FileSystemWatcher Alex Yakhnin wrote as part of the Smart Device
Framework:-
http://www.opennetcf.org/sourcebrow...root/Source/OpenNETCF/IO/FileSystemWatcher.cs

Or download and use the binaries:-
www.opennetcf.org/sdf/

Peter

--
Peter Foot
Windows Embedded MVP
OpenNETCF.org Senior Advisor
www.inthehand.com | www.opennetcf.org

Michael Senf said:
I thought SHChangeNotifyRegister needs tyhe PIDL for the folder I'm
interested in.

Here's my call to SHChangeNotifyRegister:

notifyid = SHChangeNotifyRegister(
hWnd,
SHCNF.SHCNF_TYPE | SHCNF.SHCNF_IDLIST, SHCNE.SHCNE_ALLEVENTS |
SHCNE.SHCNE_INTERRUPT, WM_SHNOTIFY,
1,
ref changeentry);


where changeentry is a struct:

[StructLayout(LayoutKind.Sequential)]
public struct SHChangeNotifyEntry
{
public IntPtr pIdl;
public bool Recursively;
}

And I need to provide the pointer to iIdl.

If there is an easier way, that would be great!

Thanks so much for your help!


Paul G. Tobey said:
I don't see why you would need to use SHGetSpecialFolderLocation in
order
to
use SHChangeNotifyRegister. Why do you think so?

Paul T.

Thanks for the quick reply. :=)

I tried coredll.dll too, but I get the same result. :=(

I think I need SHGetSpecialFolderLocation to call SHChangeNotifyRegister.
Is
there an easier way?

THanks again,

michael


message Are you sure there is a shell32.dll? SHGetSpecialFolderPath is in
coredll.dll. That's actually a more-universally-available
function,
if
you
can use it.

Paul T.

Hi,

I working on a very simple prototype to intercept file system
change
messages on my Pocket PC.

When I use the SHGetSpecialFolderLocation function, I get a
MissingMethodException.

What am I doing wrong? If anybody has sample code how to receive fife
system
notifiations, tat would be even better..

Here's my code:

[DllImport("shell32.dll")]
private static extern uint SHGetSpecialFolderLocation(IntPtr hWnd,
int nFolder, out IntPtr Pidl);

public static IntPtr GetPidlFromFolderID(IntPtr hWnd, int Id)
{
IntPtr pIdl = IntPtr.Zero;

uint myvalue = SHGetSpecialFolderLocation(hWnd, Id, out pIdl);

}

Thanks,

michael
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top