//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "SysUtilsStrRScan.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
	: TForm(Owner)
{
}
//---------------------------------------------------------------------------
// BeginExample: SysUtilsStrRScan
// Routine: SysUtils.StrRScan

// BeginCode
/*
The following example uses an Open dialog box and a button
on a form. When the button is clicked, the user is prompted
for a filename. Then the filename, minus its path, is
displayed in a message box.
Note:	This technique will not work with multi-byte
character sets (MBCS). To be more general, use ExtractFileName.
*/
char *__fastcall GetFileName(char *pszFilePath)
{
  char *pszFileName = StrRScan(pszFilePath, '\\');
  if (!pszFileName)
    pszFileName = pszFilePath;
  else
	pszFileName++;
  return pszFileName;
}
void __fastcall TForm1::Button1Click(TObject *Sender)
{
  if (OpenDialog1->Execute())
  {
	char *name = GetFileName(OpenDialog1->FileName.t_str());
	Application->MessageBox(
	  WideString(name).c_bstr(),
	  L"File Name",
	  MB_OK);
  }
}
// EndCode
// EndExample: SysUtilsStrRScan
//---------------------------------------------------------------------------
