Thursday, June 27, 2013

Get memory usage info

In this post I will show you how to log your current memory usage in a process. Our main function to get required information is “GetProcessMemoryInfo()” function, which is defined in psapi.h(Process Status API). After you include psapi.h in your code file, you have to link psapi.lib to your project. Otherwise you will get a linker error.
#include "psapi.h"

  PPROCESS_MEMORY_COUNTERS pMemCountr = new PROCESS_MEMORY_COUNTERS;
    if(GetProcessMemoryInfo(GetCurrentProcess(),pMemCountr,
             sizeof(PROCESS_MEMORY_COUNTERS)))
{
printf("%l",pMemCountr->PagefileUsage/1024)
}
    delete pMemCountr;

Thursday, June 20, 2013

error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

Error 1 error C2146: syntax error : missing ';' before identifier 'm_xxx' D:\Workdir\*.h 51
Error 2 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int D:\Workdir\*.h 51 1

I got these error when I try  using Poco library with Fltlib together,

What I did is : I build the poco library sample fine.
                        I build the minifilter  sample  fine.

  I want create my project, merge these 2 project together, I meet an issue is Platform toolset is different.  I try find the way it worked.  using Platform  toolset v110. 

but got these 2 exception.   the type missing is defined in "fltuserstruct.h", 

Why merge got exception...

Finally , I found I need put include "fltUser.h" ahead of poco*.h 

It is good to find something work.



Tuesday, June 18, 2013

About Redirect or Change Print Stream

One of my friends told me he worked on a project, the requirement is change the print content, but could not change the print source program yesterday. I remember I did similar project before also need change print content, it was a translate print result. The original print is English version, the client want all label change to Chinese. What I did is create a Txt Printer, then monitor the printed files change, open the print result files, output new translate result.

I think this is a simple solution for change the print content. Hope my friend do a good job!

Friday, June 14, 2013

c++ LRU Cache

I am looking for c++ implement LRU cache recently,
found POCO C++ library is very useful.  And it include different types Cache class we can use:

http://pocoproject.org/slides/140-Cache.pdf

LRUCache,
ExpireCache
ExpireLRUCache  etc.






 

Tuesday, June 11, 2013

Cannot open your default e-mail folders. You must connect to Microsoft Exchange with the current profile before you can synchronize your folders with your Outlook data file (.ost)

Cannot open your default e-mail folders. You must connect to Microsoft Exchange with the current profile before you can synchronize your folders with your Outlook data file (.ost)

I got this error when my new colleague test out exchange routing agent. He created new test user got this error, mine was connect to  exchange before, and at the same time mine is working.

We did not think the problem is exchange server side issue, search a lot fix blog, none is fit us.

Finally, I check exchange server, there are 1 service mark as automate start but did not run.  just start the service.  every thing is fine.

There are some blog said check the  exchange service first,  this is important.


Tuesday, June 4, 2013

How to indentify a SID is wellknown sid or not

In my project, I need identify a SID is wellknown sid or not. I found a function to do it.

Well-known SIDs
http://msdn.microsoft.com/en-us/library/windows/desktop/aa379649(v=vs.85).aspx
Well-known-sid-type enumeration
http://msdn.microsoft.com/en-us/library/windows/desktop/aa379650(v=vs.85).aspx

IsWellKnownSid function
http://msdn.microsoft.com/en-us/library/windows/desktop/aa379154(v=vs.85).aspx
BOOL WINAPI IsWellKnownSid(
  _In_  PSID pSid,
  _In_  WELL_KNOWN_SID_TYPE WellKnownSidType
);