Splitting CString to array in MFC



The following function converts string to array in MFC & ATL. By default it trims each string in the array and also ignores empty strings. It uses CString MFC class and CAtlArray ATL class.

//converts semicolon separated string to array of strings
void StringToArray(CString & strValue, CAtlArray<CString> & arrValue, TCHAR szSeparator, BOOL bTrim/*=TRUE*/, BOOL bIgnoreEmptyString/*=TRUE*/)
{
	int idx;
	CString strTemp,strRest;
 
	strRest = strValue;
 
	if (strRest.IsEmpty()) {
		arrValue.RemoveAll();
		return;
	}
	do
	{
		idx = strRest.Find(szSeparator);
 
		if (idx != -1)
		{
			//take the left part
			strTemp = strRest.Left(idx);
 
			if (bTrim)
			{
				strTemp.Trim();
			}
 
			if ( (bIgnoreEmptyString) && strTemp.IsEmpty() )
			{
				//ignore
			}else
			{
				arrValue.Add(strTemp);
			}
 
			strRest = strRest.Right(strRest.GetLength()-idx-1);
 
		}else
		{
			if (bTrim)
			{
				strRest.Trim();
			}
 
			if (!strRest.IsEmpty())
			{
				//this is the last element, so lets add it
				arrValue.Add(strRest);
			}
		}
 
	}while(idx != -1);
 
}


Tracking your software downloads using setup filename



Measuring your marketing campaign is utmost necessary to determine the success of your campaign.

In order to measure, you need to track various factors. When you are selling a downloadable software, one such factor is the website from which your software was downloaded.

There are several software download sites where you can publish your software. Such as download.com, softonic, softpedia etc. When someone purchases your software, how will you determine from which website he had downloaded your product? Very few websites have javascript based tracking methods. The disadvantage is that tracking is available only when you advertise on that particular download website.

Today I will show you one trick. The trick is to name the setup file name with a tracking code and track it till product purchase. I implemented this today for my sticky notes app – Notezilla.

Step 1:

If the setup file name is NotezillaSetup.exe, just suffix it with a code like NotezillaSetup(s101).exe

Step 2:

In the setup program that you use, parse the setup file name, pick the tracking code and save it in registry or an INI file during installation of the product.

I use Inno Setup. Here is the Inno Setup script I used to parse and save it to INI file during installation.

function GetDownloadSource(Param: String) : String;
var
setupFileName : String;
stringPos : Integer;
downloadSourceName : String;
Begin
 
  //The following code is to find the source of download file
  //from the file name itself. For example if the file name is NotezillaSetup(s100).exe 
  //then we will get s100 from the file name
  setupFileName := ExtractFileName(ExpandConstant('{srcexe}'));
  stringPos := Pos('(s', setupFileName);
  if (stringPos > 0) Then
  Begin
       //+1 ignores ( character
       downloadSourceName := Copy(setupFileName, stringPos+1, Length(setupFileName)); 
       stringPos := Pos(')', downloadSourceName);
       if (stringPos > 0) Then
       Begin
              //remove all characters after ) closing bracket so that
              //finally we get a string of within the () brakets
              Delete(downloadSourceName, stringPos, Length(downloadSourceName));
       End;
  End;
 
  Result := downloadSourceName;
 
End;

In the INI file, now you used the above function GetDownloadSource

[INI]
Filename: "{userappdata}\Conceptworld\Notezilla\Notezilla.ini"; Section: "General"; Key: "DownloadSource"; String: "{code:GetDownloadSource}";

Step 3:

In your software, you will have various locations where you take the user to your website. Like Buy Now button, Website button, Online Help.

You need to suffix the tracking code to all the urls that take the user to your website.

Example:

Old Url: http://www.conceptworld.com/Notezilla
New Url: http://www.conceptworld.com/Notezilla?downloadTrackingCode=s101

Step 4:

Now modify your website code (client or server side) to read this tracking code and save it to cookie or session variable.

Step 5:

On your order page, take the tracking code from the cookie/session variable and append to your order urls. All e-commerce websites allow you pass additional data so that you can track your order. Configure your e-commerce server provider to save this additional data and send it to you on successful order completion. Usually it is through IPN (Instant Payment Notification).

That’s it.

You can see how useful this tracking method can be. You simply have to change the setup file name and provide a different url to the download website. This way you can plan your marketing strategies. Where to spend more money on advertisement, where you stop spending more money etc.

I hope you got an idea how to go about it. If you have any questions, please post them below in comments section.



What would Buddha do? – Borrow or buy this book online



[Borrow Book]

[Buy Book]

A unique approach to Buddhism, What Would Buddha Do? shows that anyone can find guidance in Buddha’s teachings. It demonstrates how to use the advice of Buddha to become a better person at work, at home, and in society. Presented in a reader-friendly format, with each page offering a question, a Buddhist quote, and advice from the author, What Would Buddha Do? applies this question to 101 problems confronted in everyday life and reveals how Buddha’s teachings are still meaningful after 2,500 years. [Read More]



