|
Hi
I'm having trouble trying to load a non-default .wab file (I know it's old hat but need to keep it going for my XP users). I'm running it on Vista and although I'm supplying a filename it keeps loading my Vista Contacts instead instead of the specific wab addresses.
It must be going wrong around here (mostly stock code from the msdn sample code):
// (pszFileName is const char *)
if(m_hinstWAB)
{
// if we loaded the dll, get the entry point
//
m_lpfnWABOpen = (LPWABOPEN) GetProcAddress(m_hinstWAB, "WABOpen");
if(m_lpfnWABOpen)
{
HRESULT hr = E_FAIL;
WAB_PARAM wp = {0};
wp.cbSize = sizeof(WAB_PARAM);
wp.szFileName = (LPTSTR) (LPCTSTR) pszFileName;
// if we choose not to pass in a WAB_PARAM object,
// the default WAB file will be opened up
//
if(m_lpfnWABOpen(&m_lpAdrBook,&m_lpWABObject,&wp,0)==S_OK)
m_bInitialized = TRUE;
}
As usual, any help much appreciated.
Greg
|
|
|
|
|
Why is this conversion needed:
Member 868926 wrote: wp.szFileName = (LPTSTR) (LPCTSTR) pszFileName; ?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> If it doesn't matter, it's antimatter.<
|
|
|
|
|
Good point, well I'm now trying:
wp.szFileName = "C:\\Jim.wab";
as I know that wab exists there but it still isn't loading it.
G
|
|
|
|
|
Are you completely sure that is a correct WAB file and it is readable by the process (it has the required access rights and somesuch)?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> If it doesn't matter, it's antimatter.<
|
|
|
|
|
Yes the wab is OK. If you doubleclick it Windows asks if you want to import the addresses.
Somehow the WabOpen bit just thinks I want the default Wab (although there isn't one in Vista) and isn't getting the filename. In the original code there was a 'GetNativePath()' call which isn't available - could it be to do with how I'm passing in the file location string?
G
|
|
|
|
|
As far as i remember the documentation says it will load the default if you pass NULL for the path, but you are not passing NULL but a seemingly correct path. Hmm...
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> If it doesn't matter, it's antimatter.<
|
|
|
|
|
If i check the documentation (http://msdn.microsoft.com/en-us/library/ms629458%28v=vs.85%29.aspx[^]) for WAB_PARAM , the szFileName member is declared to be LPTSTR . This suggests that depending on your target options, it might be a unicode or an ansii/mbcs string which then suggests that there might be a unicode and an ansii/mbcs version of the function (as with a lot of API methods throughout windows). When you query the function's pointer...are you sure you are getting the correct version?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> If it doesn't matter, it's antimatter.<
|
|
|
|
|
I'm not sure - in the header file I can't see another version except WabOpenEx which I tried but didn't work.
I've noticed that my Contacts folder is actually receiving the wab addresses and getting bigger and bigger! So instead of opening the wab on its own it's adding them to the Contacts then opening those instead. Is this some undocumented Vista mechanism?
Thanks very much for everyone's conttributions so far.
G
|
|
|
|
|
Frankly, i don't know, sorry...
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> If it doesn't matter, it's antimatter.<
|
|
|
|
|
- Have you checked the actual error code returned from the
WABOpen Function? - Have you checked the documentation[^] for compatibility?
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
It doesn't return an error, just loads my Vista Contacts instead. Compatability seems OK.
|
|
|
|
|
Have you tried removing the default contacts file to see if it works then? It's a long while since I used WAB and I never actually tried using the non-default file.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
I tried that, then it just doesn't load anything.
|
|
|
|
|
Sorry, I cannot think of anything else to suggest. You could try the Microsoft forums.
One of these days I'm going to think of a really clever signature.
|
|
|
|