The specified module could not be found and This function is only valid in win32 mode
I converting my application from pocket pc to smart phone.
When I deploy my pocket pc during registry creation i get the following errors.
The specified module could not be found
This function is only valid in win32 mode
But the menu get created
After converting it to smartphone i got errors at the same places but my error message says unknown error
function for error message is
TCHAR szPrompt[1024];
0, dwError,
0,
szPrompt,
sizeof(szPrompt),
0);
if (!bRet)
lstrcpy(szPrompt, __TEXT("Unknown Error"));
MessageBox(0, szPrompt, szFn,0);*/
But menu is also not created
My registry entry are like calling card sample.
my tool menu implementation is
#include
"common.h"#include
"appext.h"#include
"ContactsExtDBProvider.h"extern
LONG g_cRefDLL;extern
HINSTANCE g_hinstDLL;const
int WM_SYNC_CONTACTS = 0x0420;const
int WM_REPORTS = 0x0422;UINT toolsIdCmd1 = 0;
UINT toolsIdCmd2 = 0;
UINT curIdCmd = 0;
UINT cmdToolsCustom = 0;
UINT cmdToolsJournal = 0;
UINT cmdToolsSales = 0;
UINT cmdToolsFax = 0;
UINT cmdToolsAdd = 0;
const
int WM_CUSTOM_FLDS = 0x0415;const
int WM_JOURNAL_FLDS = 0x0416;const
int WM_SHOW_SALES = 0x0407;const
int WM_FAX = 0x0431;const
int WM_EDIT_CONTACT_EXT = 0x0408;// **************************************************************************
// Function Name: Reset
//
// Purpose: Releases the m_pSite object
//
void
ContactsToolsMenu::Reset(){
RELEASE_OBJ( m_punkSite);
}
// **************************************************************************
// Function Name: Intialize
//
HRESULT ContactsToolsMenu::Initialize()
{
return(S_OK);}
ContactsToolsMenu::ContactsToolsMenu()
{
m_cRef = 0;
m_punkSite = NULL;
++g_cRefDLL;
}
ContactsToolsMenu::~ContactsToolsMenu()
{
Reset();
--g_cRefDLL;
}
STDMETHODIMP_(ULONG) ContactsToolsMenu::AddRef()
{
return (ULONG)InterlockedIncrement(&m_cRef);}
STDMETHODIMP_(ULONG) ContactsToolsMenu::Release()
{
ULONG cnt = (ULONG)InterlockedDecrement(&m_cRef);
if(0!=cnt)return(cnt);//delete this;return(0);}
STDMETHODIMP ContactsToolsMenu::QueryInterface(
REFIID riid,
LPVOID *ppv
)
{
if (NULL == ppv)return E_POINTER;*ppv = NULL;
if (IID_IUnknown == riid)*ppv = (LPVOID)
this;elseif (IID_IContextMenu == riid)*ppv =
static_cast<IContextMenu*>(this);elseif (IID_IObjectWithSite == riid)*ppv =
static_cast<IObjectWithSite*>(this);if (NULL != *ppv){
((IUnknown *)(*ppv))->AddRef();
return S_OK;}
return E_NOINTERFACE;}
STDMETHODIMP ContactsToolsMenu::GetCommandString(
UINT idCmd,
UINT uFlags,
UINT *pwReserved,
LPSTR pszName,
UINT cchMax
)
{
curIdCmd = idCmd;
return NOERROR;}
STDMETHODIMP ContactsToolsMenu::InvokeCommand(
LPCMINVOKECOMMANDINFO pici
)
{
HRESULT hr = NOERROR;
if (NULL == pici){
hr = E_POINTER;
}
else{
if (sizeof(CMINVOKECOMMANDINFO) != pici->cbSize){
hr = E_INVALIDARG;
}
else{
if (curIdCmd == toolsIdCmd1){
MsgSender::Send(WM_SYNC_CONTACTS);
}
elseif (curIdCmd == toolsIdCmd2){
MsgSender::Send(WM_REPORTS);
}
else{
IDataObject *pIdo;
if (FAILED(GetSite(IID_IDataObject, (void **)&pIdo))){
hr = MAKE_HRESULT(SEVERITY_ERROR, FACILITY_NULL,
ERROR_NO_SUCH_SITE);
}
else{
FORMATETC fe={0};
STGMEDIUM sm;
fe.cfFormat = RegisterClipboardFormat(CFNAME_ITEMREFARRAY);
fe.lindex = -1;
fe.dwAspect = DVASPECT_CONTENT;
fe.tymed = TYMED_HGLOBAL;
ItemRefArray *pira;
CEOID oid;
HRESULT hr = pIdo->GetData(&fe, &sm);
if (!FAILED(hr)) {pira = (ItemRefArray*)sm.hGlobal;
oid = (CEOID)pira->rgRefs[0].pRef;
//LocalFree(sm.hGlobal);ReleaseStgMedium(&sm);
}
elseoid = 0;
pIdo->Release();
if (!FAILED(hr)){
if (curIdCmd == cmdToolsCustom){
MsgSender::Send(WM_CUSTOM_FLDS, oid);
}
elseif (curIdCmd == cmdToolsJournal){
MsgSender::Send(WM_JOURNAL_FLDS, oid);
}
elseif (curIdCmd == cmdToolsSales){
MsgSender::Send(WM_SHOW_SALES, oid);
}
elseif (curIdCmd == cmdToolsFax){
MsgSender::Send(WM_FAX, oid);
}
elseif (curIdCmd == cmdToolsAdd){
MsgSender::Send(WM_EDIT_CONTACT_EXT, oid);
}
}
}
}
}
}
return hr;}
STDMETHODIMP ContactsToolsMenu::QueryContextMenu(
HMENU hmenu,
UINT indexMenu,
UINT idCmdFirst,
UINT idCmdLast,
UINT uFlags
)
{
HRESULT hr = NOERROR;
UNREFERENCED_PARAMETER(uFlags);
if (idCmdLast < idCmdFirst){
hr = E_INVALIDARG;
}
else{
IDataObject *pIdo;
// get the siteif (FAILED(GetSite(IID_IDataObject, (void **)&pIdo))){
hr = MAKE_HRESULT(SEVERITY_ERROR, FACILITY_NULL,
ERROR_NO_SUCH_SITE);
}
else{
FORMATETC fe = {0};
STGMEDIUM sm;
fe.cfFormat = RegisterClipboardFormat(CFNAME_ITEMREFARRAY);
fe.lindex = -1;
fe.dwAspect = DVASPECT_CONTENT;
fe.tymed = TYMED_HGLOBAL;
int existFlag = MF_GRAYED;hr = pIdo->GetData(&fe, &sm);
if (!FAILED(hr)) {ItemRefArray *pira = (ItemRefArray*)sm.hGlobal;
CEOID oid = (CEOID)pira->rgRefs[0].pRef;
ContactsExtDBProvider* dbContactsExt =
new ContactsExtDBProvider();if (!dbContactsExt->IsExist())dbContactsExt->CreateDB();
if (!(dbContactsExt->FindItem(oid) <= 0))existFlag = MF_ENABLED;
}
ReleaseStgMedium(&sm);
pIdo->Release();
TCHAR _szCommand1[MAX_PATH] = TEXT(
"test Custom fields...");TCHAR _szCommand2[MAX_PATH] = TEXT(
"test Journal...");TCHAR _szCommand3[MAX_PATH] = TEXT(
"test Sales...");TCHAR _szCommand4[MAX_PATH] = TEXT(
"test Fax/Email document...");TCHAR _szCommand5[MAX_PATH] = TEXT(
"test Edit additional info...");TCHAR szCommand1[MAX_PATH] = TEXT(
"test Sync...");TCHAR szCommand2[MAX_PATH] = TEXT(
"test Reports...");toolsIdCmd1 = idCmdFirst;
toolsIdCmd2 = idCmdFirst + 1;
cmdToolsCustom = idCmdFirst + 3;
cmdToolsJournal = idCmdFirst + 4;
cmdToolsSales = idCmdFirst + 5;
cmdToolsFax = idCmdFirst + 6;
cmdToolsAdd = idCmdFirst + 7;
if (InsertMenu(hmenu, 0, MF_BYPOSITION, toolsIdCmd1, szCommand1) &&InsertMenu(hmenu, 1, MF_BYPOSITION, toolsIdCmd2, szCommand2) &&
InsertMenu(hmenu, 2, MF_BYPOSITION | MF_SEPARATOR, idCmdFirst + 2, NULL) &&
InsertMenu(hmenu, 3, MF_BYPOSITION | existFlag, cmdToolsCustom, _szCommand1) &&
InsertMenu(hmenu, 4, MF_BYPOSITION | existFlag, cmdToolsJournal, _szCommand2) &&
InsertMenu(hmenu, 5, MF_BYPOSITION | existFlag, cmdToolsSales, _szCommand3) &&
InsertMenu(hmenu, 6, MF_BYPOSITION | existFlag, cmdToolsFax, _szCommand4) &&
InsertMenu(hmenu, 7, MF_BYPOSITION | existFlag, cmdToolsAdd, _szCommand5))
{
InsertMenu(hmenu, 8, MF_BYPOSITION | MF_SEPARATOR, idCmdFirst + 2, NULL);
hr = MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_NULL, 3);
}
}
}
return hr;}
STDMETHODIMP ContactsToolsMenu::GetSite(
REFIID riid,
void **ppvSite)
{
HRESULT hr = NOERROR;
if (NULL == ppvSite){
hr = E_POINTER;
}
else{
if (NULL == m_punkSite){
// no site*ppvSite = NULL;
hr = E_FAIL;
}
else{
// see if we have the requested interfacehr = m_punkSite->QueryInterface(riid, ppvSite);
}
}
return hr;}
STDMETHODIMP ContactsToolsMenu::SetSite(
IUnknown *pUnkSite
)
{
if (NULL != pUnkSite){
pUnkSite->AddRef();
}
if (NULL != m_punkSite){
m_punkSite->Release();
}
m_punkSite = pUnkSite;
return NOERROR;}
HRESULT ContactsToolsMenu::Create(IObjectWithSite** ppNew)
{
HRESULT hr = S_OK;
ContactsToolsMenu* pte = NULL;
pte =
new ContactsToolsMenu;//CBR((!pte) || (1 == pte->m_cRef));//CPR(pte);hr = pte->Initialize();
//CHR(hr);//Error:
if (FAILED(hr)){
delete(pte);}
else{
*ppNew = pte;
}
return(hr);}

