URGENT: Access Violation when accessing the POOM IAppointment 
Author Message
 URGENT: Access Violation when accessing the POOM IAppointment

Hi all,

I am getting an access violation runtime error when i try to access the
IAppointment in POOM.

Here's the code sample:

HRESULT hr;
int nItems;
DATE  pdate;
SYSTEMTIME st;

IPOutlookApp *polApp;
IFolder *pFolder;
IPOutlookItemCollection *pItems;
IAppointment *pApp;

// Initialize COM for Pocket Outlook
if (FAILED(CoInitializeEx(NULL, 0))) return FALSE;
// Get the application object
hr = CoCreateInstance(CLSID_Application, NULL, CLSCTX_INPROC_SERVER,
IID_IPOutlookApp, (LPVOID *)&polApp);
if (FAILED(hr)) return FALSE;

// Log on to Pocket Outlook
hr = polApp->Logon(NULL);
if (FAILED(hr)) return FALSE;

// Get the version and display it in a message box
BSTR pwszVersion = NULL;
polApp->get_Version(&pwszVersion);
MessageBox(NULL, pwszVersion, TEXT("POOM Version"), MB_SETFOREGROUND |
MB_OK);

// Free the version string
SysFreeString(pwszVersion);
// Note: For Palm PC version 1.0
// polApp->SysFreeString(pwszVersion);
polApp->GetDefaultFolder(olFolderCalendar, &pFolder);
pFolder->get_Items(&pItems);
pItems->get_Count(&nItems);
gtotal = nItems;

if (nItems > 0)
{
 for (x=1; x <= nItems; x++)
 {
  pItems->Item(x,(IDispatch **) &pApp);
  pApp->get_Start(&pdate);
  pApp->get_Duration(&dwDuration);
 }

Quote:
}

polApp->VariantTimeToSystemTime(pdate,&st);
g_Current = st;

// Log off and release the Application object
pApp->Release();
pItems->Release();
pFolder->Release();
polApp->Logoff();
polApp->Release();

return TRUE;

Quote:
}

It runs fine till it hits  pItems->Item(x,(IDispatch **) &pApp);  and gives
me an access violation.  Can someone tell me what i might be doing wrong
here?

Thanks a lot for your help in advance

Mustafa



Tue, 15 Nov 2005 06:35:17 GMT  
 URGENT: Access Violation when accessing the POOM IAppointment
I don't see where you test pItems to make sure it was properly initialized.
We might assume it did because pItems->get_Count() presumably worked, but
still worth a check in the code.  Btw you shouldn't have to type cast since
IAppointment is derived from IDispatch.

--

Michael Salamone
Entrek Software, Inc.
www.entrek.com


Quote:
> Hi all,

> I am getting an access violation runtime error when i try to access the
> IAppointment in POOM.

> Here's the code sample:

> HRESULT hr;
> int nItems;
> DATE  pdate;
> SYSTEMTIME st;

> IPOutlookApp *polApp;
> IFolder *pFolder;
> IPOutlookItemCollection *pItems;
> IAppointment *pApp;

> // Initialize COM for Pocket Outlook
> if (FAILED(CoInitializeEx(NULL, 0))) return FALSE;
> // Get the application object
> hr = CoCreateInstance(CLSID_Application, NULL, CLSCTX_INPROC_SERVER,
> IID_IPOutlookApp, (LPVOID *)&polApp);
> if (FAILED(hr)) return FALSE;

> // Log on to Pocket Outlook
> hr = polApp->Logon(NULL);
> if (FAILED(hr)) return FALSE;

> // Get the version and display it in a message box
> BSTR pwszVersion = NULL;
> polApp->get_Version(&pwszVersion);
> MessageBox(NULL, pwszVersion, TEXT("POOM Version"), MB_SETFOREGROUND |
> MB_OK);

> // Free the version string
> SysFreeString(pwszVersion);
> // Note: For Palm PC version 1.0
> // polApp->SysFreeString(pwszVersion);
> polApp->GetDefaultFolder(olFolderCalendar, &pFolder);
> pFolder->get_Items(&pItems);
> pItems->get_Count(&nItems);
> gtotal = nItems;

> if (nItems > 0)
> {
>  for (x=1; x <= nItems; x++)
>  {
>   pItems->Item(x,(IDispatch **) &pApp);
>   pApp->get_Start(&pdate);
>   pApp->get_Duration(&dwDuration);
>  }
> }

> polApp->VariantTimeToSystemTime(pdate,&st);
> g_Current = st;

> // Log off and release the Application object
> pApp->Release();
> pItems->Release();
> pFolder->Release();
> polApp->Logoff();
> polApp->Release();

> return TRUE;
> }

> It runs fine till it hits  pItems->Item(x,(IDispatch **) &pApp);  and
gives
> me an access violation.  Can someone tell me what i might be doing wrong
> here?

> Thanks a lot for your help in advance

> Mustafa



Tue, 15 Nov 2005 20:45:00 GMT  
 URGENT: Access Violation when accessing the POOM IAppointment

them to null?  n yeah everything is working fine.  The thing is i tried the
same code in a small application n its working fine, but when u put it in my
application it gives me this error.



Quote:
> I don't see where you test pItems to make sure it was properly
initialized.
> We might assume it did because pItems->get_Count() presumably worked, but
> still worth a check in the code.  Btw you shouldn't have to type cast
since
> IAppointment is derived from IDispatch.

> --

> Michael Salamone
> Entrek Software, Inc.
> www.entrek.com



> > Hi all,

> > I am getting an access violation runtime error when i try to access the
> > IAppointment in POOM.

> > Here's the code sample:

