|
No, it doesn't work, at least according to the way I've tried to use it. The following code always returns the same values (workingset size never changes):
#include <windows.h>
void main()
{
long minn, maxx;
long nbytes=1;
while (1) {
GetProcessWorkingSetSize(GetCurrentProcess(), &minn, &maxx);
printf("%ld %ld\n", minn, maxx);
malloc(nbytes);
nbytes *= 2;
Sleep(1000);
}
}
#include <windows.h>
C:\temp>workingset
204800 1413120
204800 1413120
204800 1413120
204800 1413120
204800 1413120
204800 1413120
204800 1413120
204800 1413120
204800 1413120
204800 1413120
204800 1413120
204800 1413120
204800 1413120
204800 1413120
204800 1413120
204800 1413120
204800 1413120
204800 1413120
204800 1413120
204800 1413120
204800 1413120
204800 1413120
|
|
|
|
|
I was hoping someone could help me with a little problem I am having. I am new to COM and after a lot of research and helpful articles, I was finally able to write my first COM dll. One of the most suggested articles is the one about creating an outlook dll for office 2000. So I structed my dll around this. I used the #import for the type libs and was actually able to create my own button. I am not doing this for outlook but instead of word and excel. What I was wondering is if there is a way to know, programatically, what version of office the machine has? The #import statements are located in the stdafx.h. But is there a way to check if Office XP, then use the #import statements for Office XP and if not, use the ones for Office 2000 libs? I have looked through a lot of code and I found a complete of alot ideas but with the way the dll is put together, since I am not using the msword.h and such, they don't work for me. Can anyone give me any suggestions!!!!!!
|
|
|
|
|
You can import both of the interfaces into your DLL and then select which one to use at run-time.
Todd Smith
|
|
|
|
|
How would I do that? Since I would have to put all the #import statements in stdafx.h, it wouldn't compile unless I had both installed on my machine. It would look for MSO9.dll and MSO.dll. I am a little lost on how to do this!
|
|
|
|
|
This is what I am trying to do:
We have a very large file (over 2Gb) that has a special character at the very end that we wish to remove.
The approach I have taken is to seek the end of the file and then reading the very last line. Once I have read the last line, I manipulate this with a CString object and remove the unwanted character(s). Once I have done that, I reset the length of the file and the write out a new line which is my modified CString object.
My problem is that since the file is very large, my CFile::SetLength(...) function is bombing. I get a Bad File Seek exception everytime. This is because the size of the file, according to the CFileStatus object's m_size variable is a negative number. When I supply the modified size to SetLenth, it casts it to a LONG and the calls the Seek function. When the Seek gets called, the number becomes negative and I get an exception.
Is there a way around this? A better way of doing this perhaps?
thanks
ashish
|
|
|
|
|
did you try without MFC but in C or with STL ?
Stephane
www.exotk.org
|
|
|
|
|
Here's a complete program that should work for you (and it should be really fast!) This is pure Win32 API, no MFC or ANSI C++. As usual, you should test the heck out of it before attempting to roll with it.
HTH-
Ty
#include <Windows.h>
int main(int argc, char* argv[])
{
HANDLE hFile = NULL;
DWORD dwFileSize = 0;
DWORD dwError = 0;
__try
{
hFile = ::CreateFile(
argv[1],
GENERIC_WRITE,
FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
FILE_FLAG_RANDOM_ACCESS,
NULL);
if( hFile == INVALID_HANDLE_VALUE )
{
return 1;
}
dwFileSize = ::GetFileSize( hFile, NULL );
if( ::SetFilePointer( hFile, dwFileSize - 1, NULL, FILE_BEGIN ) != -1 )
{
if( !::SetEndOfFile( hFile ) )
{
dwError = ::GetLastError();
return dwError;
}
}
else
{
dwError = ::GetLastError();
return dwError;
}
}
_finally
{
CloseHandle( hFile );
}
return 0;
}
</code>
|
|
|
|
|
TyMatthews wrote:
This is pure Win32 API, no MFC
So why do I read "CFile" in the subject line???
Instead of telling you possible "interesting" interactions with the Win16-derived "things" and FAT, try to just search to (1, FILE_END) before setting EOF.
|
|
|
|
|
Mike Nordell wrote:
So why do I read "CFile" in the subject line???
Whoa, easy there pal... if you actually read his post, you'd see he also asked:
Is there a way around this? A better way of doing this perhaps?
All I did was offer up an alternative... a quicker and easier solution to his problem. My intention was purely to suggest looking at the Win32 API a little. I started out writing 100% in MFC. Then when the MFC classes could no longer provide the functionality I needed, I had to go elsewhere. He asked for alternatives, and I gave one. So chill out.
If someone really wants to know what's happening under the hood of CFile, just take a look at the MFC source code for CFile::Open() and CFile::Seek(). It's in VC98\MFC\SRC\FILECORE.CPP. Amazingly enough you'll find the same Win32 API code that I referenced. I'm sure if CFile had a function for SetEndOfFile, it'd be calling the exact same Win32 API code. MS didn't bother to do that. If you're worried about exception handling, just take cues from any of those CFile functions and run with it.
I don't have a Win16/FAT box to test your example. I gave up on both in 1996.
Ty
|
|
|
|
|
TyMatthews wrote:
Mike Nordell wrote:
So why do I read "CFile" in the subject line???
Whoa, easy there pal...
Ouch. I completely misread the thread and got the impression it was you that wanted a solution to a problem. Sorry Ty, my mistake. I'll try to not let it happen again.
Mumbling to myself: How the h*ll could I misread a thread like that...
|
|
|
|
|
Ahh, no worries mate
Ty
|
|
|
|
|
does anyone know how to print file.html?
I used ShellExecute(..) to print. It seems printed coz I got no error or warning.. but when you open your printer ( I paused the printer before), you won't see any file in the printer spool..
it is samething like when you right click print on file.html in window explore. nothing get printed...
is there anyway to print file.html programmatically??
thanks.
|
|
|
|
|
|
|
I have a code that uses fprintf function. The program is crashing every time it hits this function. It asks for a path to fprintf.c (can't find it anywhere). Shouldn't this file be included in the MFC libraries? Anyone has this file?!
Thanks!
Cintch
|
|
|
|
|
Post the piece of code that is calling fprintf . (Forget about the asking for a path, it is debugger stuff you don't need to care about.)
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
You forgot to ask for the CRT when you installed VisualStudio. Go back and reinstall and select C Runtime Libraries Source, which is un-checked by default in VisualStudio 6.0.
|
|
|
|
|
Is it possible to create a program that would run concurrently with any web browser and would then have the ability to grab data from the HTTP headers that is posted back to a server before it is encrypted? My purpose is not create an application that does this, however another co-worker is doing some research on any security issues related to allowing users to have a web interface to change their LAN password. We have found that even through SSL the data isn't encrypted until it is actually transports across the wire per say. If this is possible it could be a major security risk for us. Any input would be great. Thanks in advance.
Nick Parker
|
|
|
|
|
My friend and I are having a somewhat friendly conversation and would like some weigh in on the following. Back to fundamentals.
1. int a;
2. int &ra = a;
is #2 a declaration or define? I should hope there will be concensus in the answer for this question.
dand999
|
|
|
|
|
i would have called it a declaration with assignment ... so i guess a declaration
*crosses fingers*
"... and so i said to him ... if it don't dance (or code) and you can't eat it either f**k it or throw it away" sonork: 100.18128 8028finder.com
|
|
|
|
|
It is a definition.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
|
It's both a declaration and an assignment.
---------------- Shog9 ----------------
------- Drink Coca-Cola -------
---- Use SciTE ----
|
|
|
|
|
Both, declaring a variable doesn't have anything to do with initial value, but more so the memory required for it, etc. Its definition will come with the initial value. So, it's both - a definition inside the declaration.
Jeremy Falcon
Imputek
<nobr>"C# is the answer to a question nobody asked." - Chris Losinger
|
|
|
|
|
I am reading "Introduction to MFC Programming with Visual C++" by Richard M Jones.
I am learning how to handcraft MFC programs (starting with blank Win 32 Application).
When I compile, build and execute one of the examples it causes a Debug Assertion Failure (File wincore.cpp, line 3109) on exiting.
When I unmap the OnDestroy() function the program terminates normally.
Here is the offending message handler.
CMainFrame inherits publicly from CFrameWnd.
void CMainFrame::OnDestroy ( )<br />
{<br />
SetWindowText(mWindowTitle);<br />
UINT resp;<br />
resp = MessageBox ("Do you understand the material in Ch 4","Question",MB_YESNO | MB_ICONQUESTION);<br />
if (resp == IDYES)<br />
MessageBox("Good");<br />
else<br />
MessageBox("I suggest you do all the exercises.");<br />
}
Obviously the book has left out important step.
As a guess I tried ::PostQuitMessage(0); but that did not work.
Anyone know what the book is doing wrong???
|
|
|
|