Maintaining huge amounts of data

I have around 50 external hard drives, 20 internal ones (form old PCs since 1994 and until today), floppy disks, CDs, DVDs and thumb drives. After purchasing the best NAS I could find – Synology Diskstation 2415+

I started looking for NAS (Red) hard drives to fill it up. I purchased 12 x 6TB ones but recently began replacing them with 10TB each (having the potential storage size of 120TB !

NAS - snapshot

Synology offers Hybrid RAID, which allows the safety of having the data backed up in several places in case of a failure. The “price” for that is 1/3 of the storage space which is used to provide the necessary tolerance to faults and loss of data. Each drive of the 12 is part of a group of 3 (“Volume”) and you can take out and throw away one drive of the three, and yet the data will be preserved.

That doesn’t come instead of backing up the entire data, which wasn’t an easy task due to the huge amount of data to back up. Typical Cloud services allow up to 1TB (for example: Dropbox). More professional services such as Amazon allows unlimited data to be backed up for a quite expensive monthly cost per each MB.

Speaking of Dropbox, one of the advantages of using a NAS is that it can entirely replace services such as Dropbox, Google Docs, etc. You have your own cloud. You can give access to specific documents or folders, run your in-house Chat service (instead of using WhatsApp), host web sites, create your own Emailing system, FTP, etc.

Costs:

NAS                                                       $1,313.71

12 x 10TB Drives                                  $4,775.88

Total (before Tax)                               $6,089.59

You can then organize your files based on subjects, themes, types and dates.

For example, organizing all photos (or videos) by year and then by month.

Photos-Haephrati.png

Since Synology gives you the ability to create your own Cloud and avoid using external Cloud services, it is quite easy to back up all photos from your cellphone automatically. You can of course insert external USB drives and purge their data to the NAS.

I travel a lot and since my wife is a photographer, there are many camera files to back up. I carry a 4TB external drives when I travel and first backup the memory cards to the drive. Then, I upload the contents of the drive to my NAS remotely from anywhere.

Add to that tools to keep your PCs backed up, access the NAS from an iPhone and so on.

Finding data is also an important consideration. Synology provides a quite fast mechanism for finding files, including from the iPhone App. Searching for files based on a criteria can take hours, especially in my case where I have millions of files. For example, an open query for all .doc files (Word) can take 1 hour to run (found already  310,000 files and still searching…).

2018-04-27 (8).png

 

One of the advantages of Synology NAS is the ability to remotely connect to surveillance cameras, but in addition there are many possible add-on’s to use.

For example, the Video Station scans all videos stored and provide easy access from a Smart TV. Please note that there are many issues with Samsung Start TV which we own. This TV is very impressing with the curve style but has many connectivity issues. Our Surface Pro‘s can’t be projected to the TV. Other streamers such as Roku have similar issues, some of which have been resolved since. In many cases we had problems with service providers such as Netflix, HBO, CBS, NBC, etc. and in most cases they were specific to our Samsung… However when it comes to projecting videos form the NAS to our TV, that works excellent.

2018-04-27 (7).png

As for protecting your NAS from outside hacking, here are some guidelines:

  • Use SSL (I purchased an SSL certificate for my NAS)
  • Use Two Factor Authentication – its impossible to log in (even if the password is known) without operating an hardware device which generate a one-time code. Banks use it (in the US) and it can be applied to other accounts such as NAS, Gmail, Facebook, etc.
  • Other security measures such as an internal Firewall running on the NAS (which has its own OS), blocking certain ports and protocols, etc.
Advertisements

Embed a resource to a static library (nothing is impossible)

I needed to embed a resource (icon) to a static library so we can deploy just the .lib and .h files with no need to include any graphics or .rc files.

I wanted my static library to be used by any application including such that don’t have any graphic user interface, i.e. Console applications, etc.

I posted a question in Stack Overflow and Code Project and the responses were: That’s not possible…

Here is the question I have posted:

Is there a way to embed resources (such as icons, dialogs) in a c++ (Win32 API) static library? My purpose is to embed an icon in the static library in a way that functions that use LoadIcon will work as if it was a normal .exe so the main application can only link to the static library and include a header file, with no requirement to add other files such as .rc files, or .ico files, etc. Clearly the main application who uses the static library doesn’t have this resource so LoadIcon will fail, however I was wondering if there is a workaround to make it work. A static array with the icon data can work as long as the standard API calls (such as LoadIcon) will work.

To explain further, the person who will be using the static library will only have 2 files: .lib and .h and will not have any .rc file

 

Comments that followed:

“It is not possible, you can stop looking. Consider a DLL project instead.

At Code Project I was pointed to the following Stack Overflow thread:

” I read them but we wish to deploy 2 files: .lib and .h. These solutions require deploying the .rc file and having whoever uses our static library to link / include it as well.”
 
“Then there is no solution from my point of view.
The SO thread covers it all.”

Here is the solution I have found after some research I found a way. Using my method, an icon can be used as an integral part of a static library and such library can be used by any type of application, including a console one (which doesn’t have any resource segment whatsoever).

1. Icon is converted to a static array of BYTE. bin2c can be used for that.

2. Data is converted into a HICON handle. Here is how I have done that:

HICON GetIcon()
{ 
   DWORD dwTmp;
   int offset;
   HANDLE hFile;
   HICON hIcon = NULL;
   offset = LookupIconIdFromDirectoryEx(s_byIconData, TRUE, 0, 0, LR_DEFAULTCOLOR);
   if (offset != 0)
   {
      hIcon = CreateIconFromResourceEx(s_byIconData + offset, 0, TRUE, 0x00030000, 0, 0, LR_DEFAULTCOLOR | LR_DEFAULTSIZE);
   }
   return hIcon;  
}
3. GetIcon is used instead of LoadIcon.
Instead of calling:

I call

m_hIcon = GetIcon()

To test it, I created a Console application and a new static library. I added to the static library the XMessageBox class which allows using a custom icon.
The Console application just calls a function located at the static library and the icon is displayed!

See also:

Flawless Integration with PayPal

We have recently added a unique feature to Wizdome: payment processing embedded in your program using just few lines of source code.

Wizdome has a built-in payment processing engine which allows you to accept payments from any credit card holder (regardless of being a PayPal customer) and pay for unlocking your software or for specific features. As part of Datattoo Recovery, one of our other products, the customer can pay per each MB of successfully restored data.

To process payments you need to choose 2 routes:

  1. Apply as a PayPal developers and obtain your own PayPal credentials
  2. Use Wizdome credentials and receive all payments from Secured Globe, Inc.

Technically, the SG_PayPal API is used as described below. Following, your program can continue as before, while Wizdome will continue monitor the status of each payment initiated and in the event of a successful payment to a Pending Transaction, the credit (“max” value) of the associated Restriction, will be updated accordingly, so if your program checks the allowed maximum value per each per-defined Restriction, the value will become higher and your software can give additional access flawlessly.

Void InitPayPal(BOOL Sandbox, LPTSTR User, LPTSTR password, LPTSTR signature, LPTSTR successUrl, LPTSTR failedURL)

Sandbox – indicates whether you are testing your integration using PayPal's Sandbox account, or going live.

User – your PayPal user name

Password – your PayPal password

Signature – you PayPal signature

successUrl – a url leading to a web page which you wish to be shown after successful payment.

failedURL – a url leading to a web page which you wish to be shown after failed / cancalled payment.

Initiating a payment

When you wish to initiate a payment, you call

BOOL InitiatePaypalPayment(int nUnits, int PricePerUnit, LPWSTR UnitName, LPWSTR RestrictionName)

nUnits (integer) - number of unique needed to be purchased

PricePerUnit (integer) - cost per each unit (in default currency).

UnitName (string) - the name of the unit to be purchased

RestrictionName (string) - optional - the name of any restriction tied to this transaction

For example: if you would like a data recovery software to allow recovery of 15 MB for the price of $15, and provided that a Restriction named “MB_RESTRICTION” was defined, you call this function using the following parameters:

InitiatePaypalPayment(15,1,L”MB”,L”MB_RESTRICTION”);

Currency

By default the currency used for transactions is USD, however that can be changed.

Tying a transaction to a Restriction

Wizdome allows you to tie a transaction (payment) to a Restriction. When you do so, the user will be able to lift or change a Restriction by making a payment and without having to switch versions, restart your program or restart any work done by your end-users.

 

 

מניעת העתקת תוכנה באופן בלתי חוקי

בין יצרני התוכנה ופורצי התוכנה מתנהלת מלחמה ארוכת שנים ואינסופית. כל יצרן תוכנה רוצה באופן טבעי להגן על הקניין שלו ולמנוע לא רק שימוש לא מורשה בתוכנה אלא גם גניבת קוד המקור של התוכנה או העתקת אופן פעולתה, אשר באופן טבעי מוגן בעיקר במוצרים שאינם מוצרי קוד פתוח. גם תוכנת “רשומון” פרי פיתוחי משנת 1989, הוגנה על ידי פלאג הגנה של אלאדין בשם AmigaHASP אשר נמכר בהמשך לחברת אלאדין.

קיימות טכנוקות רבות למניעת הגנת תוכנה, פריצה (hacking) של תוכנה וביצוע הינדוס לאחור (reverse engineering) של קובץ התוכנה. לא ניתן לאכוף מערכת רישוי לתוכנה כאשר ניתן בקלות לעקוף מערכת זו על ידי הינדוס לאחור. לכן נעשה שימוש בטכניקות של אובפוסקציה (Obfuscation).

תהליך האובפוסקציה כרוך בשינוי קוד התוכנה באופן שיקשה על הבנתו. תהליך זה מבוצע בשתי רמות: רמת קוד המקור ורמת קובץ הריצה של התוכנה.

ברמת קוד המקור, קיימות שיטות להצפין מחרווזת, להסוות קריאות לפונקציות מערכת הפעלה ושינוי שמותיהם של משתנים ופונקציות מקומיות באופן שיקשה על הבנת ייעודם.

בשנת 2013 פרסמתי מאמר בנוגע להצפנת מחרוזות בתוכנה לצורך אובפוסקציה (זכה בפרס ראשון כמאמר הטוב ביותר ב-++C באותו חודש). במאמר מובא קוד מקור פרי פיתוח צוות הפיתוח שלנו אשר במסגרתו נעשה שימוש בהצפנת AES 256.

ראשית, אציין כי מאמר זה מתמקד בתוכנה כתובה ב-C /C++ ולא בשפות אחרות או בטכנולוגיות DOT NET אשר באופן טבעי אינן מוגנות וקיימים כלים להקשחתם.

לצורך בחינות האפשרויות לבצע אובפוסקציה ברמת קוד המקור, קיים מוצר שנחשב לטוב מסוגו של חברת Semantic Designs.

כדוגמה לקוד לפני ואחרי, מובאת באתר שלהם הדוגמה הבאה:

לפני ביצוע התהליך קוד המקור נראה כך:

 

for (i=0; i < M.length; i++){
   // Adjust position of clock hands
   var ML=(ns)?document.layers['nsMinutes'+i]:ieMinutes[i].style;
   ML.top=y[i]+HandY+(i*HandHeight)*Math.sin(min)+scrll;
   ML.left=x[i]+HandX+(i*HandWidth)*Math.cos(min);
 }

לאחר התהליך הוא ייראה כך:

for(O79=0;O79<l6x.length;O79++){var O63=(l70)?document.layers["nsM
\151\156u\164\145s"+O79]:ieMinutes[O79].style;O63.top=l61[O79]+O76+(O79*O75)
*Math.sin(O51)+l73;O63.left=l75[O79]+l77+(O79*l76)*Math.cos(O51);}

במהלך תהליך זה נתמכות הפעולות הבאות, כל אחת תורמת את חלקה להפיכת הקוד לבלתי ניתן להבנה:

  • Output encoding in ASCII, European ASCII, or UNICODE
  • No changes to the your C++ compilation or execution procedurs or environment
  • User definable list of preserved names
  • Predefined list of reserved identifiers for C++ standard libraries provided
  • Can preserve most preprocessor conditionals and macro calls in obfuscated source
  • Option to neatly format C++ source code to aid development before obfuscation.
  • Output encoding in ASCII, European ASCII, or UNICODE
  • Command line and GUI interfaces

 לעומת זאת, ברמה הבינארית של קובץ הריצה של התוכנה, התהליך מתבצע בשתי צורות עיקריות:

1. ביצוע שינויים ברמה הבינארית ועם זאת מבלי לפגוש במבנה של הקובץ (משום שפגיעה משמעותית במבנה הקובץ תהפוך אותו ללא קריא למערכת ההפעלה).

2. שימוש ב-Loader

הדרך הראשונה אפשרית באופן מוגבל, כאמור בשל הצורך לשמר את מבנה הקובץ באופן שיאפשר ריצתו. ברגע שהופכים קובץ ריצה (exe) לקובץ לגמרי אחר, ככל שיהיה מוגן ומוצפן, מערכת ההפעלה לא תזהה אותו ולא תריץ אותו.

הדרך השניה מבוססת על הצפנת קובץ הריצה כולו, והפעלתו על ידי תוכנה קטנה הטוענת את המידע המוצפן בזמן ריצה, פותחת את ההצפנה ומריצה אותו. שיטה זו מסורבלת ומקשה על עידכונים, דיבוג  ותחזוקה. ובנוסף עלולה להביא לחסימה על ידי רוב האנטי וירוסים המזהים סוג כזה של הפעלה כמאפיין לנוזקות למינהן; אם בוחנים את אופן פעולה של Loader, הוא משמש כ”סוס טרויאני” אשר עם הפעלתה, פותח ושולף מתוכו את התוכנה האמיתית. סוג כזה של פעולה מתאים לנוזקות המסוות את ייעודן האמיתי אולם ככל שמדובר בתוכנה לגיטימית, תוכנה כזו תיחסם בשל אותה תבנית פעולה. מצד שני, ברמה של הגנה, שיטה זו יעילה ביותר שכן היא מאפשרת הצפנה של מרבית התוכנה. (תמיד מדובר בהצפנה של “מרבית” ולא של “כל” התכונה, זאת משום שללא החלק הלא מוצפן, לא תתפאשר הרצת התוכנה. צלילה למבנה ה-PE (המבנה אשר עומד מאחורי כל תוכנה שתרוץ ברגע שתופעל בלחיצה כפולה), מתואר במאמרים רבים כדוגמת מאמר זה.

קיימות מספר שיטות אשר שימוש בהן עשוי להקשיח את התוכנה ולהקשות על הינדוס לאחור שלה:

  • שימוש בresources מוצפנים או שימוש בבלוקי מידע מוצפנים במקום resources.
  • הצפנת מחרוזות.
  • החלפת קריאות לפונקציות מערכת ההפעלה בקריאה לפסדאו-פונקציה פנימית אשר טוענת מצביע לפונקציה האמיתית (תוך הצפנה ופתיחה בזמן ריצה של שם הפונקציה), ואז קריאה לפונקציה האמיתית.

לדוגמה

GetProcAddress(hModule,reinterpret_cast<const char*>(reinterpret_cast<int>(szName)

בנוסף נעשה שימוש בטכניקות המקשות על הפעלת כלי דיבוג (Debuggers) ואלה יפורטו להלן:

  1. בדיקות תזמון של ריצת קטעי קוד, מתוך הנחה שאם אלה רצים כאשר במקביל מופעל debugger, זמן הריצה יהיה ארוך יותר.
  2. בדיקת קיומם של debuggers ידועים לפי שם התהליך (process) שלהם.
  3. שימוש בחתימת קוד / חתימה דיגטלית אחרת של קטעי תוכנה, ואימות חתימה זו בזמן ריצה על מנת להבטיח שלא הוחלפו.

 

לדוגמה, אם התוכנה עושה שימוש ב-DLL, הוא ייחתם דיגיטלית בחתימת קוד (Code Signing Certificate). לאחר מכן, בזמן ריצה, תאומת החתימה (כמובן לא על ידי ה-DLL עצמו).

לאחרונה פיתחתי כלי סיוע לחתימת קוד וניתן להוריד כלי זה כאן.

בנוסף, למיקרוסופט יש ספריה לחתימה ואימות חתימה וניתן לקרוא עליה כאן.

תיאור זה הנו על קצה המזלג וניתן לקרוא עוד (באנגלית) בבלוג של Secured Globe, Inc ובבלוג של מערכת הגנת התוכנה שלנו.

מיכאל האפרתי Michael Haephrati

Secured Globe, Inc.

 

Free Forensics Tools

Here are free forensics tools I have added recently:

https://sourceforge.net/projects/chrome-credentials-viewer/

https://sourceforge.net/projects/firefox-credentials-viewer/

https://sourceforge.net/projects/ie-credentials-viewer/

Also you can read about these tools in the following articles:

https://www.codeproject.com/Articles/1164749/The-Secrets-of-Wi-Fi-Credentials

https://www.codeproject.com/Articles/1167954/Firefox-Credentials-Secrets

https://www.codeproject.com/Articles/1167935/The-Secrets-of-Google-Chrome-Credentials

https://www.codeproject.com/Articles/1167943/The-Secrets-of-Internet-Explorer-Credentials

How to play with the ‘date’ taken’ attribute of photos

Original article I have published at Code Project

http://www.codeproject.com/Articles/792931/Date-time-batch-changer-for-photos-and-other-files

Source code

Executable to download

Background

I recently looked for photos and videos of an important event and couldn’t understand why I can’t find any video files, even though I recalled that my wife and my daughter took both photos and videos…

I then realized that our still camera (Nokia D5000) and camcorder (Sony) are both set up with the wrong time, each with a different wrong time… One was 7 hours and 36 minutes earlier and the other was 3 hours later. That was the reason for the confusion, and I spent a lot of time checking backups, etc. thinking my precious files were somehow deleted.  I calculated the correct times of both video and photo files, adjusting their time stamp and happily found out that both occurred within the same time frame, so everything was OK. I then setup the time of the camcorder and the camera to the correct time. and looked for a way to fix the incorrect time stamps of my photos and video files. That is when I decided to program such tool myself…

Introduction

Even though there can be many occasions in which a program like the one I am about to introduce, can be useful, I originally developed it for the purpose of adjusting wrong time stamp of photos and videos, which are a result of incorrect settings or timezone in the camcoder or camera.  The idea is to define the following:

  • Path – where to look (will bring a path dialog box where the user can type or choose the start path to search. For example: c:\ or c:\users\myuser\documents\

  • Query – what to look for (for example all files ending with .AVI, or all files within a certain date, or files which contain a certain string in their name).

  • Date related attributes to apply to– which can be either:

    • Date Created
    • Date Last Modified
    • Date Last Accessed
    • Date Taken
  • Requested change – which can be either:

    • Fixed date and time, for example: 7.7.2014 01:00
    • Relative change of currently stamped date and time, for example: 7 and a half hours earlier (Dec 12, 2014 12:31AM will be adjusted to: Dec 11, 2014 5:01PM)

The Building Blocks

Searching for files based on a given criteria

Our application allows you to either state the extension of files searched for, the name (or part of it) but also to process only files having a certain date/time stamp. I will elaborate about the various attributes files have, which are date/time related in the next section, however, for the simplicity of this article, our program changes all of these attribute at once. A ComboBox is used to allow the user to make the selection among the above options.

Changing a file’s date/time related attributes

There are several attributes which are relevant for our goal, among them:

  • Date Created- The date and time in which the file was first created.
  • Date Modified- The date and time in which the file was last modified.
  • Date Accessed – The date and time in which the file was last accessed.

for photos there is another important attribute: Date Taken. That is the date and time a photo was taken.

For the purpose of the article, “photos” are identified by their extension and include .jpg and .nef (Nokia) photos, but that of course can and should be enhanced.


The Date Taken Property

The Date Taken property appears as one of the optional columns Windows Explorer allows to choose. This property is only valid for photos. Unlike the other date related file properties, this one is taken from the EXIF (Exchange Image File format) of the image file.

In order to read and manipulate the EXIF of the file, I have used exif.cpp and exif.h written by Davide Pizzolato, which based his work on jhead-1.8 by Matthias Wandel.

When a file is identified as a photo, getTakenXap is called:

Then the current “Date Taken” attribute value is used to call parseXapTime.

Calculating date and time differences

If you look at web sites like this one, you can check the possibilities covered in the code, for example changing the date/time stamp of a file so it will show 7 and a half hours backward.

To do such calculations from an application, we can use CTime for storing the time, and CTimeSpan for the calculations.

CTime

The CTime class is used to hold an absolute time and date.

Microsoft provides 7 different constructors for the CTime class which amongst others, allows you to do the following:

  1. Create a time class using a Standard Library time_t calender time.
  2. Create a time class using a dos date and time.
  3. Create a time class using a Win32 SYSTEMTIME or FILETIME
  4. Create a time class using individual entries for year, month, day, hour, minute, and second.

By incorporating the ANSI time_t data type, the CTime class provides all the functionalities discussed above in section 1. It also has methods to get the time in SYSTEMTIME or FILETIME or GMT format.

In addition this class also overloads the +, -, = , ==, <, <<, >> operators to provide many more useful features.

You can find the definition of CTime class in afx.h header file and it is as following:

The Process

First you select the search creteria, and / or a folder where you wish to start…

Alternatively, files can be just dragged and dropped to the dialog box.

Note: in this version only one file can be dragged, but that will be fixed later.

For the purpose of this article, I have created a folder named “test” and copied there many files, and folders. These files are both photos (.jpg) and non photos (.txt).

After the files are found based on the search criteria, selected or dragged and dropped, the process starts. Each file is checked and its date/time attributes are changed.

  • If a certain date and time are requested, the change takes into consideration the local time zone and whether day light savings is on or off.

}

  • An “Undo” button allows reversing any change.
  • The log of the changes that have taken place is displayed on screen, along with the date/time before and after the process.
  • The user can check via check boxes which dates should be changed.
  • The dates include the “Date Taken” attribute which is unique for photos (such as .jpg and camera specific files such as .NEF files (Nikon camera), etc. That is done via accessing the EXIF of the graphic file.

User Interface

As part of my efforts to make my small application user friendly and easy to use, I have done the following:

  • Keeping last entered values:

    Since there are two types of input from the user: a fixed date / time and a relative time (number of hours), which are indicated by setting a Combo box to either “Relative Date” or “Fixed Date”, it is important that when the user switches between the two, the last value entered will be show. For example, if you entered the fixed date “2000/01/01” and then entered 8:30 as a Relative Date, when you select “Fixed Date” again, the last value “2000/01/01” should be shown, and when switching back to Relative Date, the last relative value, “8:30” should be shown as well.

  • Allowing flexible data entry

    It should be possible to enter the following as a fixed date:

    • 2000/01/01 00:00:00
    • 2000/01/01 00:00
    • 2000/01/01

          It should be possible to enter a relative time in various ways:

  • 10 (means 10 hours forward)
  • -5 (means 5 hours backward)
  • 10:30 (means 10 and a half hours forward)

and so on…

  • Error handling

    In case there is an error, such as a file being locked, the log entry of this specific file is marked as “Failed” and the process continues.

Code Signing

As I am involved with large scale projects, my software venture purchases a Code Signing Certificate from Verisign (they cost $499 a year, and are suitable also for Kernel drivers).

To sign an executable, I use a tool named kSign by Commodo.

The difference between signing your executables and not signing them can be explained by the warrning your customer will get when trying to download a non signed executable.

and also:

But if your executable is signed, the user will get this message:

Which is better. Obtaining a Verisign certificate means that your identity (or your company’s identity) are fully verified.

Final Notes

Thanks to Aha-Soft for the icon used for the demo application. Copyright © 2000-2014 Aha-Soft

If you find bugs, please feel free to send me the revised source code Smile | :)

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Sending Text Messages from an iOS App

Introduction

This article explains how to add the capability of sending text (SMS) messages from a desktop application.

Background

The article focuses on an implementation using MFC / C++. While looking for a reliable and cheap solution for sending SMS messages programmatically, I came across a company named CardBoardFish which covers 150 countries and provides an easy to use, yet powerful SDK for interfacing from any web site, mobile phone, or desktop application, covering most platforms and development environments. Unfortunately, among the code samples in their web site, there aren’t any C++ samples, so I decided to develop my own C++ implementation.

Sending SMS Messages Programmatically

Most applications and web sites used to send SMS messages as part of their scope or among other functionalities (i.e., sending alerts, etc.) use one of the following methods:

HTTP Web Service –  requires using HTTP “GET” method to send a given Web Service a command, using an API, which contains the credentials, parameters, and the text for this message.

Email to SMS  – uses the SMTP protocol to allow sending an email in a unique format, which encodes all required parameters (credentials, sender, receiver, etc.) as part of an email.

This article focuses on the first method, using a Web Service.

The API

The following table lists all parameters that can (or should) be sent to the Web Service:

image1

Using the code

The code in this article was developed in MFC / C++ using Visual Studio 2010 Ultimate. I also used Cheng Shi‘s HTTPClient (thanks Cheng!).

In order to use the code for your own application, it is advised to read the specifications for the SDK named HTTPSMS. Secondly, you need to open an account and obtain your user name and password, which can be hardcoded in the source code, or entered during runtime.

The SendSMS application

image2

The main functionality of our application is obviously sending an SMS, which is done in the following function:

// SendSms – by Michael Haephrati

BOOL SendSms(CString From, CString CountryCode, CString To,CString Message,CString *Status)

// From – the ID or number you are sending from. This is what will appear at the recipient’s cellphone.

// CountyCode – the code of the country you are sending the SMS to (for example: 44 is for the UK

as, etc.
// Message – is the message you are sending, which can be any multi lingual text
// The statu

// To – is the number you are texting to, which should not contain any leading zeros, spaces, com

ms returned would be either a confirmation number along with the text “OK”, which means that the message

    // was delivered, or an error code. 
{
    BOOL result=FALSE;

equest+=user; // user name
request+=L”&P=”;
request+=pass; // password
r

    wstring user=L"PLACE_YOUR_USERNAME_HERE",pass=L"PLACE_YOUR_PASSWORD_HERE",request=L"";
    // 
    request=L"http://sms1.cardboardfish.com:9001/HTTPSMS?S=H&UN=";
    
request+=L"&DA="; 
    request+=(wstring)(CountryCode+To); // country code
    request+=L"&SA="; 
    request+=(wstring)From; // From (sender ID)
    request+=L"&M=";
    CString EncodedMessage; // Message
    
    CString ccc;

ssage is encoded as opposed to plain text

    EncodedMessage=ConvertHex(Message)+ConvertHex( L" here you can place your marketing piech, website, etc.");
    
    request+=(wstring)EncodedMessage; // Message to send

    request+=L"&DC=4";
    // Indicating that this m

e

Now we handle the HTTP “GET” request:

WinHttpClient client(request);

nt.SendHttpRequest(L”GET”,true);
// G

cli

eet the response

sponseHeader = client.GetResponseHeader();
wstring httpR

    wstring httpR
eesponseContent = client.GetResponseContent();

turn result;
}

    *Status=httpResponseContent.c_str();

Other Services

I have tested the services of CardBoardFish, which I used for the attached source code. They provide their own code samples here, but these don’t include c++, which I why I wrote the test application attached to this article.

I recently tested another service they provide which is verifying mobile numbers before sending the text messages. I didn’t include this functionality because I found it to be too slow, and also it doesn’t cover some countries, among them… USA.

I found another alternative service provider : http://www.clickatell.com so there are several options to choose from.

Further Reading

Please refer to another article of mine, this time explaining how to do the same using iOS (iPhone / iPad).