> > HRESULT hr;
> > int nItems;
> > DATE  pdate;
> > SYSTEMTIME st;

> > IPOutlookApp *polApp;
> > IFolder *pFolder;
> > IPOutlookItemCollection *pItems;
> > IAppointment *pApp;

> > // Initialize COM for Pocket Outlook
> > if (FAILED(CoInitializeEx(NULL, 0))) return FALSE;
> > // Get the application object
> > hr = CoCreateInstance(CLSID_Application, NULL, CLSCTX_INPROC_SERVER,
> > IID_IPOutlookApp, (LPVOID *)&polApp);
> > if (FAILED(hr)) return FALSE;

> > // Log on to Pocket Outlook
> > hr = polApp->Logon(NULL);
> > if (FAILED(hr)) return FALSE;

> > // Get the version and display it in a message box
> > BSTR pwszVersion = NULL;
> > polApp->get_Version(&pwszVersion);
> > MessageBox(NULL, pwszVersion, TEXT("POOM Version"), MB_SETFOREGROUND |
> > MB_OK);

> > // Free the version string
> > SysFreeString(pwszVersion);
> > // Note: For Palm PC version 1.0
> > // polApp->SysFreeString(pwszVersion);
> > polApp->GetDefaultFolder(olFolderCalendar, &pFolder);
> > pFolder->get_Items(&pItems);
> > pItems->get_Count(&nItems);
> > gtotal = nItems;

> > if (nItems > 0)
> > {
> >  for (x=1; x <= nItems; x++)
> >  {
> >   pItems->Item(x,(IDispatch **) &pApp);
> >   pApp->get_Start(&pdate);
> >   pApp->get_Duration(&dwDuration);
> >  }
> > }

> > polApp->VariantTimeToSystemTime(pdate,&st);
> > g_Current = st;

> > // Log off and release the Application object
> > pApp->Release();
> > pItems->Release();
> > pFolder->Release();
> > polApp->Logoff();
> > polApp->Release();

> > return TRUE;
> > }

> > It runs fine till it hits  pItems->Item(x,(IDispatch **) &pApp);  and
> gives
> > me an access violation.  Can someone tell me what i might be doing wrong
> > here?

> > Thanks a lot for your help in advance

> > Mustafa



Wed, 16 Nov 2005 07:05:03 GMT  
 URGENT: Access Violation when accessing the POOM IAppointment
I thinki found the problem.


function call as "struct to IAppointment", while in my app is just showing
an address without this sent. next to it.  I tried init pApp to null and
it's still pointing to a strange address.

Any ideas where am i going wrong or y is it seeing this address? and y is it
not detecting that this is a struct to IAppoitment?

Please respond if anyone can help this is really important and the whole app
is waiting on this error n i have a dead line to meet.

Thanks
Mustafa

Quote:
> Hi all,

> I am getting an access violation runtime error when i try to access the
> IAppointment in POOM.

> Here's the code sample:

> HRESULT hr;
> int nItems;
> DATE  pdate;
> SYSTEMTIME st;

> IPOutlookApp *polApp;
> IFolder *pFolder;
> IPOutlookItemCollection *pItems;
> IAppointment *pApp;

> // Initialize COM for Pocket Outlook
> if (FAILED(CoInitializeEx(NULL, 0))) return FALSE;
> // Get the application object
> hr = CoCreateInstance(CLSID_Application, NULL, CLSCTX_INPROC_SERVER,
> IID_IPOutlookApp, (LPVOID *)&polApp);
> if (FAILED(hr)) return FALSE;

> // Log on to Pocket Outlook
> hr = polApp->Logon(NULL);
> if (FAILED(hr)) return FALSE;

> // Get the version and display it in a message box
> BSTR pwszVersion = NULL;
> polApp->get_Version(&pwszVersion);
> MessageBox(NULL, pwszVersion, TEXT("POOM Version"), MB_SETFOREGROUND |
> MB_OK);

> // Free the version string
> SysFreeString(pwszVersion);
> // Note: For Palm PC version 1.0
> // polApp->SysFreeString(pwszVersion);
> polApp->GetDefaultFolder(olFolderCalendar, &pFolder);
> pFolder->get_Items(&pItems);
> pItems->get_Count(&nItems);
> gtotal = nItems;

> if (nItems > 0)
> {
>  for (x=1; x <= nItems; x++)
>  {
>   pItems->Item(x,(IDispatch **) &pApp);
>   pApp->get_Start(&pdate);
>   pApp->get_Duration(&dwDuration);
>  }
> }

> polApp->VariantTimeToSystemTime(pdate,&st);
> g_Current = st;

> // Log off and release the Application object
> pApp->Release();
> pItems->Release();
> pFolder->Release();
> polApp->Logoff();
> polApp->Release();

> return TRUE;
> }

> It runs fine till it hits  pItems->Item(x,(IDispatch **) &pApp);  and
gives
> me an access violation.  Can someone tell me what i might be doing wrong
> here?

> Thanks a lot for your help in advance

> Mustafa



Sat, 19 Nov 2005 14:26:40 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Function causes access violation when called from vb (URGENT, please)

2. "Access violation" accessing a DLL

3. Problem accessing Access 2000 database using DAO. - URGENT

4. Accessing POOM from desktop device

5. Data Access tool to access MS-Access from DOS/C application

6. access violation in

7. Access violation exception in Visual studio 7.0

8. access violation due to bad CString copy ctor when porting from VC6 to VC7 (VC++.NET)

9. VB Access Violation from C DLL

10. Access Violation.

11. access violations

12. Access Violation Revisited

 

 
Powered by phpBB® Forum Software