Saturday, January 31, 2009

Canon A540 camera problem

Hi there

I'd like to talk about files...

I have a camera Canon A540 and when I get files to PC, they have name like img_XXXX.jpg

this is bad name for image because there is no information in the name. It doesn't contain when and where the photo was taken.

Other problem occurs when I try to remove some small defects (red ayes for example) I am losing last modification date and then I don't know when the photo was taken

If my camera is more smart I won't have this problem

So I decided to create a console application for changing file name. And the main task was to add date, time and prefix to filename. Sure I understand that if I change filename the last file  modification date would be changed. So I add a file description to do reverse operation if there is a need.


Finally I have finished the program. It was not difficult to implement but I have no free time for that game.

So about program:

NameChanger - if you need one just mail me

You should use program with arguments:

-r - recursive search in sub-folders

-d -t - rename fonded file and insert date and time in file name

-pimg - insert prefix img in file name so all you files will start from this prefix. it is convinient when you just download photos from camera and wanted a prefix (for example: my_summer_holidays )

-ejpg - rename files only with jpg extension

-iimg - ignore files started with "img"

So in general you could use this command tool like bellow:

NameChanger.exe -d -t -r -pparty -ejpg


I have used it and noticed that some files have the same file modify date and time. In this case NameChanger add a letter to the resulted name. For example if you have three files with the same date and time then you will have 

summer_2009_06_01_13_27_10.jpg

summer_2009_06_01_13_27_10A.jpg

summer_2009_06_01_13_27_10B.jpg


Friday, October 31, 2008

Windows Mobile API ToolBar

Today I'd like to make some suggestion about CCommandBar class for Windows Mobile 5.0.
You can use MFC menu wrapper class or you can use Windows WINAPI function to get access to the ToolBar


MFC class CCommandBar class has no API to access to menu items and doesn't know how to control the menu. After a brief investigation and experiments with the menu I have got a working code:
 TBBUTTON tbb;
 ::SendMessage(m_oCommandBar.GetSafeHwnd(),     TB_GETBUTTON, 1, (LPARAM)&tbb);
 HMENU hMenu=HMENU(tbb.dwData);
 if(hMenu)
 {
     ::DeleteMenu(hMenu,0,MF_BYPOSITION);

     ::InsertMenu(hMenu,0,MF_BYPOSITION, ID_MENU_FR_SHOWDETAILS, L"Show Details");
 }


Here m_oCommandBar is an instance of CCommandBar. By using windows messages you can access to WINAPI menu and create a dynamic menus :-)

Thursday, October 9, 2008

WMI database

Hi there !
I'd like to tell you about WMI
It's a pretty huge database with common API to access to the hardware/software information
It contains different information about operating system and hardware. For example computer name, TCP/IP address, DNS, and DHCP information and many other keys that are necessary for normal working.
Also, I notice that it builds as a COM service and it is available from different languages C++, C, Pascal, Visual Basic and scripts such as VBScript.
According to C++ to invoke a method we need to do a lot of work. So I show you how to use:
I have created two classes: first is for reading properties, second to invoke methods.
WMI divided to several groups and each group contain classes:
For example Network group contains NetworkAdapter, NetworkAdapterConfigurator
It's not a c++ classes. Actually, it is a description of the class which you can use with not C++ languages.

Tuesday, September 23, 2008

small annoying bugs :-(

Sometimes when you debugging a code, You don't expect a bug in project settings and you may spend hours to find it.

Here is some suggestions that may help you with it.
This is applicable to mobile development:

1. All resources line memory allocation, files, etc., you need to put in a wrapper: shared_ptr myPointer(rawPointer)

2. All unexpected behavior line "low memory" should throw an exception and exit.


class MyDataBlock
{
   char* mData;
public:
   MyDataBlock():mData(NULL){}
   MyDataBlock():mData(int size)
   {
      ASSERT(size>0,"wrong size");
      mData = new char[size];
      ASSERT(mData,"low memory");
   }

   ~MyDataBlock()
   {
      delete[] mData;
   }
}

3. Logs
  • developer logs - you must have them if there is no way to run application in debug mode. This is more applicable to OS driver development or other specific domain development.
  • when exception happen try to log stack. When application crashes it is very useful to have function calls stack. 

Thursday, July 31, 2008

Factorial calculation

Hello everyone!
Yesterday, I have implemented program that calculates 2347!.
That is the same as 1*2*...*2347
It is  really big number that holds 10000 digits
I will publish it in the next posts. One thing I observed is: I like creating really compact programs...

Tuesday, July 22, 2008

User activity

I'd like to create a user activity driver

It will have two modes:

  • in the first mode, it collects data from the user (mouse and keyboard) and store them to a local file
  • in the second mode, it reproduces data from the file so we could have a very small sized video demonstration.

Thursday, July 17, 2008

Folder monitor

I'd like to implement folder monitor. I think it should be easy because there is a Win32 API to do this.

Also, I could do this via driver...