Invincible Thinking, There Is No Such Thing As Defeat – Borrow or buy this book online



[Borrow Book]

[Buy Book]

Life can be compared to the construction of a tunnel; it seems we are often obstructed by solid rock. Invincible thinking works as the powerful drill to break through this rock. When we practice it, we will never feel defeat in our lives. By savoring and practicing the philosophy in this book, and using it as your own power, you will be able to declare that there is no such thing as defeat. [Read More]



Know Thyself – Borrow or buy this book online



[Borrow Book]

[Buy Book]

You are chidananda and you will remain that. Nothing can change your being. Be in the being and know that you are the truth. You do not have to do anything to achieve Truth you are the truth! So how can you attain yourself? What can you do to know ‘you’? Just wake up and see. The whole journey is the journey of waking up from this sleep. [Read More]



Finding The Joy within You – Borrow or buy this book online



[Borrow Book]

[Buy Book]

Finding the Joy Within You is a compassionate and deeply encouraging book that speaks to all who long to know that God is real, that He is near to us at all times, and that we can live every day of our lives in intimate communion with Him. In this collection of talks, informal counsel, and personal reminiscences, Sri Daya Mata shares the guidance and inspiration she receieved as a close disciple of Paramahansa Yogananda, one of the preeminent spiritual figures of our time and author of the widely acclaimed Autobiography of a Yogi.
This anthology conveys the in-depth guidance she absorbed during her more than twenty years of day-to-day association with the great teacher: the practices and principles that lead to realization of the infinite love and joy that are hidden within every human being, just waiting to be discovered. [Read More]



Talent Is Never Enough – Borrow or buy this book online



[Borrow Book]

[Buy Book]

New York Times best-selling author Dr. John C. Maxwell has a message for you, and for today’s corporate culture fixated on talent above all else: TALENT IS NEVER ENOUGH.

People everywhere are proving him right. Read the headlines, watch the highlights, or just step out your front door: Some talented people reach their full potential, while others self-destruct or remain trapped in mediocrity. What makes the difference? Maxwell, the go-to guru for business professionals across the globe, insists that the choices people make-not merely the skills they inherit-propel them onto greatness. Among other truths, successful people know that:

Belief lifts your talent.
Initiative activates your talent.
Focus directs your talent.
Preparation positions your talent.
Practice sharpens your talent.
Perseverance sustains your talent.
Character protects your talent. . . . and more!!
It’s what you add to your talent that makes the greatest difference. With authentic examples and time-tested wisdom, Maxwell shares thirteen attributes you need to maximize your potential and live the life of your dreams.

You can have talent alone and fall short of your potential. Or you can have talent plus, and really stand out. [Read More]



Who Will Cry When You Die – Borrow or buy this book online



[Borrow Book]

[Buy Book]

Does the gem of wisdom quoted above strike a chord deep within you? Do you feel that life is slipping by so fast that you just might never get the chance to live with the meaning, happiness and joy you know you deserve? If so, then this very special book by leadership guru Robin S. Sharma, the author whose Monk Who Sold His Ferrari series has transformed the lives of thousands, will be the guiding light that leads you to a brilliant new way of living. In this easy-to-read yet wisdom-rich manual, Robin S. Sharma offers 101 simple solutions to life’s most complex problems, ranging from a little-known method for beating stress and worry to a powerful way to enjoy the journey while you create a legacy that lasts. Other lessons include “Honor Your Past,” “Start Your Day Well,” “See Troubles as Blessings” and “Discover Your Calling.” If you are finally ready to move beyond a life spent chasing success to one of deep significance, this is the ideal book for you. [Read More]



The Monk Who Sold His Ferrari – Borrow or buy this book online



[Borrow Book]

[Buy Book]

The Monk Who Sold His Ferrari: A Fable About Fulfilling Your Dreams and Reaching Your Destiny by motivational speaker and author Robin Sharma is an inspiring tale that provides a step-by-step approach to living with greater courage, balance, abundance and joy. The Monk Who Sold His Ferrari tells the extraordinary story of Julian Mantle, a lawyer forced to confront the spiritual crisis of his out-of-balance life, and the subsequent wisdom that he gains on a life-changing odyssey that enables him to create a life of passion, purpose and peace [Read More]



Profile Of The Perfect Person – Borrow or buy this book online



[Borrow Book]

[Buy Book]

The Bhagavad Gita : A Melody Divine
Michelangelo said that inside every block of stone dwells a beautiful statue.

The Bhagavad Gita is a divine song that helps unravel the beauty within you. It helps you to discover the magic potency of self-governance. It enriches you from within. Carl Jung said, Who looks outside dreams, who looks inside awakes. The world converges to that rare person who has empowered himself and tapped his inner resources. Such a person achieves success effortlessly. He is happy and evolves to his full potential. Without cultivating your inner resources you feel inadequate, incomplete. It is only with inner unfoldment that you experience true power. You are not the human being going through a spiritual experience; you are the very Spirit. The Gita brings you back to the cognition of your true potential. You become a Perfect Person. [Read More]