SmartPhone WM5 PInvoke

G

Guest

I have a SmartPhone WM5 application that I needed to write a few native calls
in C++ to complete a few operations that DotNet didnt seem to handle. This
application works perfect on Pocket PC Edition of Windows Mobile 5 but when I
get to the pinvoke on the SmartPhone it claims it cannot find the dll. The
exact message is:

Can't find PInvoke DLL

And I can see in file explorer that the dll is alongside the application and
the dll was properly built for SmartPhone WM 5.

Thanks in advance!
 
N

Norman Rericha

Verify the path. I could be mistaken but I thought that all DLLs were
required to be in the \Windows directory to work properly without
having to explicitly define the path.

Hope this helps.
 
G

Guest

Here is the source:

////////////////Header File

#ifdef MOBILEVOLUME_EXPORTS
#define MOBILEVOLUME_API __declspec(dllexport)
#else
#define MOBILEVOLUME_API __declspec(dllimport)
#endif

class MOBILEVOLUME_API CMobileVolume {
public:
CMobileVolume(void);
};


extern "C" {

MOBILEVOLUME_API BOOL CheckCall();
MOBILEVOLUME_API BOOL CheckCallEx(LPWSTR fileLocation);

};


////////////////cpp File

#include "stdafx.h"
#include "MobileVolume.h"
#include <windows.h>
#include <commctrl.h>

BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID
lpReserved) {
switch (ul_reason_for_call) {
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}

CMobileVolume::CMobileVolume() {
return;
}

MOBILEVOLUME_API BOOL CheckCall() {
return true;
}

MOBILEVOLUME_API BOOL CheckCallEx(LPWSTR fileLocation) {
return true;
}

////////////////cs File


[DllImport("MobileVolume.dll",EntryPoint="CheckCall",SetLastError=true)]
public static extern bool CheckCall();

if (!CheckCall()) {
MessageBox.Show("Returned False");
} else {
MessageBox.Show("Returned True");
}

The dll and the exe is signed with the developer cert and it works fine in
Pocket PC version even with it only in the application directory. as for the
SmartPhone version I have tried putting it in the Windows directory I have
tried turning on COM Register - not too sure what that is for and the help
key doesnt return anything on it.

any ideas?
 
N

Norman Rericha

Nothing is jumping out at me that would cause a problem.

Unless there is something else with SmartPhone that I am missing, the
code you supplied should work.

Can you see the file from the application? Meaning if you use
Directory.GetFiles etc .. does the file exist? Maybe the assembly is
unable to find it?
 
G

Guest

Yes I can see it in Directory.GetFiles and I can see it in explorer on my
Workstation, but I cannot see it in File Explorer on the device, I figured
this was just because there is not a show all files option on this smartphone.
 

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