|
Ack, I couldn't find a "main" function in his code - added it and now it works of course!
|
|
|
|
|
Hi
I am creating a wipe utility which will wipe files, some application and system traces.
Here I want to include "WIPE OF PAGE FILE" ( in NT it is Pagefile.sys and in 9x it is WIN386.SWP) in the utility, where fill garbage value in this file.
I googled a bit about pagefile/ swap file and learned that it can be deleted at restart.
But I am not sure that how to proceed for deleting this file because pagfile is used by System, and when I try to open it ( say in WordPad) then error of sharing violation comes.
So please suggest me that how to overwrite pagefile.sys / WIN386.SWP files.
Please reply.
Thanks
--
|
|
|
|
|
AFAIK only a native app running at boot time can mess with the paging files. At other times, the paging file is in use for actual paging.
Not sure if this will help your situation, but there is a group policy setting that will make the OS zero out the page file when the system is shut down.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
Ok, but please tell me the way how to overwrite pagefile.sys file with some garbage value, because when we open this file then it gives sharing violation error.
Please reply.
Thanks
|
|
|
|
|
So if Windows has important information paged out to this file, and your program comes along and deletes the file, what becomes of the information it once contained? That does not sound like a good idea.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
Thnaks for your suggetions,
Now I m trying to move files at boot time by using MoveFileEx( ), but this function even deletes the source file ( when we give second parameter NULL) at boot time, but does not move the file .
This is the code I am using
BOOL bMove;
bMove = MoveFileEx(_T("C:\\Rajeev.txt"), _T("C:\\MovedRajeev.txt"), MOVEFILE_DELAY_UNTIL_REBOOT);
int aaa = GetLastError();
Here bMove returns 1 and aaa is 0
Please guide me that where I am wrong.
Thanks
|
|
|
|
|
rajeevktripathi wrote: Here bMove returns 1 and aaa is 0
Which means it was successful.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
yes it means it is successful but it does not move the fils at reboot.
Please give me the solution
Please reply.
Thanks
|
|
|
|
|
So does HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\PendingFileRenameOperations exist in the registry after the function returns, and is it gone when Windows is restarted?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
one more thing is that when I use
bMove = MoveFileEx(_T("C:\\PAGEFILE.SYS"), _T("C:\\MovedPAGEFILE.SYS"), MOVEFILE_DELAY_UNTIL_REBOOT);
int aaa = GetLastError();
then bMeove = 0
and aaa = 5.
Please solve my problem.
Thanks
|
|
|
|
|
rajeevktripathi wrote: and aaa = 5.
Which indicates access is denied. Do you have administrator privileges?
Why don't you just configure Wndows to do clear the page file automatically at shutdown:
Click Start
Click Control Panel
Click Administrative Tools
Click Local Security Policy
Click the "+" next to Local Policies
Click Security Options
Doubleclick "Shutdown: Clear Virtual Memory Pagefile"
Select the "Enabled" radio button
Click OK
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
Access DENIED. (and here's why)
The pagefile is a protected resource in Windows because it represents the virtual memory pool in use while Windows is running. If you could move or corrupt this resource, Windows would simply lose its mind and crash and burn.
Also, access will be restricted to this resource because it is a major security issue. If you as a user (even admin) level programmer could access the pagefile that would open Windows to password and key recovery attacks by malicious software.
NT, NT Server, XP Pro will automatically wipe the pagefile on boot and on shutdown to protect the data contents from attack.
Cheers,
- Ed.
--------------------------------
|
|
|
|
|
Now I want to get the printer status, I write the code like this:
EnumPrinters(PRINTER_ENUM_LOCAL,NULL,2,NULL,0,&pcbNeeded,&pcReturned);
pPrinterEnum =(struct _PRINTER_INFO_2A *) malloc(pcbNeeded);
EnumPrinters(PRINTER_ENUM_LOCAL,NULL,2,(LPBYTE) pPrinterEnum,pcbNeeded,&pcbNeeded,&pcReturned);
for(int i = 0; i
|
|
|
|
|
bluelzdwy wrote: pPrinterEnum[i].status;
I do not believe that status is a member of _PRINTER_INFO_2A . Use Status instead.
bluelzdwy wrote: But sadly I found It Only return zerO!
Are you saying that pcReturned is 0, or the status is 0? If the latter, that would be the expected status for a ready-to-print printer.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
First thanks for your reply,I think that Status is right as a member of _PRINTER_INFO_2A,thanks a lot.
The Status is 0,you say that would be the expected status for a ready-to-print printer.However I still have some doubt,if The printer is printing ,the status is 0 too!
|
|
|
|
|
bluelzdwy wrote: if The printer is printing ,the status is 0 too!
That would indicate a problem, as I'd expect PRINTER_STATUS_PRINTING in that scenario.
What is the value of the pPrinterName member?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
First thanks for your reply again.
The value of the pPrinterName is " HP LaserJet 1022 " And I can get the member Attributes correctly. So It puzzles me if the printer don't support the member Status?
-- modified at 20:39 Thursday 20th April, 2006
|
|
|
|
|
bluelzdwy wrote: ...if the printer don't support the member Status?
To verify this a bit further, try turning the printer off or removing the paper and see if the status is still 0. Do you have another printer that you can test with?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
how to use TRACE function in console win app, if we include afxwin.h for this function then comes a lot of unresolved
app error LNK2005: "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) already defined in libcpd.lib(newop.obj)
app error LNK2005: "void * __cdecl operator new[](unsigned int)" (??_U@YAPAXI@Z) already defined in libcpd.lib(newaop.obj)
app error LNK2019: unresolved external symbol __beginthreadex referenced in function "public: int __thiscall CWinThread::CreateThread(unsigned long,unsigned int,struct _SECURITY_ATTRIBUTES *)" (?CreateThread@CWinThread@@QAEHKIPAU_SECURITY_ATTRIBUTES@@@Z)
app error LNK2019: unresolved external symbol __endthreadex referenced in function "void __stdcall AfxEndThread(unsigned int,int)" (?AfxEndThread@@YGXIH@Z)
9ine
|
|
|
|
|
TRACE is a MFC macros.
Check radio button "An application that supports MFC" on step 1 of 1 while creating console application.
|
|
|
|
|
Can we do it after app was created? it is nasty to recreate existing one completely.
if there are also similar TRACE like in STD or win libs?
9ine
|
|
|
|
|
see your project settings
in the C/C++ section, there might be some "MFC support" to enable
|
|
|
|
|
use api
OutputDebugString. You need to include windows.h for this.
|
|
|
|
|
yes it works, and in proj settings there is additional MFC libs usage combo box
9ine
|
|
|
|
|
We have an application developed in Windows 2000. When we run the same application on Windows XP with exactly same environment, there is a drastic increase in CPU Usage. Say if it was 15% on Windows 2000, now its 50% on Windows XP.
Application has few components communicating through DCOM and few Win32 Dlls. Any hint how can i trace which portion of code is taking too much CPU on Windows XP. Any easy to get profiling tool? any other way?
Any help would be really appreciated.
Regards
Muhammad Shoaib Khan
http://geocities.com/lansolution
|
|
|
|