|
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.
|
|
|
|
|
I have the following code:
FILE *fp = stdin;
if ((fp = fopen(argv[optind], "rb")) == NULL) {
printf("Cannot open file %s\n", argv[optind]);
return 2;
}
It executes correctly and the correct file is accessed.
I added the following to get the file size:
SizeLow = GetFileSize(_fileno(fp), & SizeHigh);
if ((SizeLow == 0xFFFFFFFF) && ((Error = GetLastError()) != NO_ERROR)) {
printf("Cannot read file size for %s, error %d\n", argv[optind], Error);
help();
return 2;
}
if (binary && (SizeHigh > 0x70000000)) {
printf("File too big for Binary Mode\n");
help();
return 2;
}
__asm {
mov eax,SizeLow
mov edx,SizeHigh
cmp binary,TRUE
jnz Bytes
shld edx,eax,3
shl eax,3
Bytes:
mov DWORD PTR totalc,eax
mov DWORD PTR totalc+4,edx
}
When I execute I get the following:
ent.exe f:\tst1.tst >ent1.txt
Cannot read file size for f:\tst1.tst, error 6
What am I doing wrong with the the GetFileSize call?
In case you are wondering, this is a modification to John Walker's ENT to speed up execution for huge files.
Dave.
|
|
|
|
|
GetFileSize() expects a file HANDLE but you are passing a file descriptor returned by _fileno() . This is indicated by the error code 6 ERROR_INVALID_HANDLE .
See A Handy Guide To Handling Handles[^] for the differences and how to convert between the various file handle types.
|
|
|
|
|
Jochen,
Thank you for the excellent reference. Just what I needed.
Dave.
|
|
|
|
|
Jochen,
With this line, everything works correctly:
SizeLow = GetFileSize(_get_osfhandle(_fileno(fp)), & SizeHigh);
Thanks for the pointer.
Dave.
|
|
|
|
|
Hi
While launching a MFC application(.exe) as OLE server, some time CWinApp::OnFileNew() gets failed; due to this frame window cannot be created and handle to the main window (m_pMainWnd) becomes NULL and error message "Error occurs in mfc42.dll" appeared.
At windows XP, CWinApp::OnFileNew() failed in 1 out of 100 times.
We have not implemented the OnFileNew() in our application; we are using default implementation of OnFileNew().
As per MSDN CWinApp::OnFileNew implements this command differently depending on the number of document templates in the application. If there is only one CDocTemplate, CWinApp::OnFileNew will create a new document of that type, as well as the proper frame and view class.
Problem occurs only at one system and frequency is one out of 100 and error message "Error occurs in mfc42.dll" appeared.
Thank You
Ashish Kumar verma
Software Engineer(VC++)
|
|
|
|
|
From your information it is rather impossible to guess what is wrong. But I will give you some notes that may help you to find the problem or enhance your question:
"Error occurs in mfc42.dll" seems to be an application specific error message (googling the exact term gives only a few results). So you should be able to locate the executed source sections before the error occurs.
Even when using the default implementation of OnFileNew() , virtual functions of your document class are involved. In this case I would especially check OnNewDocument() . When this returns FALSE , creation of the document and frame window will be stopped (see the MFC sources for CSingleDocTemplate::OpenDocumentFile() ).
|
|
|
|
|
I ran into a small problem using Visual Studio 2012 Update 1.
Any MFC dialog that has controls with icons or bitmaps does not show the graphics if it is the first one in z-order. The following controls are displayed correctly.
A simple way to demonstrate this bogus behavior is to generate a dialog application with a couple of MFC EditBrowse Controls (but you could use MFC Buttons with icons as well). You can arbitratily change the z-order of the controls with the result that the icon does not display for the first one (preview is ok but not the compiled application).
I don't know whether this problem occurs in other versions of VS or if I have overlooked something important like proper initialization.
A simple way to get around this problem is to add a control with a picture at z-order 1 and make it invisible such that subsequent controls are not affected.
Has anybody dealt with this before?
_jg_
|
|
|
|
|
Hi, I am a novice in programming on RTOS.
I have a question about the task function design. For example, the system tick is 10ms,
if one task can't finish a loop within 10 ms (do one function in one loop), then how can I guanrantee the funciton's run time?
I mean, the time it start, and the time it stop?
|
|
|
|
|
Your question is pretty valgue as there are a lot of RTOS's out there. A guess, is to put the function in its own thread and make the thread a higher priority than all others so it would not be preempted. Prioritization can be a tricky business though.
|
|
|
|
|
Not being sarcastic, but check out this article on Wikipedia: http://en.wikipedia.org/wiki/Real-time_operating_system[^]
HOW the RTOS you are using schedules threads is very important. Many (most?) RTOSs can't actually guarantee a function's run time; they simply run fast enough that with proper programming you can get close enough. Something that takes over 10ms will almost always fall into this latter category since writing a function to use such an exact amount of time is essentially impossible (hardware interrupts alone on embedded system will add enough variance to cause a measurable difference in timings.)
(Here's a good article on RTOS interrupt scheduling: http://rtos.com/articles/18835[^])
modified 7-Jan-13 16:37pm.
|
|
|
|
|
Hey guys, quick question...
I am working with treeview in win32 (VC++).
I want to remove selection facility provided for treeview. Can anyone tell what window message is posted onAfterSelect Event of tree view.
PS:- List also has checkboxes. So disabling mouse click isn't an option...
Thanks in advance...
-
Varun
|
|
|
|
|