<repo_name>f059074251/interested<file_sep>/7-Zip/CPP/7zip/Archive/Nsis/NsisIn.cpp
// NsisIn.cpp

#include "StdAfx.h"

#include "../../../../C/CpuArch.h"

#include "Common/IntToString.h"

#include "../../Common/StreamUtils.h"

#include "NsisIn.h"

#define Get32(p) GetUi32(p)

namespace NArchive {
namespace NNsis {

Byte kSignature[kSignatureSize] = NSIS_SIGNATURE;

#ifdef NSIS_SCRIPT
static const char *kCrLf = "\x0D\x0A";
#endif

#define NS_UN_SKIP_CODE  0xE000
#define NS_UN_VAR_CODE   0xE001
#define NS_UN_SHELL_CODE 0xE002
#define NS_UN_LANG_CODE  0xE003
#define NS_UN_CODES_START NS_UN_SKIP_CODE
#define NS_UN_CODES_END   NS_UN_LANG_CODE

Byte CInArchive::ReadByte()
{
  if (_posInData >= _size)
    throw 1;
  return _data[_posInData++];
}

UInt32 CInArchive::ReadUInt32()
{
  UInt32 value = 0;
  for (int i = 0; i < 4; i++)
    value |= ((UInt32)(ReadByte()) << (8 * i));
  return value;
}

void CInArchive::ReadBlockHeader(CBlockHeader &bh)
{
  bh.Offset = ReadUInt32();
  bh.Num = ReadUInt32();
}

#define RINOZ(x) { int __tt = (x); if (__tt != 0) return __tt; }

static int CompareItems(void *const *p1, void *const *p2, void * /* param */)
{
  const CItem &i1 = **(CItem **)p1;
  const CItem &i2 = **(CItem **)p2;
  RINOZ(MyCompare(i1.Pos, i2.Pos));
  if (i1.IsUnicode)
  {
    RINOZ(i1.PrefixU.Compare(i2.PrefixU));
    RINOZ(i1.NameU.Compare(i2.NameU));
  }
  else
  {
    RINOZ(i1.PrefixA.Compare(i2.PrefixA));
    RINOZ(i1.NameA.Compare(i2.NameA));
  }
  return 0;
}

static AString UIntToString(UInt32 v)
{
  char sz[32];
  ConvertUInt64ToString(v, sz);
  return sz;
}

static AString IntToString(Int32 v)
{
  char sz[32];
  ConvertInt64ToString(v, sz);
  return sz;
}

AString CInArchive::ReadStringA(UInt32 pos) const
{
  AString s;
  if (pos >= _size)
    return IntToString((Int32)pos);
  UInt32 offset = GetOffset() + _stringsPos + pos;
  for (;;)
  {
    if (offset >= _size)
      break; // throw 1;
    char c = _data[offset++];
    if (c == 0)
      break;
    s += c;
  }
  return s;
}

UString CInArchive::ReadStringU(UInt32 pos) const
{
  UString s;
  UInt32 offset = GetOffset() + _stringsPos + (pos * 2);
  for (;;)
  {
    if (offset >= _size || offset + 1 >= _size)
      return s; // throw 1;
    char c0 = _data[offset++];
    char c1 = _data[offset++];
    wchar_t c = (c0 | ((wchar_t)c1 << 8));
    if (c == 0)
      break;
    s += c;
  }
  return s;
}

/*
static AString ParsePrefix(const AString &prefix)
{
  AString res = prefix;
  if (prefix.Length() >= 3)
  {
    if ((Byte)prefix[0] == 0xFD && (Byte)prefix[1] == 0x95 && (Byte)prefix[2] == 0x80)
      res = "$INSTDIR" + prefix.Mid(3);
    else if ((Byte)prefix[0] == 0xFD && (Byte)prefix[1] == 0x96 && (Byte)prefix[2] == 0x80)
      res = "$OUTDIR" + prefix.Mid(3);
  }
  return res;
}
*/

#define SYSREGKEY "Software\\Microsoft\\Windows\\CurrentVersion"

/*
#  define CSIDL_PROGRAMS 0x2
#  define CSIDL_PRINTERS 0x4
#  define CSIDL_PERSONAL 0x5
#  define CSIDL_FAVORITES 0x6
#  define CSIDL_STARTUP 0x7
#  define CSIDL_RECENT 0x8
#  define CSIDL_SENDTO 0x9
#  define CSIDL_STARTMENU 0xB
#  define CSIDL_MYMUSIC 0xD
#  define CSIDL_MYVIDEO 0xE

#  define CSIDL_DESKTOPDIRECTORY 0x10
#  define CSIDL_NETHOOD 0x13
#  define CSIDL_FONTS 0x14
#  define CSIDL_TEMPLATES 0x15
#  define CSIDL_COMMON_STARTMENU 0x16
#  define CSIDL_COMMON_PROGRAMS 0x17
#  define CSIDL_COMMON_STARTUP 0x18
#  define CSIDL_COMMON_DESKTOPDIRECTORY 0x19
#  define CSIDL_APPDATA 0x1A
#  define CSIDL_PRINTHOOD 0x1B
#  define CSIDL_LOCAL_APPDATA 0x1C
#  define CSIDL_ALTSTARTUP 0x1D
#  define CSIDL_COMMON_ALTSTARTUP 0x1E
#  define CSIDL_COMMON_FAVORITES 0x1F

#  define CSIDL_INTERNET_CACHE 0x20
#  define CSIDL_COOKIES 0x21
#  define CSIDL_HISTORY 0x22
#  define CSIDL_COMMON_APPDATA 0x23
#  define CSIDL_WINDOWS 0x24
#  define CSIDL_SYSTEM 0x25
#  define CSIDL_PROGRAM_FILES 0x26
#  define CSIDL_MYPICTURES 0x27
#  define CSIDL_PROFILE 0x28
#  define CSIDL_PROGRAM_FILES_COMMON 0x2B
#  define CSIDL_COMMON_TEMPLATES 0x2D
#  define CSIDL_COMMON_DOCUMENTS 0x2E
#  define CSIDL_COMMON_ADMINTOOLS 0x2F

#  define CSIDL_ADMINTOOLS 0x30
#  define CSIDL_COMMON_MUSIC 0x35
#  define CSIDL_COMMON_PICTURES 0x36
#  define CSIDL_COMMON_VIDEO 0x37
#  define CSIDL_RESOURCES 0x38
#  define CSIDL_RESOURCES_LOCALIZED 0x39
#  define CSIDL_CDBURN_AREA 0x3B
*/

struct CCommandPair
{
  int NumParams;
  const char *Name;
};

enum
{
  // 0
  EW_INVALID_OPCODE,    // zero is invalid. useful for catching errors. (otherwise an all zeroes instruction
                        // does nothing, which is easily ignored but means something is wrong.
  EW_RET,               // return from function call
  EW_NOP,               // Nop/Jump, do nothing: 1, [?new address+1:advance one]
  EW_ABORT,             // Abort: 1 [status]
  EW_QUIT,              // Quit: 0
  EW_CALL,              // Call: 1 [new address+1]
  EW_UPDATETEXT,        // Update status text: 2 [update str, ui_st_updateflag=?ui_st_updateflag:this]
  EW_SLEEP,             // Sleep: 1 [sleep time in milliseconds]
  EW_BRINGTOFRONT,      // BringToFront: 0
  EW_CHDETAILSVIEW,     // SetDetailsView: 2 [listaction,buttonaction]
  
  // 10
  EW_SETFILEATTRIBUTES, // SetFileAttributes: 2 [filename, attributes]
  EW_CREATEDIR,         // Create directory: 2, [path, ?update$INSTDIR]
  EW_IFFILEEXISTS,      // IfFileExists: 3, [file name, jump amount if exists, jump amount if not exists]
  EW_SETFLAG,           // Sets a flag: 2 [id, data]
  EW_IFFLAG,            // If a flag: 4 [on, off, id, new value mask]
  EW_GETFLAG,           // Gets a flag: 2 [output, id]
  EW_RENAME,            // Rename: 3 [old, new, rebootok]
  EW_GETFULLPATHNAME,   // GetFullPathName: 2 [output, input, ?lfn:sfn]
  EW_SEARCHPATH,        // SearchPath: 2 [output, filename]
  EW_GETTEMPFILENAME,   // GetTempFileName: 2 [output, base_dir]
  
  // 20
  EW_EXTRACTFILE,       // File to extract: 6 [overwriteflag, output filename, compressed filedata, filedatetimelow, filedatetimehigh, allow ignore]
                        //  overwriteflag: 0x1 = no. 0x0=force, 0x2=try, 0x3=if date is newer
  EW_DELETEFILE,        // Delete File: 2, [filename, rebootok]
  EW_MESSAGEBOX,        // MessageBox: 5,[MB_flags,text,retv1:retv2,moveonretv1:moveonretv2]
  EW_RMDIR,             // RMDir: 2 [path, recursiveflag]
  EW_STRLEN,            // StrLen: 2 [output, input]
  EW_ASSIGNVAR,         // Assign: 4 [variable (0-9) to assign, string to assign, maxlen, startpos]
  EW_STRCMP,            // StrCmp: 5 [str1, str2, jump_if_equal, jump_if_not_equal, case-sensitive?]
  EW_READENVSTR,        // ReadEnvStr/ExpandEnvStrings: 3 [output, string_with_env_variables, IsRead]
  EW_INTCMP,            // IntCmp: 6 [val1, val2, equal, val1<val2, val1>val2, unsigned?]
  EW_INTOP,             // IntOp: 4 [output, input1, input2, op] where op: 0=add, 1=sub, 2=mul, 3=div, 4=bor, 5=band, 6=bxor, 7=bnot input1, 8=lnot input1, 9=lor, 10=land], 11=1%2
  
  // 30
  EW_INTFMT,            // IntFmt: [output, format, input]
  EW_PUSHPOP,           // Push/Pop/Exchange: 3 [variable/string, ?pop:push, ?exch]
  EW_FINDWINDOW,        // FindWindow: 5, [outputvar, window class,window name, window_parent, window_after]
  EW_SENDMESSAGE,       // SendMessage: 6 [output, hwnd, msg, wparam, lparam, [wparamstring?1:0 | lparamstring?2:0 | timeout<<2]
  EW_ISWINDOW,          // IsWindow: 3 [hwnd, jump_if_window, jump_if_notwindow]
  EW_GETDLGITEM,        // GetDlgItem:        3: [outputvar, dialog, item_id]
  EW_SETCTLCOLORS,      // SerCtlColors:      3: [hwnd, pointer to struct colors]
  EW_SETBRANDINGIMAGE,  // SetBrandingImage:  1: [Bitmap file]
  EW_CREATEFONT,        // CreateFont:        5: [handle output, face name, height, weight, flags]
  EW_SHOWWINDOW,        // ShowWindow:        2: [hwnd, show state]
  
  // 40
  EW_SHELLEXEC,         // ShellExecute program: 4, [shell action, complete commandline, parameters, showwindow]
  EW_EXECUTE,           // Execute program: 3,[complete command line,waitflag,>=0?output errorcode]
  EW_GETFILETIME,       // GetFileTime; 3 [file highout lowout]
  EW_GETDLLVERSION,     // GetDLLVersion: 3 [file highout lowout]
  EW_REGISTERDLL,       // Register DLL: 3,[DLL file name, string ptr of function to call, text to put in display (<0 if none/pass parms), 1 - no unload, 0 - unload]
  EW_CREATESHORTCUT,    // Make Shortcut: 5, [link file, target file, parameters, icon file, iconindex|show mode<<8|hotkey<<16]
  EW_COPYFILES,         // CopyFiles: 3 [source mask, destination location, flags]
  EW_REBOOT,            // Reboot: 0
  EW_WRITEINI,          // Write INI String: 4, [Section, Name, Value, INI File]
  EW_READINISTR,        // ReadINIStr: 4 [output, section, name, ini_file]
  
  // 50
  EW_DELREG,            // DeleteRegValue/DeleteRegKey: 4, [root key(int), KeyName, ValueName, delkeyonlyifempty]. ValueName is -1 if delete key
  EW_WRITEREG,          // Write Registry value: 5, [RootKey(int),KeyName,ItemName,ItemData,typelen]
                        //  typelen=1 for str, 2 for dword, 3 for binary, 0 for expanded str
  EW_READREGSTR,        // ReadRegStr: 5 [output, rootkey(int), keyname, itemname, ==1?int::str]
  EW_REGENUM,           // RegEnum: 5 [output, rootkey, keyname, index, ?key:value]
  EW_FCLOSE,            // FileClose: 1 [handle]
  EW_FOPEN,             // FileOpen: 4  [name, openmode, createmode, outputhandle]
  EW_FPUTS,             // FileWrite: 3 [handle, string, ?int:string]
  EW_FGETS,             // FileRead: 4  [handle, output, maxlen, ?getchar:gets]
  EW_FSEEK,             // FileSeek: 4  [handle, offset, mode, >=0?positionoutput]
  EW_FINDCLOSE,         // FindClose: 1 [handle]
  
  // 60
  EW_FINDNEXT,          // FindNext: 2  [output, handle]
  EW_FINDFIRST,         // FindFirst: 2 [filespec, output, handleoutput]
  EW_WRITEUNINSTALLER,  // WriteUninstaller: 3 [name, offset, icon_size]
  EW_LOG,               // LogText: 2 [0, text] / LogSet: [1, logstate]
  EW_SECTIONSET,        // SectionSetText:    3: [idx, 0, text]
                        // SectionGetText:    3: [idx, 1, output]
                        // SectionSetFlags:   3: [idx, 2, flags]
                        // SectionGetFlags:   3: [idx, 3, output]
  EW_INSTTYPESET,       // InstTypeSetFlags:  3: [idx, 0, flags]
                        // InstTypeGetFlags:  3: [idx, 1, output]
  // instructions not actually implemented in exehead, but used in compiler.
  EW_GETLABELADDR,      // both of these get converted to EW_ASSIGNVAR
  EW_GETFUNCTIONADDR,

  EW_LOCKWINDOW
};

#ifdef NSIS_SCRIPT
static CCommandPair kCommandPairs[] =
{
  { 0, "Invalid" },
  { 0, "Return" },
  { 1, "Goto" },
  { 0, "Abort" },
  { 0, "Quit" },
  { 1, "Call" },
  { 2, "UpdateSatusText" },
  { 1, "Sleep" },
  { 0, "BringToFront" },
  { 2, "SetDetailsView" },

  { 2, "SetFileAttributes" },
  { 2, "SetOutPath" },
  { 3, "IfFileExists" },
  { 2, "SetFlag" },
  { 4, "IfFlag" },
  { 2, "GetFlag" },
  { 3, "Rename" },
  { 2, "GetFullPathName" },
  { 2, "SearchPath" },
  { 2, "GetTempFileName" },

  { 6, "File" },
  { 2, "Delete" },
  { 5, "MessageBox" },
  { 2, "RMDir" },
  { 2, "StrLen" },
  { 4, "StrCpy" },
  { 5, "StrCmp" },
  { 3, "ReadEnvStr" },
  { 6, "IntCmp" },
  { 4, "IntOp" },

  { 3, "IntFmt" },
  { 3, "PushPop" },
  { 5, "FindWindow" },
  { 6, "SendMessage" },
  { 3, "IsWindow" },
  { 3, "GetDlgItem" },
  { 3, "SerCtlColors" },
  { 1, "SetBrandingImage" },
  { 5, "CreateFont" },
  { 2, "ShowWindow" },

  { 4, "ShellExecute" },
  { 3, "Execute" },
  { 3, "GetFileTime" },
  { 3, "GetDLLVersion" },
  { 3, "RegisterDLL" },
  { 5, "CreateShortCut" },
  { 3, "CopyFiles" },
  { 0, "Reboot" },
  { 4, "WriteINIStr" },
  { 4, "ReadINIStr" },

  { 4, "DelReg" },
  { 5, "WriteReg" },
  { 5, "ReadRegStr" },
  { 5, "RegEnum" },
  { 1, "FileClose" },
  { 4, "FileOpen" },
  { 3, "FileWrite" },
  { 4, "FileRead" },
  { 4, "FileSeek" },
  { 1, "FindClose" },

  { 2, "FindNext" },
  { 2, "FindFirst" },
  { 3, "WriteUninstaller" },
  { 2, "LogText" },
  { 3, "Section?etText" },
  { 3, "InstType?etFlags" },
  { 6, "GetLabelAddr" },
  { 2, "GetFunctionAddress" },
  { 6, "LockWindow" }
};

#endif

static const char *kShellStrings[] =
{
  "",
  "",

  "SMPROGRAMS",
  "",
  "PRINTERS",
  "DOCUMENTS",
  "FAVORITES",
  "SMSTARTUP",
  "RECENT",
  "SENDTO",
  "",
  "STARTMENU",
  "",
  "MUSIC",
  "VIDEO",
  "",

  "DESKTOP",
  "",
  "",
  "NETHOOD",
  "FONTS",
  "TEMPLATES",
  "COMMONSTARTMENU",
  "COMMONFILES",
  "COMMON_STARTUP",
  "COMMON_DESKTOPDIRECTORY",
  "QUICKLAUNCH",
  "PRINTHOOD",
  "LOCALAPPDATA",
  "ALTSTARTUP",
  "ALTSTARTUP",
  "FAVORITES",

  "INTERNET_CACHE",
  "COOKIES",
  "HISTORY",
  "APPDATA",
  "WINDIR",
  "SYSDIR",
  "PROGRAMFILES",
  "PICTURES",
  "PROFILE",
  "",
  "",
  "COMMONFILES",
  "",
  "TEMPLATES",
  "DOCUMENTS",
  "ADMINTOOLS",

  "ADMINTOOLS",
  "",
  "",
  "",
  "",
  "MUSIC",
  "PICTURES",
  "VIDEO",
  "RESOURCES",
  "RESOURCES_LOCALIZED",
  "",
  "CDBURN_AREA"
};

static const int kNumShellStrings = sizeof(kShellStrings) / sizeof(kShellStrings[0]);

/*
# define CMDLINE 20 // everything before here doesn't have trailing slash removal
# define INSTDIR 21
# define OUTDIR 22
# define EXEDIR 23
# define LANGUAGE 24
# define TEMP   25
# define PLUGINSDIR 26
# define HWNDPARENT 27
# define _CLICK 28
# define _OUTDIR 29
*/

static const char *kVarStrings[] =
{
  "CMDLINE",
  "INSTDIR",
  "OUTDIR",
  "EXEDIR",
  "LANGUAGE",
  "TEMP",
  "PLUGINSDIR",
  "EXEPATH", // test it
  "EXEFILE", // test it
  "HWNDPARENT",
  "_CLICK",
  "_OUTDIR"
};

static const int kNumVarStrings = sizeof(kVarStrings) / sizeof(kVarStrings[0]);


static AString GetVar(UInt32 index)
{
  AString res = "$";
  if (index < 10)
    res += UIntToString(index);
  else if (index < 20)
  {
    res += "R";
    res += UIntToString(index - 10);
  }
  else if (index < 20 + kNumVarStrings)
    res += kVarStrings[index - 20];
  else
  {
    res += "[";
    res += UIntToString(index);
    res += "]";
  }
  return res;
}

#define NS_SKIP_CODE  252
#define NS_VAR_CODE   253
#define NS_SHELL_CODE 254
#define NS_LANG_CODE  255
#define NS_CODES_START NS_SKIP_CODE

static AString GetShellString(int index)
{
  AString res = "$";
  if (index < kNumShellStrings)
  {
    const char *sz = kShellStrings[index];
    if (sz[0] != 0)
      return res + sz;
  }
  res += "SHELL[";
  res += UIntToString(index);
  res += "]";
  return res;
}

// Based on <NAME>'s simplified process_string
AString GetNsisString(const AString &s)
{
  AString res;
  for (int i = 0; i < s.Length();)
  {
    unsigned char nVarIdx = s[i++];
    if (nVarIdx > NS_CODES_START && i + 2 <= s.Length())
    {
      int nData = s[i++] & 0x7F;
      unsigned char c1 = s[i++];
      nData |= (((int)(c1 & 0x7F)) << 7);

      if (nVarIdx == NS_SHELL_CODE)
        res += GetShellString(c1);
      else if (nVarIdx == NS_VAR_CODE)
        res += GetVar(nData);
      else if (nVarIdx == NS_LANG_CODE)
        res += "NS_LANG_CODE";
    }
    else if (nVarIdx == NS_SKIP_CODE)
    {
      if (i < s.Length())
        res += s[i++];
    }
    else // Normal char
      res += (char)nVarIdx;
  }
  return res;
}

UString GetNsisString(const UString &s)
{
  UString res;
  for (int i = 0; i < s.Length();)
  {
    wchar_t nVarIdx = s[i++];
    if (nVarIdx > NS_UN_CODES_START && nVarIdx <= NS_UN_CODES_END)
    {
      if (i == s.Length())
        break;
      int nData = s[i++] & 0x7FFF;

      if (nVarIdx == NS_UN_SHELL_CODE)
        res += GetUnicodeString(GetShellString(nData >> 8));
      else if (nVarIdx == NS_UN_VAR_CODE)
        res += GetUnicodeString(GetVar(nData));
      else if (nVarIdx == NS_UN_LANG_CODE)
        res += L"NS_LANG_CODE";
    }
    else if (nVarIdx == NS_UN_SKIP_CODE)
    {
      if (i == s.Length())
        break;
      res += s[i++];
    }
    else // Normal char
      res += (char)nVarIdx;
  }
  return res;
}

AString CInArchive::ReadString2A(UInt32 pos) const
{
  return GetNsisString(ReadStringA(pos));
}

UString CInArchive::ReadString2U(UInt32 pos) const
{
  return GetNsisString(ReadStringU(pos));
}

AString CInArchive::ReadString2(UInt32 pos) const
{
  if (IsUnicode)
    return UnicodeStringToMultiByte(ReadString2U(pos));
  else
    return ReadString2A(pos);
}

AString CInArchive::ReadString2Qw(UInt32 pos) const
{
  return "\"" + ReadString2(pos) + "\"";
}

#define DEL_DIR 1
#define DEL_RECURSE 2
#define DEL_REBOOT 4
// #define DEL_SIMPLE 8

static const int kNumEntryParams = 6;

struct CEntry
{
  UInt32 Which;
  UInt32 Params[kNumEntryParams];
  AString GetParamsString(int numParams);
  CEntry()
  {
    Which = 0;
    for (UInt32 j = 0; j < kNumEntryParams; j++)
      Params[j] = 0;
  }
};

AString CEntry::GetParamsString(int numParams)
{
  AString s;
  for (int i = 0; i < numParams; i++)
  {
    s += " ";
    UInt32 v = Params[i];
    if (v > 0xFFF00000)
      s += IntToString((Int32)Params[i]);
    else
      s += UIntToString(Params[i]);
  }
  return s;
}

#ifdef NSIS_SCRIPT

static AString GetRegRootID(UInt32 val)
{
  const char *s;
  switch(val)
  {
    case 0:  s = "SHCTX"; break;
    case 0x80000000:  s = "HKCR"; break;
    case 0x80000001:  s = "HKCU"; break;
    case 0x80000002:  s = "HKLM"; break;
    case 0x80000003:  s = "HKU";  break;
    case 0x80000004:  s = "HKPD"; break;
    case 0x80000005:  s = "HKCC"; break;
    case 0x80000006:  s = "HKDD"; break;
    case 0x80000050:  s = "HKPT"; break;
    case 0x80000060:  s = "HKPN"; break;
    default:
      return UIntToString(val); break;
  }
  return s;
}

#endif

HRESULT CInArchive::ReadEntries(const CBlockHeader &bh)
{
  _posInData = bh.Offset + GetOffset();
  AString prefixA;
  UString prefixU;
  for (UInt32 i = 0; i < bh.Num; i++)
  {
    CEntry e;
    e.Which = ReadUInt32();
    for (UInt32 j = 0; j < kNumEntryParams; j++)
      e.Params[j] = ReadUInt32();
    #ifdef NSIS_SCRIPT
    if (e.Which != EW_PUSHPOP && e.Which < sizeof(kCommandPairs) / sizeof(kCommandPairs[0]))
    {
      const CCommandPair &pair = kCommandPairs[e.Which];
      Script += pair.Name;
    }
    #endif

    switch (e.Which)
    {
      case EW_CREATEDIR:
      {
        if (IsUnicode)
        {
          prefixU.Empty();
          prefixU = ReadString2U(e.Params[0]);
        }
        else
        {
          prefixA.Empty();
          prefixA = ReadString2A(e.Params[0]);
        }
        #ifdef NSIS_SCRIPT
        Script += " ";
        if (IsUnicode)
          Script += UnicodeStringToMultiByte(prefixU);
        else
          Script += prefixA;
        #endif
        break;
      }

      case EW_EXTRACTFILE:
      {
        CItem item;
        item.IsUnicode = IsUnicode;
        if (IsUnicode)
        {
          item.PrefixU = prefixU;
          item.NameU = ReadString2U(e.Params[1]);
        }
        else
        {
          item.PrefixA = prefixA;
          item.NameA = ReadString2A(e.Params[1]);
        }
        /* UInt32 overwriteFlag = e.Params[0]; */
        item.Pos = e.Params[2];
        item.MTime.dwLowDateTime = e.Params[3];
        item.MTime.dwHighDateTime = e.Params[4];
        /* UInt32 allowIgnore = e.Params[5]; */
        if (Items.Size() > 0)
        {
          /*
          if (item.Pos == Items.Back().Pos)
            continue;
          */
        }
        Items.Add(item);
        #ifdef NSIS_SCRIPT
        Script += " ";

        if (IsUnicode)
          Script += UnicodeStringToMultiByte(item.NameU);
        else
          Script += item.NameA;
        #endif
        break;
      }


      #ifdef NSIS_SCRIPT
      case EW_UPDATETEXT:
      {
        Script += " ";
        Script += ReadString2(e.Params[0]);
        Script += " ";
        Script += UIntToString(e.Params[1]);
        break;
      }
      case EW_SETFILEATTRIBUTES:
      {
        Script += " ";
        Script += ReadString2(e.Params[0]);
        Script += " ";
        Script += UIntToString(e.Params[1]);
        break;
      }
      case EW_IFFILEEXISTS:
      {
        Script += " ";
        Script += ReadString2(e.Params[0]);
        Script += " ";
        Script += UIntToString(e.Params[1]);
        Script += " ";
        Script += UIntToString(e.Params[2]);
        break;
      }
      case EW_RENAME:
      {
        Script += " ";
        Script += ReadString2(e.Params[0]);
        Script += " ";
        Script += ReadString2(e.Params[1]);
        Script += " ";
        Script += UIntToString(e.Params[2]);
        break;
      }
      case EW_GETFULLPATHNAME:
      {
        Script += " ";
        Script += ReadString2(e.Params[0]);
        Script += " ";
        Script += ReadString2(e.Params[1]);
        Script += " ";
        Script += UIntToString(e.Params[2]);
        break;
      }
      case EW_SEARCHPATH:
      {
        Script += " ";
        Script += ReadString2(e.Params[0]);
        Script += " ";
        Script += ReadString2(e.Params[1]);
        break;
      }
      case EW_GETTEMPFILENAME:
      {
        AString s;
        Script += " ";
        Script += ReadString2(e.Params[0]);
        Script += " ";
        Script += ReadString2(e.Params[1]);
        break;
      }

      case EW_DELETEFILE:
      {
        UInt64 flag = e.Params[1];
        if (flag != 0)
        {
          Script += " ";
          if (flag == DEL_REBOOT)
            Script += "/REBOOTOK";
          else
            Script += UIntToString(e.Params[1]);
        }
        Script += " ";
        Script += ReadString2(e.Params[0]);
        break;
      }
      case EW_RMDIR:
      {
        UInt64 flag = e.Params[1];
        if (flag != 0)
        {
          if ((flag & DEL_REBOOT) != 0)
            Script += " /REBOOTOK";
          if ((flag & DEL_RECURSE) != 0)
            Script += " /r";
        }
        Script += " ";
        Script += ReadString2(e.Params[0]);
        break;
      }
      case EW_STRLEN:
      {
        Script += " ";
        Script += GetVar(e.Params[0]);;
        Script += " ";
        Script += ReadString2Qw(e.Params[1]);
        break;
      }
      case EW_ASSIGNVAR:
      {
        Script += " ";
        Script += GetVar(e.Params[0]);;
        Script += " ";
        Script += ReadString2Qw(e.Params[1]);
        AString maxLen, startOffset;
        if (e.Params[2] != 0)
          maxLen = ReadString2(e.Params[2]);
        if (e.Params[3] != 0)
          startOffset = ReadString2(e.Params[3]);
        if (!maxLen.IsEmpty() || !startOffset.IsEmpty())
        {
          Script += " ";
          if (maxLen.IsEmpty())
            Script += "\"\"";
          else
            Script += maxLen;
          if (!startOffset.IsEmpty())
          {
            Script += " ";
            Script += startOffset;
          }
        }
        break;
      }
      case EW_STRCMP:
      {
        Script += " ";

        Script += " ";
        Script += ReadString2Qw(e.Params[0]);
        
        Script += " ";
        Script += ReadString2Qw(e.Params[1]);

        for (int j = 2; j < 5; j++)
        {
          Script += " ";
          Script += UIntToString(e.Params[j]);
        }
        break;
      }
      case EW_INTCMP:
      {
        if (e.Params[5] != 0)
          Script += "U";

        Script += " ";
        Script += ReadString2(e.Params[0]);
        Script += " ";
        Script += ReadString2(e.Params[1]);

        for (int i = 2; i < 5; i++)
        {
          Script += " ";
          Script += UIntToString(e.Params[i]);
        }
        break;
      }
      case EW_INTOP:
      {
        Script += " ";
        Script += GetVar(e.Params[0]);
        Script += " ";
        int numOps = 2;
        AString op;
        switch (e.Params[3])
        {
          case 0: op = '+'; break;
          case 1: op = '-'; break;
          case 2: op = '*'; break;
          case 3: op = '/'; break;
          case 4: op = '|'; break;
          case 5: op = '&'; break;
          case 6: op = '^'; break;
          case 7: op = '~'; numOps = 1; break;
          case 8: op = '!'; numOps = 1; break;
          case 9: op = "||"; break;
          case 10: op = "&&"; break;
          case 11: op = '%'; break;
          default: op = UIntToString(e.Params[3]);
        }
        AString p1 = ReadString2(e.Params[1]);
        if (numOps == 1)
        {
          Script += op;
          Script += p1;
        }
        else
        {
          Script += p1;
          Script += " ";
          Script += op;
          Script += " ";
          Script += ReadString2(e.Params[2]);
        }
        break;
      }

      case EW_PUSHPOP:
      {
        int isPop = (e.Params[1] != 0);
        if (isPop)
        {
          Script += "Pop";
          Script += " ";
          Script += GetVar(e.Params[0]);;
        }
        else
        {
          int isExch = (e.Params[2] != 0);
          if (isExch)
          {
            Script += "Exch";
          }
          else
          {
            Script += "Push";
            Script += " ";
            Script += ReadString2(e.Params[0]);
          }
        }
        break;
      }

      case EW_SENDMESSAGE:
      {
        // SendMessage: 6 [output, hwnd, msg, wparam, lparam, [wparamstring?1:0 | lparamstring?2:0 | timeout<<2]
        Script += " ";
        // Script += ReadString2(e.Params[0]);
        // Script += " ";
        Script += ReadString2(e.Params[1]);
        Script += " ";
        Script += ReadString2(e.Params[2]);
        
        Script += " ";
        UInt32 spec = e.Params[5];
        // if (spec & 1)
          Script += IntToString(e.Params[3]);
        // else
        //   Script += ReadString2(e.Params[3]);
        
        Script += " ";
        // if (spec & 2)
          Script += IntToString(e.Params[4]);
        // else
        //   Script += ReadString2(e.Params[4]);

        if ((Int32)e.Params[0] >= 0)
        {
          Script += " ";
          Script += GetVar(e.Params[1]);
        }

        spec >>= 2;
        if (spec != 0)
        {
          Script += " /TIMEOUT=";
          Script += IntToString(spec);
        }
        break;
      }

      case EW_GETDLGITEM:
      {
        Script += " ";
        Script += GetVar(e.Params[0]);;
        Script += " ";
        Script += ReadString2(e.Params[1]);
        Script += " ";
        Script += ReadString2(e.Params[2]);
        break;
     }


      case EW_REGISTERDLL:
      {
        Script += " ";
        Script += ReadString2(e.Params[0]);
        Script += " ";
        Script += ReadString2(e.Params[1]);
        Script += " ";
        Script += UIntToString(e.Params[2]);
        break;
      }

      case EW_CREATESHORTCUT:
      {
        AString s;

        Script += " ";
        Script += ReadString2Qw(e.Params[0]);

        Script += " ";
        Script += ReadString2Qw(e.Params[1]);

        for (int j = 2; j < 5; j++)
        {
          Script += " ";
          Script += UIntToString(e.Params[j]);
        }
        break;
      }

      /*
      case EW_DELREG:
      {
        AString keyName, valueName;
        keyName = ReadString2(e.Params[1]);
        bool isValue = (e.Params[2] != -1);
        if (isValue)
        {
          valueName = ReadString2(e.Params[2]);
          Script += "Key";
        }
        else
          Script += "Value";
        Script += " ";
        Script += UIntToString(e.Params[0]);
        Script += " ";
        Script += keyName;
        if (isValue)
        {
          Script += " ";
          Script += valueName;
        }
        Script += " ";
        Script += UIntToString(e.Params[3]);
        break;
      }
      */

      case EW_WRITEREG:
      {
        AString s;
        switch(e.Params[4])
        {
          case 1:  s = "Str"; break;
          case 2:  s = "ExpandStr"; break;
          case 3:  s = "Bin"; break;
          case 4:  s = "DWORD"; break;
          default: s = "?" + UIntToString(e.Params[4]); break;
        }
        Script += s;
        Script += " ";
        Script += GetRegRootID(e.Params[0]);
        Script += " ";

        AString keyName, valueName;
        keyName = ReadString2Qw(e.Params[1]);
        Script += keyName;
        Script += " ";
        
        valueName = ReadString2Qw(e.Params[2]);
        Script += valueName;
        Script += " ";

        valueName = ReadString2Qw(e.Params[3]);
        Script += valueName;
        Script += " ";

        break;
      }

      case EW_WRITEUNINSTALLER:
      {
        Script += " ";
        Script += ReadString2(e.Params[0]);
        for (int j = 1; j < 3; j++)
        {
          Script += " ";
          Script += UIntToString(e.Params[j]);
        }
        break;
      }

      default:
      {
        int numParams = kNumEntryParams;
        if (e.Which < sizeof(kCommandPairs) / sizeof(kCommandPairs[0]))
        {
          const CCommandPair &pair = kCommandPairs[e.Which];
          // Script += pair.Name;
          numParams = pair.NumParams;
        }
        else
        {
          Script += "Unknown";
          Script += UIntToString(e.Which);
        }
        Script += e.GetParamsString(numParams);
      }
      #endif
    }
    #ifdef NSIS_SCRIPT
    Script += kCrLf;
    #endif
  }

  {
    Items.Sort(CompareItems, 0);
    int i;
    // if (IsSolid)
    for (i = 0; i + 1 < Items.Size();)
    {
      bool sameName = IsUnicode ?
        (Items[i].NameU == Items[i + 1].NameU) :
        (Items[i].NameA == Items[i + 1].NameA);
      if (Items[i].Pos == Items[i + 1].Pos && (IsSolid || sameName))
        Items.Delete(i + 1);
      else
        i++;
    }
    for (i = 0; i + 1 < Items.Size(); i++)
    {
      CItem &item = Items[i];
      item.EstimatedSizeIsDefined = true;
      item.EstimatedSize = Items[i + 1].Pos - item.Pos - 4;
    }
    if (!IsSolid)
    {
      for (i = 0; i < Items.Size(); i++)
      {
        CItem &item = Items[i];
        RINOK(_stream->Seek(GetPosOfNonSolidItem(i), STREAM_SEEK_SET, NULL));
        const UInt32 kSigSize = 4 + 1 + 5;
        BYTE sig[kSigSize];
        size_t processedSize = kSigSize;
        RINOK(ReadStream(_stream, sig, &processedSize));
        if (processedSize < 4)
          return S_FALSE;
        UInt32 size = Get32(sig);
        if ((size & 0x80000000) != 0)
        {
          item.IsCompressed = true;
          // is compressed;
          size &= ~0x80000000;
          if (Method == NMethodType::kLZMA)
          {
            if (processedSize < 9)
              return S_FALSE;
            if (FilterFlag)
              item.UseFilter = (sig[4] != 0);
            item.DictionarySize = Get32(sig + 5 + (FilterFlag ? 1 : 0));
          }
        }
        else
        {
          item.IsCompressed = false;
          item.Size = size;
          item.SizeIsDefined = true;
        }
        item.CompressedSize = size;
        item.CompressedSizeIsDefined = true;
      }
    }
  }
  return S_OK;
}

HRESULT CInArchive::Parse()
{
  // UInt32 offset = ReadUInt32();
  // ???? offset == FirstHeader.HeaderLength
  /* UInt32 ehFlags = */ ReadUInt32();
  CBlockHeader bhPages, bhSections, bhEntries, bhStrings, bhLangTables, bhCtlColors, bhData;
  // CBlockHeader bgFont;
  ReadBlockHeader(bhPages);
  ReadBlockHeader(bhSections);
  ReadBlockHeader(bhEntries);
  ReadBlockHeader(bhStrings);
  ReadBlockHeader(bhLangTables);
  ReadBlockHeader(bhCtlColors);
  // ReadBlockHeader(bgFont);
  ReadBlockHeader(bhData);

  _stringsPos = bhStrings.Offset;
  UInt32 pos = GetOffset() + _stringsPos;
  int numZeros0 = 0;
  int numZeros1 = 0;
  int i;
  const int kBlockSize = 256;
  for (i = 0; i < kBlockSize; i++)
  {
    if (pos >= _size || pos + 1 >= _size)
      break;
    char c0 = _data[pos++];
    char c1 = _data[pos++];
    wchar_t c = (c0 | ((wchar_t)c1 << 8));

    if (c >= NS_UN_CODES_START && c < NS_UN_CODES_END)
    {
      if (pos >= _size || pos + 1 >= _size)
        break;
      pos += 2;
      numZeros1++;
    }
    else
    {
      if (c0 == 0 && c1 != 0)
        numZeros0++;
      if (c1 == 0)
        numZeros1++;
    }
    // printf("\nnumZeros0 = %2x %2x", _data[pos + 0],  _data[pos + 1]);
  }
  IsUnicode = (numZeros1 > numZeros0 * 3 + kBlockSize / 16);
  // printf("\nnumZeros0 = %3d    numZeros1 = %3d", numZeros0,  numZeros1);
  return ReadEntries(bhEntries);
}

static bool IsLZMA(const Byte *p, UInt32 &dictionary)
{
  dictionary = Get32(p + 1);
  return (p[0] == 0x5D && p[1] == 0x00 && p[2] == 0x00 && p[5] == 0x00);
}

static bool IsLZMA(const Byte *p, UInt32 &dictionary, bool &thereIsFlag)
{
  if (IsLZMA(p, dictionary))
  {
    thereIsFlag = false;
    return true;
  }
  if (IsLZMA(p + 1, dictionary))
  {
    thereIsFlag = true;
    return true;
  }
  return false;
}

HRESULT CInArchive::Open2(
      DECL_EXTERNAL_CODECS_LOC_VARS2
      )
{
  RINOK(_stream->Seek(0, STREAM_SEEK_CUR, &StreamOffset));

  const UInt32 kSigSize = 4 + 1 + 5 + 1; // size, flag, lzma props, lzma first byte
  BYTE sig[kSigSize];
  RINOK(ReadStream_FALSE(_stream, sig, kSigSize));
  UInt64 position;
  RINOK(_stream->Seek(StreamOffset, STREAM_SEEK_SET, &position));

  _headerIsCompressed = true;
  IsSolid = true;
  FilterFlag = false;

  UInt32 compressedHeaderSize = Get32(sig);
  
  if (compressedHeaderSize == FirstHeader.HeaderLength)
  {
    _headerIsCompressed = false;
    IsSolid = false;
    Method = NMethodType::kCopy;
  }
  else if (IsLZMA(sig, DictionarySize, FilterFlag))
  {
    Method = NMethodType::kLZMA;
  }
  else if (IsLZMA(sig + 4, DictionarySize, FilterFlag))
  {
    IsSolid = false;
    Method = NMethodType::kLZMA;
  }
  else if (sig[3] == 0x80)
  {
    IsSolid = false;
    Method = NMethodType::kDeflate;
  }
  else
  {
    Method = NMethodType::kDeflate;
  }

  _posInData = 0;
  if (!IsSolid)
  {
    _headerIsCompressed = ((compressedHeaderSize & 0x80000000) != 0);
    if (_headerIsCompressed)
      compressedHeaderSize &= ~0x80000000;
    _nonSolidStartOffset = compressedHeaderSize;
    RINOK(_stream->Seek(StreamOffset + 4, STREAM_SEEK_SET, NULL));
  }
  UInt32 unpackSize = FirstHeader.HeaderLength;
  if (_headerIsCompressed)
  {
    // unpackSize = (1 << 23);
    _data.SetCapacity(unpackSize);
    RINOK(Decoder.Init(
        EXTERNAL_CODECS_LOC_VARS
        _stream, Method, FilterFlag, UseFilter));
    size_t processedSize = unpackSize;
    RINOK(Decoder.Read(_data, &processedSize));
    if (processedSize != unpackSize)
      return S_FALSE;
    _size = processedSize;
    if (IsSolid)
    {
      UInt32 size2 = ReadUInt32();
      if (size2 < _size)
        _size = size2;
    }
  }
  else
  {
    _data.SetCapacity(unpackSize);
    _size = (size_t)unpackSize;
    RINOK(ReadStream_FALSE(_stream, (Byte *)_data, unpackSize));
  }
  return Parse();
}

/*
NsisExe =
{
  ExeStub
  Archive  // must start from 512 * N
  #ifndef NSIS_CONFIG_CRC_ANAL
  {
    Some additional data
  }
}

Archive
{
  FirstHeader
  Data
  #ifdef NSIS_CONFIG_CRC_SUPPORT && FirstHeader.ThereIsCrc()
  {
    CRC
  }
}

FirstHeader
{
  UInt32 Flags;
  Byte Signature[16];
  // points to the header+sections+entries+stringtable in the datablock
  UInt32 HeaderLength;
  UInt32 ArchiveSize;
}
*/

HRESULT CInArchive::Open(
    DECL_EXTERNAL_CODECS_LOC_VARS
    IInStream *inStream, const UInt64 *maxCheckStartPosition)
{
  Clear();
  RINOK(inStream->Seek(0, STREAM_SEEK_SET, NULL));
  UInt64 maxSize = ((maxCheckStartPosition != 0) ? *maxCheckStartPosition : 0);
  const UInt32 kStep = 512;
  Byte buffer[kStep];
  
  UInt64 position = 0;
  for (; position <= maxSize; position += kStep)
  {
    RINOK(ReadStream_FALSE(inStream, buffer, kStep));
    if (memcmp(buffer + 4, kSignature, kSignatureSize) == 0)
      break;
  }
  if (position > maxSize)
    return S_FALSE;
  const UInt32 kStartHeaderSize = 4 * 7;
  RINOK(inStream->Seek(0, STREAM_SEEK_END, &_archiveSize));
  RINOK(inStream->Seek(position + kStartHeaderSize, STREAM_SEEK_SET, 0));
  FirstHeader.Flags = Get32(buffer);
  FirstHeader.HeaderLength = Get32(buffer + kSignatureSize + 4);
  FirstHeader.ArchiveSize = Get32(buffer + kSignatureSize + 8);
  if (_archiveSize - position < FirstHeader.ArchiveSize)
    return S_FALSE;

  try
  {
    _stream = inStream;
    HRESULT res = Open2(EXTERNAL_CODECS_LOC_VARS2);
    if (res != S_OK)
      Clear();
    _stream.Release();
    return res;
  }
  catch(...) { Clear(); return S_FALSE; }
}

void CInArchive::Clear()
{
  #ifdef NSIS_SCRIPT
  Script.Empty();
  #endif
  Items.Clear();
  _stream.Release();
}

}}
<file_sep>/7-Zip/CPP/7zip/Archive/Wim/WimIn.cpp
// Archive/WimIn.cpp

#include "StdAfx.h"

#include "../../../../C/CpuArch.h"

#include "Common/IntToString.h"

#include "../../Common/StreamUtils.h"
#include "../../Common/StreamObjects.h"
#include "../../Common/LimitedStreams.h"

#include "../Common/OutStreamWithSha1.h"

#include "WimIn.h"

#define Get16(p) GetUi16(p)
#define Get32(p) GetUi32(p)
#define Get64(p) GetUi64(p)

namespace NArchive{
namespace NWim{

static const int kChunkSizeBits = 15;
static const UInt32 kChunkSize = (1 << kChunkSizeBits);

namespace NXpress {

class CDecoderFlusher
{
  CDecoder *m_Decoder;
public:
  bool NeedFlush;
  CDecoderFlusher(CDecoder *decoder): m_Decoder(decoder), NeedFlush(true) {}
  ~CDecoderFlusher()
  {
    if (NeedFlush)
      m_Decoder->Flush();
    m_Decoder->ReleaseStreams();
  }
};

HRESULT CDecoder::CodeSpec(UInt32 outSize)
{
  {
    Byte levels[kMainTableSize];
    for (int i = 0; i < kMainTableSize; i += 2)
    {
      Byte b = m_InBitStream.DirectReadByte();
      levels[i] = b & 0xF;
      levels[i + 1] = b >> 4;
    }
    if (!m_MainDecoder.SetCodeLengths(levels))
      return S_FALSE;
  }

  while (outSize > 0)
  {
    UInt32 number = m_MainDecoder.DecodeSymbol(&m_InBitStream);
    if (number < 256)
    {
      m_OutWindowStream.PutByte((Byte)number);
      outSize--;
    }
    else
    {
      if (number >= kMainTableSize)
        return S_FALSE;
      UInt32 posLenSlot = number - 256;
      UInt32 posSlot = posLenSlot / kNumLenSlots;
      UInt32 len = posLenSlot % kNumLenSlots;
      UInt32 distance = (1 << posSlot) - 1 + m_InBitStream.ReadBits(posSlot);
      
      if (len == kNumLenSlots - 1)
      {
        len = m_InBitStream.DirectReadByte();
        if (len == 0xFF)
        {
          len = m_InBitStream.DirectReadByte();
          len |= (UInt32)m_InBitStream.DirectReadByte() << 8;
        }
        else
          len += kNumLenSlots - 1;
      }
      
      len += kMatchMinLen;
      UInt32 locLen = (len <= outSize ? len : outSize);

      if (!m_OutWindowStream.CopyBlock(distance, locLen))
        return S_FALSE;
      
      len -= locLen;
      outSize -= locLen;
      if (len != 0)
        return S_FALSE;
    }
  }
  return S_OK;
}

const UInt32 kDictSize = (1 << kNumPosSlots);

HRESULT CDecoder::CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream, UInt32 outSize)
{
  if (!m_OutWindowStream.Create(kDictSize) || !m_InBitStream.Create(1 << 16))
    return E_OUTOFMEMORY;

  CDecoderFlusher flusher(this);

  m_InBitStream.SetStream(inStream);
  m_OutWindowStream.SetStream(outStream);
  m_InBitStream.Init();
  m_OutWindowStream.Init(false);

  RINOK(CodeSpec(outSize));

  flusher.NeedFlush = false;
  return Flush();
}

HRESULT CDecoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream, UInt32 outSize)
{
  try { return CodeReal(inStream, outStream, outSize); }
  catch(const CInBufferException &e) { return e.ErrorCode; } \
  catch(const CLzOutWindowException &e) { return e.ErrorCode; }
  catch(...) { return S_FALSE; }
}

}

static void GetFileTimeFromMem(const Byte *p, FILETIME *ft)
{
  ft->dwLowDateTime = Get32(p);
  ft->dwHighDateTime = Get32(p + 4);
}

HRESULT CUnpacker::Unpack(IInStream *inStream, const CResource &resource, bool lzxMode,
    ISequentialOutStream *outStream, ICompressProgressInfo *progress)
{
  RINOK(inStream->Seek(resource.Offset, STREAM_SEEK_SET, NULL));

  CLimitedSequentialInStream *limitedStreamSpec = new CLimitedSequentialInStream();
  CMyComPtr<ISequentialInStream> limitedStream = limitedStreamSpec;
  limitedStreamSpec->SetStream(inStream);

  if (!copyCoder)
  {
    copyCoderSpec = new NCompress::CCopyCoder;
    copyCoder = copyCoderSpec;
  }
  if (!resource.IsCompressed())
  {
    if (resource.PackSize != resource.UnpackSize)
      return S_FALSE;
    limitedStreamSpec->Init(resource.PackSize);
    return copyCoder->Code(limitedStreamSpec, outStream, NULL, NULL, progress);
  }
  if (resource.UnpackSize == 0)
    return S_OK;
  UInt64 numChunks = (resource.UnpackSize + kChunkSize - 1) >> kChunkSizeBits;
  unsigned entrySize = ((resource.UnpackSize > (UInt64)1 << 32) ? 8 : 4);
  UInt64 sizesBufSize64 = entrySize * (numChunks - 1);
  size_t sizesBufSize = (size_t)sizesBufSize64;
  if (sizesBufSize != sizesBufSize64)
    return E_OUTOFMEMORY;
  if (sizesBufSize > sizesBuf.GetCapacity())
  {
    sizesBuf.Free();
    sizesBuf.SetCapacity(sizesBufSize);
  }
  RINOK(ReadStream_FALSE(inStream, (Byte *)sizesBuf, sizesBufSize));
  const Byte *p = (const Byte *)sizesBuf;
  
  if (lzxMode && !lzxDecoder)
  {
    lzxDecoderSpec = new NCompress::NLzx::CDecoder(true);
    lzxDecoder = lzxDecoderSpec;
    RINOK(lzxDecoderSpec->SetParams(kChunkSizeBits));
  }
  
  UInt64 baseOffset = resource.Offset + sizesBufSize64;
  UInt64 outProcessed = 0;
  for (UInt32 i = 0; i < (UInt32)numChunks; i++)
  {
    UInt64 offset = 0;
    if (i > 0)
    {
      offset = (entrySize == 4) ? Get32(p): Get64(p);
      p += entrySize;
    }
    UInt64 nextOffset = resource.PackSize - sizesBufSize64;
    if (i + 1 < (UInt32)numChunks)
      nextOffset = (entrySize == 4) ? Get32(p): Get64(p);
    if (nextOffset < offset)
      return S_FALSE;

    RINOK(inStream->Seek(baseOffset + offset, STREAM_SEEK_SET, NULL));
    UInt64 inSize = nextOffset - offset;
    limitedStreamSpec->Init(inSize);

    if (progress)
    {
      RINOK(progress->SetRatioInfo(&offset, &outProcessed));
    }
    
    UInt32 outSize = kChunkSize;
    if (outProcessed + outSize > resource.UnpackSize)
      outSize = (UInt32)(resource.UnpackSize - outProcessed);
    UInt64 outSize64 = outSize;
    if (inSize == outSize)
    {
      RINOK(copyCoder->Code(limitedStreamSpec, outStream, NULL, &outSize64, NULL));
    }
    else
    {
      if (lzxMode)
      {
        lzxDecoderSpec->SetKeepHistory(false);
        RINOK(lzxDecoder->Code(limitedStreamSpec, outStream, NULL, &outSize64, NULL));
      }
      else
      {
        RINOK(xpressDecoder.Code(limitedStreamSpec, outStream, outSize));
      }
    }
    outProcessed += outSize;
  }
  return S_OK;
}

HRESULT CUnpacker::Unpack(IInStream *inStream, const CResource &resource, bool lzxMode,
    ISequentialOutStream *outStream, ICompressProgressInfo *progress, Byte *digest)
{
  COutStreamWithSha1 *shaStreamSpec = new COutStreamWithSha1();
  CMyComPtr<ISequentialOutStream> shaStream = shaStreamSpec;
  shaStreamSpec->SetStream(outStream);
  shaStreamSpec->Init(digest != NULL);
  HRESULT result = Unpack(inStream, resource, lzxMode, shaStream, progress);
  if (digest)
    shaStreamSpec->Final(digest);
  return result;
}

static HRESULT UnpackData(IInStream *inStream, const CResource &resource, bool lzxMode, CByteBuffer &buf, Byte *digest)
{
  size_t size = (size_t)resource.UnpackSize;
  if (size != resource.UnpackSize)
    return E_OUTOFMEMORY;
  buf.Free();
  buf.SetCapacity(size);

  CSequentialOutStreamImp2 *outStreamSpec = new CSequentialOutStreamImp2();
  CMyComPtr<ISequentialOutStream> outStream = outStreamSpec;
  outStreamSpec->Init((Byte *)buf, size);

  CUnpacker unpacker;
  return unpacker.Unpack(inStream, resource, lzxMode, outStream, NULL, digest);
}

static const UInt32 kSignatureSize = 8;
static const Byte kSignature[kSignatureSize] = { 'M', 'S', 'W', 'I', 'M', 0, 0, 0 };

void CResource::Parse(const Byte *p)
{
  Flags = p[7];
  PackSize = Get64(p) & (((UInt64)1 << 56) - 1);
  Offset = Get64(p + 8);
  UnpackSize = Get64(p + 16);
}

#define GetResource(p, res) res.Parse(p)

static void GetStream(const Byte *p, CStreamInfo &s)
{
  s.Resource.Parse(p);
  s.PartNumber = Get16(p + 24);
  s.RefCount = Get32(p + 26);
  memcpy(s.Hash, p + 30, kHashSize);
}

static HRESULT ParseDirItem(const Byte *base, size_t pos, size_t size,
    const UString &prefix, CObjectVector<CItem> &items)
{
  for (;;)
  {
    if (pos + 8 > size)
      return S_FALSE;
    const Byte *p = base + pos;
    UInt64 length = Get64(p);
    if (length == 0)
      return S_OK;
    if (pos + 102 > size || pos + length + 8 > size || length > ((UInt64)1 << 62))
      return S_FALSE;
    CItem item;
    item.Attrib = Get32(p + 8);
    // item.SecurityId = Get32(p + 0xC);
    UInt64 subdirOffset = Get64(p + 0x10);
    GetFileTimeFromMem(p + 0x28, &item.CTime);
    GetFileTimeFromMem(p + 0x30, &item.ATime);
    GetFileTimeFromMem(p + 0x38, &item.MTime);
    memcpy(item.Hash, p + 0x40, kHashSize);

    // UInt16 shortNameLen = Get16(p + 98);
    UInt16 fileNameLen = Get16(p + 100);
    
    size_t tempPos = pos + 102;
    if (tempPos + fileNameLen > size)
      return S_FALSE;
    
    wchar_t *sz = item.Name.GetBuffer(prefix.Length() + fileNameLen / 2 + 1);
    MyStringCopy(sz, (const wchar_t *)prefix);
    sz += prefix.Length();
    for (UInt16 i = 0; i + 2 <= fileNameLen; i += 2)
      *sz++ = Get16(base + tempPos + i);
    *sz++ = '\0';
    item.Name.ReleaseBuffer();
    if (fileNameLen == 0 && item.isDir() && !item.HasStream())
    {
      item.Attrib = 0x10; // some swm archives have system/hidden attributes for root
      item.Name.Delete(item.Name.Length() - 1);
    }
    items.Add(item);
    pos += (size_t)length;
    if (item.isDir() && (subdirOffset != 0))
    {
      if (subdirOffset >= size)
        return S_FALSE;
      RINOK(ParseDirItem(base, (size_t)subdirOffset, size, item.Name + WCHAR_PATH_SEPARATOR, items));
    }
  }
}

static HRESULT ParseDir(const Byte *base, size_t size,
    const UString &prefix, CObjectVector<CItem> &items)
{
  size_t pos = 0;
  if (pos + 8 > size)
    return S_FALSE;
  const Byte *p = base + pos;
  UInt32 totalLength = Get32(p);
  // UInt32 numEntries = Get32(p + 4);
  pos += 8;
  {
    /*
    CRecordVector<UInt64> entryLens;
    UInt64 sum = 0;
    for (UInt32 i = 0; i < numEntries; i++)
    {
      if (pos + 8 > size)
        return S_FALSE;
      UInt64 len = Get64(p + pos);
      entryLens.Add(len);
      sum += len;
      pos += 8;
    }
    pos += sum; // skip security descriptors
    while ((pos & 7) != 0)
      pos++;
    if (pos != totalLength)
      return S_FALSE;
    */
    pos = totalLength;
  }
  return ParseDirItem(base, pos, size, prefix, items);
}

static int CompareHashRefs(const int *p1, const int *p2, void *param)
{
  const CRecordVector<CStreamInfo> &streams = *(const CRecordVector<CStreamInfo> *)param;
  return memcmp(streams[*p1].Hash, streams[*p2].Hash, kHashSize);
}

static int CompareStreamsByPos(const CStreamInfo *p1, const CStreamInfo *p2, void * /* param */)
{
  int res = MyCompare(p1->PartNumber, p2->PartNumber);
  if (res != 0)
    return res;
  return MyCompare(p1->Resource.Offset, p2->Resource.Offset);
}

int CompareItems(void *const *a1, void *const *a2, void * /* param */)
{
  const CItem &i1 = **((const CItem **)a1);
  const CItem &i2 = **((const CItem **)a2);

  if (i1.isDir() != i2.isDir())
    return (i1.isDir()) ? 1 : -1;
  if (i1.isDir())
    return -MyStringCompareNoCase(i1.Name, i2.Name);

  int res = MyCompare(i1.StreamIndex, i2.StreamIndex);
  if (res != 0)
    return res;
  return MyStringCompareNoCase(i1.Name, i2.Name);
}

static int FindHash(const CRecordVector<CStreamInfo> &streams,
    const CRecordVector<int> &sortedByHash, const Byte *hash)
{
  int left = 0, right = streams.Size();
  while (left != right)
  {
    int mid = (left + right) / 2;
    int streamIndex = sortedByHash[mid];
    UInt32 i;
    const Byte *hash2 = streams[streamIndex].Hash;
    for (i = 0; i < kHashSize; i++)
      if (hash[i] != hash2[i])
        break;
    if (i == kHashSize)
      return streamIndex;
    if (hash[i] < hash2[i])
      right = mid;
    else
      left = mid + 1;
  }
  return -1;
}

HRESULT CHeader::Parse(const Byte *p)
{
  UInt32 haderSize = Get32(p + 8);
  if (haderSize < 0x74)
    return S_FALSE;
  Version = Get32(p + 0x0C);
  Flags = Get32(p + 0x10);
  if (!IsSupported())
    return S_FALSE;
  UInt32 chunkSize = Get32(p + 0x14);
  if (chunkSize != kChunkSize && chunkSize != 0)
    return S_FALSE;
  memcpy(Guid, p + 0x18, 16);
  PartNumber = Get16(p + 0x28);
  NumParts = Get16(p + 0x2A);
  int offset = 0x2C;
  if (IsNewVersion())
  {
    NumImages = Get32(p + offset);
    offset += 4;
  }
  GetResource(p + offset, OffsetResource);
  GetResource(p + offset + 0x18, XmlResource);
  GetResource(p + offset + 0x30, MetadataResource);
  /*
  if (IsNewVersion())
  {
    if (haderSize < 0xD0)
      return S_FALSE;
    IntegrityResource.Parse(p + offset + 0x4C);
    BootIndex = Get32(p + 0x48);
  }
  */
  return S_OK;
}

HRESULT ReadHeader(IInStream *inStream, CHeader &h)
{
  const UInt32 kHeaderSizeMax = 0xD0;
  Byte p[kHeaderSizeMax];
  RINOK(ReadStream_FALSE(inStream, p, kHeaderSizeMax));
  if (memcmp(p, kSignature, kSignatureSize) != 0)
    return S_FALSE;
  return h.Parse(p);
}

HRESULT ReadStreams(IInStream *inStream, const CHeader &h, CDatabase &db)
{
  CByteBuffer offsetBuf;
  RINOK(UnpackData(inStream, h.OffsetResource, h.IsLzxMode(), offsetBuf, NULL));
  for (size_t i = 0; i + kStreamInfoSize <= offsetBuf.GetCapacity(); i += kStreamInfoSize)
  {
    CStreamInfo s;
    GetStream((const Byte *)offsetBuf + i, s);
    if (s.PartNumber == h.PartNumber)
      db.Streams.Add(s);
  }
  return S_OK;
}

HRESULT OpenArchive(IInStream *inStream, const CHeader &h, CByteBuffer &xml, CDatabase &db)
{
  RINOK(UnpackData(inStream, h.XmlResource, h.IsLzxMode(), xml, NULL));

  RINOK(ReadStreams(inStream, h, db));
  bool needBootMetadata = !h.MetadataResource.IsEmpty();
  if (h.PartNumber == 1)
  {
    int imageIndex = 1;
    for (int j = 0; j < db.Streams.Size(); j++)
    {
      // if (imageIndex > 1) break;
      const CStreamInfo &si = db.Streams[j];
      if (!si.Resource.IsMetadata() || si.PartNumber != h.PartNumber)
        continue;
      Byte hash[kHashSize];
      CByteBuffer metadata;
      RINOK(UnpackData(inStream, si.Resource, h.IsLzxMode(), metadata, hash));
      if (memcmp(hash, si.Hash, kHashSize) != 0)
        return S_FALSE;
      wchar_t sz[16];
      ConvertUInt32ToString(imageIndex++, sz);
      UString s = sz;
      s += WCHAR_PATH_SEPARATOR;
      RINOK(ParseDir(metadata, metadata.GetCapacity(), s, db.Items));
      if (needBootMetadata)
        if (h.MetadataResource.Offset == si.Resource.Offset)
          needBootMetadata = false;
    }
  }
  
  if (needBootMetadata)
  {
    CByteBuffer metadata;
    RINOK(UnpackData(inStream, h.MetadataResource, h.IsLzxMode(), metadata, NULL));
    RINOK(ParseDir(metadata, metadata.GetCapacity(), L"0" WSTRING_PATH_SEPARATOR, db.Items));
  }
  return S_OK;
}


HRESULT SortDatabase(CDatabase &db)
{
  db.Streams.Sort(CompareStreamsByPos, NULL);

  {
    CRecordVector<int> sortedByHash;
    {
      for (int j = 0; j < db.Streams.Size(); j++)
        sortedByHash.Add(j);
      sortedByHash.Sort(CompareHashRefs, &db.Streams);
    }
    
    for (int i = 0; i < db.Items.Size(); i++)
    {
      CItem &item = db.Items[i];
      item.StreamIndex = -1;
      if (item.HasStream())
        item.StreamIndex = FindHash(db.Streams, sortedByHash, item.Hash);
    }
  }

  {
    CRecordVector<bool> used;
    int j;
    for (j = 0; j < db.Streams.Size(); j++)
    {
      const CStreamInfo &s = db.Streams[j];
      used.Add(s.Resource.IsMetadata() && s.PartNumber == 1);
    }
    for (int i = 0; i < db.Items.Size(); i++)
    {
      CItem &item = db.Items[i];
      if (item.StreamIndex >= 0)
        used[item.StreamIndex] = true;
    }
    for (j = 0; j < db.Streams.Size(); j++)
      if (!used[j])
      {
        CItem item;
        item.StreamIndex = j;
        item.HasMetadata = false;
        db.Items.Add(item);
    }
  }
  
  db.Items.Sort(CompareItems, NULL);
  return S_OK;
}

}}
<file_sep>/FingerSuite/FingerSuiteCPL/FingerSuiteCPL.cpp
// FingerSuiteCPL.cpp : Defines the entry point for the DLL application.
//

#include "stdafx.h"
#include "..\Common\atlcplapplet.h"
#include "resource.h"
#include "Commons.h"

static UINT UWM_UPDATECONFIGURATION = ::RegisterWindowMessage(UWM_UPDATECONFIGURATION_MSG);

#include "FingerMenuCPLDlg.h"
#include "AboutDlg.h"



class CFingerSuiteApplet : public CCPlAppletBase<CFingerSuiteApplet>
{
public:
	CFingerMenuCPLDlg1 dlg1;
	CFingerMenuCPLDlg2 dlg2;
	CFingerMenuCPLDlg3 dlg3;
	CFingerMenuCPLDlg4 dlg4;
	CFingerMenuCPLDlg5 dlg5;
	CFingerMenuCPLDlg6 dlg6;
	CFingerMenuCPLDlg7 dlg7;
	CFingerMenuCPLDlg8 dlg8;
	CAboutDlg dlgAbout;

	BOOL ShowApplet(HWND hWnd, LONG_PTR /*lData*/, LPCTSTR pstrCommand)
	{
		BOOL bWithFingerMenu = FALSE;
		CString szPath;
		CString szProgramFilesFolder;
		WCHAR szInstallDir[MAX_PATH];
		WCHAR szValue[MAX_PATH];
		ZeroMemory(szValue, sizeof(szValue));
		if (SHGetSpecialFolderPath(NULL, szValue, CSIDL_PROGRAM_FILES, FALSE))
		{
			szProgramFilesFolder.Format(L"%s", szValue);
		}
		if (RegistryGetString(HKEY_LOCAL_MACHINE, L"Software\\FingerMenu", L"InstallDir", szInstallDir, MAX_PATH) == S_OK)
		{
			szPath.Format(L"%s\\FingerMenu.exe", szInstallDir);
		}
		else
		{
			szPath = szProgramFilesFolder + L"\\FingerMenu\\FingerMenu.exe";
		}
		
		CFindFile finder; 
		if (finder.FindFile(szPath))
		{
			bWithFingerMenu = TRUE;
		}



		dlg1.SetTitle(L"Startup");
		dlg1.m_bWithFingerMenu = bWithFingerMenu;
		if (bWithFingerMenu)
		{
			dlg2.SetTitle(L"Menu options");
			dlg3.SetTitle(L"Menu exclusions");
			dlg7.SetTitle(L"Menu wnd exclusions");
		}
		dlg5.SetTitle(L"Msgbox options");
		dlg6.SetTitle(L"Msgbox exclusions");
		dlg8.SetTitle(L"Msgbox wnd exclusions");
		dlg4.SetTitle(L"Skins");
		dlg4.m_bWithFingerMenu = bWithFingerMenu;
		dlgAbout.SetTitle(L"About");

		// about box
		CString strCredits = "\n\n"
			    "\tFingerMenu v1.12\n\n"
				"\tFingerMsgBox v1.01\n\n"
				"\rdeveloped by:\n"
				"<NAME>\n"
				"<<EMAIL>>\n"
				"\n\n"
				"http://forum.xda-developers.com/\n"
				"                showthread.php?t=459125\n";

		dlgAbout.SetCredits(strCredits);

		CPropertySheet sheet;
		sheet.AddPage(dlg1);
		if (bWithFingerMenu)
		{
			sheet.AddPage(dlg2);
			sheet.AddPage(dlg3);
			sheet.AddPage(dlg7);
		}
		sheet.AddPage(dlg5);
		sheet.AddPage(dlg6);
		sheet.AddPage(dlg8);
		sheet.AddPage(dlg4);
		sheet.AddPage(dlgAbout);
		sheet.SetActivePage(_ttol(pstrCommand));
		if (IDOK == sheet.DoModal(hWnd))
		{
			ReloadConfiguration();
		}

		return TRUE;
	}

private:

	void ReloadConfiguration()
	{
		HWND hWndDest = ::FindWindow(L"FINGER_MENU", NULL);
		if (hWndDest != NULL)
		{
			::PostMessage(hWndDest, UWM_UPDATECONFIGURATION, 0, 0);
			/*
			::PostMessage(hWndDest, WM_CLOSE, 0, 0);
			Sleep(2000);

			CString strApp = L"\\Program Files\\FingerMenu\\FingerMenu.exe";
			SHELLEXECUTEINFO sei;
			memset(&sei, 0, sizeof(sei));
	    
			sei.cbSize       = sizeof(sei);
			sei.fMask        = 0;                
			sei.hwnd         = 0;                
			sei.lpVerb       = L"open";                      // Operation to perform
			sei.lpFile       = strApp;                 // Application name
			sei.lpParameters = NULL;                        // Additional parameters
			sei.lpDirectory  = 0;                           // Default directory
			sei.nShow        = SW_SHOW;
			sei.hInstApp     = 0;
	    
			ShellExecuteEx(&sei);
			*/
		}

		hWndDest = ::FindWindow(L"FINGER_MSGBOX", NULL);
		if (hWndDest != NULL)
		{
			::PostMessage(hWndDest, UWM_UPDATECONFIGURATION, 0, 0);
			/*
			::PostMessage(hWndDest, WM_CLOSE, 0, 0);
			Sleep(2000);

			CString strApp = L"\\Program Files\\FingerMsgbox\\FingerMsgbox.exe";
			SHELLEXECUTEINFO sei;
			memset(&sei, 0, sizeof(sei));
	    
			sei.cbSize       = sizeof(sei);
			sei.fMask        = 0;                
			sei.hwnd         = 0;                
			sei.lpVerb       = L"open";                      // Operation to perform
			sei.lpFile       = strApp;                 // Application name
			sei.lpParameters = NULL;                        // Additional parameters
			sei.lpDirectory  = 0;                           // Default directory
			sei.nShow        = SW_SHOW;
			sei.hInstApp     = 0;
	    
			ShellExecuteEx(&sei);
			*/
		}

	}


};


BEGIN_CPLAPPLET_MAP()
	CPLAPPLET_ENTRY(CFingerSuiteApplet, "FingerSuiteApplet", FingerSuiteApplet)
END_CPLAPPLET_MAP()


CAppModule _Module;
CCPlAppletModule _Applets;


BOOL APIENTRY DllMain( HANDLE hModule, 
                       DWORD  ul_reason_for_call, 
                       LPVOID lpReserved
					 )
{
   if( ul_reason_for_call == DLL_PROCESS_ATTACH ) _Module.Init(NULL, (HMODULE)hModule);
   if( ul_reason_for_call == DLL_PROCESS_DETACH ) _Module.Term();
   return TRUE;
}

extern "C" __declspec(dllexport) LONG APIENTRY CPlApplet(HWND hwndCPl, UINT msg, LPARAM lParam1, LPARAM lParam2)
{
   return _Applets.CPlApplet(hwndCPl, msg, lParam1, lParam2);
}

<file_sep>/7-Zip/CPP/7zip/Compress/PpmdDecoder.h
// PpmdDecoder.h
// 2009-05-30 : <NAME> : Public domain

#ifndef __COMPRESS_PPMD_DECODER_H
#define __COMPRESS_PPMD_DECODER_H

#include "../../Common/MyCom.h"

#include "../ICoder.h"

#include "../Common/OutBuffer.h"

#include "PpmdDecode.h"
#include "RangeCoder.h"

namespace NCompress {
namespace NPpmd {

class CDecoder :
  public ICompressCoder,
  public ICompressSetDecoderProperties2,
  #ifndef NO_READ_FROM_CODER
  public ICompressSetInStream,
  public ICompressSetOutStreamSize,
  public ISequentialInStream,
  #endif
  public CMyUnknownImp
{
  CRangeDecoder _rangeDecoder;

  COutBuffer _outStream;

  CDecodeInfo _info;

  Byte _order;
  UInt32 _usedMemorySize;

  int _remainLen;
  UInt64 _outSize;
  bool _outSizeDefined;
  UInt64 _processedSize;

  HRESULT CodeSpec(UInt32 num, Byte *memStream);

public:

  #ifndef NO_READ_FROM_CODER
  MY_UNKNOWN_IMP4(
      ICompressSetDecoderProperties2,
      ICompressSetInStream,
      ICompressSetOutStreamSize,
      ISequentialInStream)
  #else
  MY_UNKNOWN_IMP1(
      ICompressSetDecoderProperties2)
  #endif

  void ReleaseStreams()
  {
    ReleaseInStream();
    _outStream.ReleaseStream();
  }

  HRESULT Flush() { return _outStream.Flush(); }

  STDMETHOD(CodeReal)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
      const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);

  STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
      const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);

  STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size);

  STDMETHOD(SetInStream)(ISequentialInStream *inStream);
  STDMETHOD(ReleaseInStream)();
  STDMETHOD(SetOutStreamSize)(const UInt64 *outSize);

  #ifndef NO_READ_FROM_CODER
  STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
  #endif

  CDecoder(): _outSizeDefined(false) {}
};

}}

#endif
<file_sep>/7-Zip/CPP/7zip/Compress/PpmdEncode.h
// PpmdEncode.h
// 2009-05-30 : <NAME> : Public domain
// This code is based on <NAME>'s PPMdH code (public domain)

#ifndef __COMPRESS_PPMD_ENCODE_H
#define __COMPRESS_PPMD_ENCODE_H

#include "PpmdContext.h"

namespace NCompress {
namespace NPpmd {

struct CEncodeInfo: public CInfo
{
  void EncodeBinSymbol(int symbol, NRangeCoder::CEncoder *rangeEncoder)
  {
    PPM_CONTEXT::STATE& rs = MinContext->oneState();
    UInt16 &bs = GetBinSumm(rs, GetContextNoCheck(MinContext->Suffix)->NumStats);
    if (rs.Symbol == symbol)
    {
      FoundState = &rs;
      rs.Freq = (Byte)(rs.Freq + (rs.Freq < 128 ? 1: 0));
      rangeEncoder->EncodeBit(bs, TOT_BITS, 0);
      bs = (UInt16)(bs + INTERVAL - GET_MEAN(bs, PERIOD_BITS, 2));
      PrevSuccess = 1;
      RunLength++;
    }
    else
    {
      rangeEncoder->EncodeBit(bs, TOT_BITS, 1);
      bs = (UInt16)(bs - GET_MEAN(bs, PERIOD_BITS, 2));
      InitEsc = ExpEscape[bs >> 10];
      NumMasked = 1;
      CharMask[rs.Symbol] = EscCount;
      PrevSuccess = 0;
      FoundState = NULL;
    }
  }

  void EncodeSymbol1(int symbol, NRangeCoder::CEncoder *rangeEncoder)
  {
    PPM_CONTEXT::STATE* p = GetStateNoCheck(MinContext->Stats);
    if (p->Symbol == symbol)
    {
      PrevSuccess = (2 * (p->Freq) > MinContext->SummFreq);
      RunLength += PrevSuccess;
      rangeEncoder->Encode(0, p->Freq, MinContext->SummFreq);
      (FoundState = p)->Freq += 4;
      MinContext->SummFreq += 4;
      if (p->Freq > MAX_FREQ)
        rescale();
      return;
    }
    PrevSuccess = 0;
    int LoCnt = p->Freq, i = MinContext->NumStats - 1;
    while ((++p)->Symbol != symbol)
    {
      LoCnt += p->Freq;
      if (--i == 0)
      {
        HiBitsFlag = HB2Flag[FoundState->Symbol];
        CharMask[p->Symbol] = EscCount;
        i=(NumMasked = MinContext->NumStats)-1;
        FoundState = NULL;
        do { CharMask[(--p)->Symbol] = EscCount; } while ( --i );
        rangeEncoder->Encode(LoCnt, MinContext->SummFreq - LoCnt, MinContext->SummFreq);
        return;
      }
    }
    rangeEncoder->Encode(LoCnt, p->Freq, MinContext->SummFreq);
    update1(p);
  }

  void EncodeSymbol2(int symbol, NRangeCoder::CEncoder *rangeEncoder)
  {
    int hiCnt, i = MinContext->NumStats - NumMasked;
    UInt32 scale;
    SEE2_CONTEXT* psee2c = makeEscFreq2(i, scale);
    PPM_CONTEXT::STATE* p = GetStateNoCheck(MinContext->Stats) - 1;
    hiCnt = 0;
    do
    {
      do { p++; } while (CharMask[p->Symbol] == EscCount);
      hiCnt += p->Freq;
      if (p->Symbol == symbol)
        goto SYMBOL_FOUND;
      CharMask[p->Symbol] = EscCount;
    }
    while ( --i );
    
    rangeEncoder->Encode(hiCnt, scale, hiCnt + scale);
    scale += hiCnt;
    
    psee2c->Summ = (UInt16)(psee2c->Summ + scale);
    NumMasked = MinContext->NumStats;
    return;
SYMBOL_FOUND:
    
    UInt32 highCount = hiCnt;
    UInt32 lowCount = highCount - p->Freq;
    if ( --i )
    {
      PPM_CONTEXT::STATE* p1 = p;
      do
      {
        do { p1++; } while (CharMask[p1->Symbol] == EscCount);
        hiCnt += p1->Freq;
      }
      while ( --i );
    }
    // SubRange.scale += hiCnt;
    scale += hiCnt;
    rangeEncoder->Encode(lowCount, highCount - lowCount, scale);
    psee2c->update();
    update2(p);
  }

  void EncodeSymbol(int c, NRangeCoder::CEncoder *rangeEncoder)
  {
    if (MinContext->NumStats != 1)
      EncodeSymbol1(c, rangeEncoder);
    else
      EncodeBinSymbol(c, rangeEncoder);
    while ( !FoundState )
    {
      do
      {
        OrderFall++;
        MinContext = GetContext(MinContext->Suffix);
        if (MinContext == 0)
          return; //  S_OK;
      }
      while (MinContext->NumStats == NumMasked);
      EncodeSymbol2(c, rangeEncoder);
    }
    NextContext();
  }
};

}}

#endif
<file_sep>/FBReaderJ/jni/Makefile

NDK_BUILD= /home/taotao/Dev/Tools/android-ndk-r4b/ndk-build
PROJ_DIR = /media/34D0110AD010D448/Interested/FBReaderJ/jni
START =	FBReaderJ

$(START):
	cd $(PROJ_DIR);$(NDK_BUILD) V=1

all:	$(START)

clean:
	cd $(PROJ_DIR);$(NDK_BUILD) clean
<file_sep>/SQLCEHelper/Include/SqlCeHelper.h
// SqlCeHelper class
// based on OLE DB Client class library, <NAME>
// Copyright (C) 2009 by <NAME>
//
//

#pragma once

#include "oledbcli.h"
using namespace OLEDBCLI;

class SqlCeHelper
{
public:
	SqlCeHelper(void);
	~SqlCeHelper(void);

	bool Open(const CString& dbPath);
	void Close();

	//If database exists, delete it and create new one.
	bool CreateDatabase(const CString& dbPath);
	bool DeleteDatabase(const CString& dbPath);

	int	 ExecuteReader(const CString& sql);
	bool IsEndOfRecordSet();
	void MoveNext();
	void CloseReader();

	int		GetRowInt(const long ordinal);
	double	GetRowDouble(const long ordinal);
	CString	GetRowStr(const long ordinal);

	int  ExecuteNonQuery(const CString& sql);

	void BeginTransaction();
	void CommitTransaction();
	void RollbackTransaction();

	CString GetErrorsMessage();

private:
	bool		isOpen;
	CDataSource	dataSource;
	CSession	session;
	CRowset		rowset;
	int			totalRowCount;
	int			currentRowCount;
};
<file_sep>/SQLCEHelper/Source/TableSchema.cpp

#include "stdafx.h"

using namespace OLEDBCLI;

typedef CTable* CTablePtr;


CSchema::CSchema(CSession& session)
:	m_session	(session)
{
}


CSchema::~CSchema()
{
	Clear();
}


void CSchema::Clear()
{
	size_t i;

	for(i = 0; i < m_tables.GetCount(); ++i)
		delete m_tables[i];

	m_tables.RemoveAll();
}


// CSchema::Load
//
//		Loads all tables
//
HRESULT CSchema::Load()
{
	CTablesRowset		tables(m_session);		// http://msdn.microsoft.com/en-us/library/ms716980(VS.85).aspx
	HRESULT				hr;
	CRowset				rowset;

	Clear();

	// Open the tables rowset
	hr = tables.Open(NULL, NULL, NULL, NULL, rowset);
	if(SUCCEEDED(hr))
	{
		CString	strTable;

		for(hr = rowset.MoveFirst(); hr == S_OK; hr = rowset.MoveNext())
		{
			if(rowset.GetValue(3, strTable))
			{
				CTableSchema*	pTableSchema = new CTableSchema(strTable, this);

				if(pTableSchema != NULL)
					m_tables.Add(pTableSchema);
				else
					return E_OUTOFMEMORY;
			}
		}
		hr = S_OK;
	}

	return hr;
}


//-------------------------------------------------------------------------
//
//	CTableSchema - manipulates the table schema
//
//-------------------------------------------------------------------------

CTableSchema::CTableSchema()
:	m_pSchema		(NULL),
	m_bLoaded		(false)
{
}


CTableSchema::CTableSchema(LPCTSTR pszTableName, CSchema* pSchema)
:	m_pSchema		(pSchema),
	m_strName		(pszTableName),
	m_bLoaded		(false)
{
}


CTableSchema::CTableSchema(const CTableSchema& tableSchema)
:	m_bLoaded	(false)
{
	Copy(tableSchema);
}


CTableSchema::~CTableSchema()
{
	Clear();
}


void CTableSchema::Clear()
{
	size_t i;

	for(i = 0; i < m_columns.GetCount(); ++i)
		delete m_columns[i];
	m_columns.RemoveAll();

	for(i = 0; i < m_foreignKeys.GetCount(); ++i)
		delete m_foreignKeys[i];
	m_foreignKeys.RemoveAll();

	for(i = 0; i < m_indexes.GetCount(); ++i)
		delete m_indexes[i];
	m_indexes.RemoveAll();

	for(i = 0; i < m_uniques.GetCount(); ++i)
		delete m_uniques[i];
	m_uniques.RemoveAll();
}


bool CTableSchema::Copy(const OLEDBCLI::CTableSchema &tableSchema)
{
	Clear();

	m_columns		.Copy(tableSchema.m_columns);
	m_indexes		.Copy(tableSchema.m_indexes);
	m_foreignKeys	.Copy(tableSchema.m_foreignKeys);
	m_uniques		.Copy(tableSchema.m_uniques);
	
	m_strName = tableSchema.GetName();
	m_pSchema = tableSchema.GetSchema();
	m_bLoaded = tableSchema.IsLoaded();

	return true;
}


// CTableSchema::FindIndex
//
//		Seraches for an index in the list given a name and returns its position or -1 if not found.
//
int CTableSchema::FindIndex(LPCTSTR pszName)
{
	int	i, n = m_indexes.GetCount();

	for(i = 0; i < n; ++i)
	{
		if(wcsicmp(pszName, m_indexes[i]->GetName()) == 0)
			return i;
	}
	return -1;
}


// CTableSchema::FindUnique
//
//		Seraches for an unique constraint in the list given a name and returns its position or -1 if not found.
//
int CTableSchema::FindUnique(LPCTSTR pszName)
{
	int	i, n = m_uniques.GetCount();

	for(i = 0; i < n; ++i)
	{
		if(wcsicmp(pszName, m_uniques[i]->GetName()) == 0)
			return i;
	}
	return -1;
}


// CTableSchema::GetPrimaryKey
//
//		Gets the CIndex object that represents the PRIMARY KEY, if any
//
CIndex* CTableSchema::GetPrimaryKey()
{
	int	i, n = m_indexes.GetCount();

	for(i = 0; i < n; ++i)
	{
		if(m_indexes[i]->IsPrimaryKey())
			return m_indexes[i];
	}
	return NULL;
}


// CTableSchema::FindForeignKey
//
//		Searches for a foreign key in the list given a name and returns its position or -1 if not found.
//
int CTableSchema::FindForeignKey(LPCTSTR pszName)
{
	int i, n = m_foreignKeys.GetCount();

	for(i = 0; i < n; ++i)
	{
		if(wcsicmp(pszName, m_foreignKeys[i]->GetName()) == 0)
			return i;
	}
	return -1;
}


// CTableSchema::Load
//
//		Loads the table schema
//
HRESULT CTableSchema::Load(OLEDBCLI::CSession &session, LPCTSTR pszTableName)
{
	if(m_bLoaded)
		return S_OK;

	HRESULT				hr;
	CTableDefinition	tableDef;

	Clear();

	hr = tableDef.GetDefinition(session, m_strName);
	if(FAILED(hr))
		return hr;

	// Populate the column array
	tableDef.FillColumnArray(m_columns);

	// Populate the foreign key array
	tableDef.FillForeignKeyArray(m_foreignKeys);

	// Populate the foreign key array
	tableDef.FillUniqueArray(m_uniques);

	// Load and filter the indexes
	hr = LoadIndexes(session);

	m_bLoaded = true;

	return hr;
}


// CTableSchema::Load
//
//		Loads the schema from a table created through a CSchema.
//		These have a non-NULL m_pSchema.
//
HRESULT CTableSchema::Load()
{
	if(m_pSchema == NULL)
		return E_FAIL;

	return Load(m_pSchema->GetSession(), m_strName);
}


// CTableSchema::LoadIndexes
//
//		Loads the table's indexes
//
HRESULT CTableSchema::LoadIndexes(CSession& session)
{
	HRESULT			hr;
	CRowset			rowset;
	CIndexesRowset	indexes(session);

	// List all indexes for the given table
	hr = indexes.Open(NULL, NULL, NULL, NULL, m_strName, rowset);
	if(SUCCEEDED(hr))
	{
		CString	strName,
				strColumn;

		for(hr = rowset.MoveFirst(); hr == S_OK; hr = rowset.MoveNext())
		{
			int		iIndex,
					iOrdinal;
			short	nCollation;
			CIndex*	pIndex	= NULL;

			if(!rowset.GetValue(6, strName))
				return E_FAIL;

			// Skip known unique constraints
			if(FindUnique(strName) != -1)
				continue;

			if(!rowset.GetValue(17, iOrdinal))
				return E_FAIL;
			if(!rowset.GetValue(18, strColumn))
				return E_FAIL;
			if(!rowset.GetValue(21, nCollation))
				return E_FAIL;

			iIndex = FindIndex(strName);
			if(iIndex == -1)
			{
				bool	bPrimary, bUnique;

				rowset.GetValue(7, bPrimary);
				rowset.GetValue(8, bUnique);

				pIndex = new CIndex(strName, bUnique, bPrimary);

				if(pIndex == NULL)
					return E_OUTOFMEMORY;

				m_indexes.Add(pIndex);
				iIndex = 0;
			}

			if(pIndex == NULL)
				pIndex = m_indexes[iIndex];

			pIndex->AddColumn(strColumn, nCollation, (ULONG)iOrdinal);
		}
		hr = S_OK;
	}

	return hr;
}
<file_sep>/FBReader/zlibrary/ui/src/qt4/dialogs/ZLQtSelectionDialog.cpp
/*
 * Copyright (C) 2004-2010 <NAME> <<EMAIL>>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 * 02110-1301, USA.
 */

#include <QtGui/QApplication>
#include <QtGui/QLineEdit>
#include <QtGui/QPixmap>
#include <QtGui/QLayout>
#include <QtGui/QPushButton>
#include <QtGui/QButtonGroup>
#include <QtGui/QKeyEvent>

#include <ZLibrary.h>

#include "ZLQtSelectionDialog.h"
#include "ZLQtDialogManager.h"
#include "ZLQtUtil.h"

ZLQListWidget::ZLQListWidget(QWidget *parent) : QListWidget(parent) {
}

void ZLQListWidget::keyPressEvent(QKeyEvent *event) {
	if (event->key() == Qt::Key_Return) {
		emit returnPressed();
	}
	QListWidget::keyPressEvent(event);
}

ZLQtSelectionDialogItem::ZLQtSelectionDialogItem(QListWidget *listWidget, const ZLTreeNodePtr node) : QListWidgetItem(listWidget), myNode(node) {
	setText(::qtString(node->displayName()));
}

ZLQtSelectionDialog::ZLQtSelectionDialog(const std::string &caption, ZLTreeHandler &handler) : QDialog(qApp->activeWindow()), ZLDesktopSelectionDialog(handler) {
	setWindowTitle(::qtString(caption));

	QVBoxLayout *mainLayout = new QVBoxLayout(this);

	myStateLine = new QLineEdit(this);
	myStateLine->setEnabled(!this->handler().isOpenHandler());
	mainLayout->addWidget(myStateLine);

	myListWidget = new ZLQListWidget(this);
	mainLayout->addWidget(myListWidget);

	QWidget *group = new QWidget(this);
	QGridLayout *buttonLayout = new QGridLayout(group);
	buttonLayout->setColumnStretch(0, 3);
	mainLayout->addWidget(group);

	QPushButton *okButton = new QPushButton(group);
	okButton->setText(::qtButtonName(ZLDialogManager::OK_BUTTON));
	buttonLayout->addWidget(okButton, 0, 1);
	connect(okButton, SIGNAL(clicked()), this, SLOT(accept()));

	QPushButton *cancelButton = new QPushButton(group);
	cancelButton->setText(::qtButtonName(ZLDialogManager::CANCEL_BUTTON));
	buttonLayout->addWidget(cancelButton, 0, 2);
	connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));

 	connect(myListWidget, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(runNodeSlot()));
 	connect(myListWidget, SIGNAL(returnPressed()), this, SLOT(runNodeSlot()));
 	connect(myStateLine, SIGNAL(returnPressed()), this, SLOT(accept()));

	ZLSelectionDialog::update();
}

ZLQtSelectionDialog::~ZLQtSelectionDialog() {
	for (std::map<std::string,QIcon*>::const_iterator it = myIcons.begin(); it != myIcons.end(); ++it) {
		delete it->second;
	}
}

QIcon &ZLQtSelectionDialog::getIcon(const ZLTreeNodePtr node) {
	const std::string &pixmapName = node->pixmapName();
	std::map<std::string,QIcon*>::const_iterator it = myIcons.find(pixmapName);
	if (it == myIcons.end()) {
		QPixmap pixmap((ZLibrary::ApplicationImageDirectory() + ZLibrary::FileNameDelimiter + pixmapName + ".png").c_str());
		QIcon *icon = new QIcon(pixmap);
		myIcons[pixmapName] = icon;
		myListWidget->setIconSize(pixmap.size());
		return *icon;
	} else {
		return *it->second;
	}
}

void ZLQtSelectionDialog::keyPressEvent(QKeyEvent *event) {
	if ((event != 0) && (event->key() == Qt::Key_Escape)) {
		reject();
	}
}

void ZLQtSelectionDialog::updateStateLine() {
	myStateLine->setText(::qtString(handler().stateDisplayName()));
}

void ZLQtSelectionDialog::updateList() {
	myListWidget->clear();

	const std::vector<ZLTreeNodePtr> &subnodes = handler().subnodes();

	if (subnodes.size() > 0) {
		for (std::vector<ZLTreeNodePtr>::const_iterator it = subnodes.begin(); it != subnodes.end(); ++it) {
		 	QListWidgetItem *item = new ZLQtSelectionDialogItem(myListWidget, *it);
			item->setIcon(getIcon(*it));
		}
	}
}

void ZLQtSelectionDialog::selectItem(int index) {
	if ((index >= 0) && (index < myListWidget->count())) {
		myListWidget->setCurrentRow(index);
	}
}

void ZLQtSelectionDialog::exitDialog() {
	QDialog::accept();
}

void ZLQtSelectionDialog::runNodeSlot() {
	QListWidgetItem *item = myListWidget->currentItem();
	if (item != 0) {
		runNode(((ZLQtSelectionDialogItem*)item)->node());
	}
}

void ZLQtSelectionDialog::accept() {
	if (handler().isOpenHandler()) {
		runNodeSlot();
	} else {
		runState((const char*)myStateLine->text().toUtf8());
	}
}

bool ZLQtSelectionDialog::run() {
	return QDialog::exec() == Accepted;
}
<file_sep>/7-Zip/CPP/7zip/UI/Explorer/ContextMenuFlags.h
// ContextMenuFlags.h

#ifndef __SEVENZIP_CONTEXTMENUFLAGS_H
#define __SEVENZIP_CONTEXTMENUFLAGS_H

namespace NContextMenuFlags
{
  const UINT32 kExtract = 1 << 0;
  const UINT32 kExtractHere = 1 << 1;
  const UINT32 kExtractTo = 1 << 2;
  // const UINT32 kExtractEach = 1 << 3;

  const UINT32 kTest = 1 << 4;

  const UINT32 kOpen = 1 << 5;

  const UINT32 kCompress = 1 << 8;
  const UINT32 kCompressTo7z = 1 << 9;
  const UINT32 kCompressEmail = 1 << 10;
  const UINT32 kCompressTo7zEmail = 1 << 11;

  const UINT32 kCompressToZip = 1 << 12;
  const UINT32 kCompressToZipEmail = 1 << 13;

  inline UINT32 GetDefaultFlags() {
    return
      kOpen | kTest |
      kExtract | kExtractHere | kExtractTo |
      kCompress | kCompressEmail |
      kCompressTo7z | kCompressTo7zEmail |
      kCompressToZip | kCompressToZipEmail; }
}

#endif
<file_sep>/SQLCEHelper/Source/DbValue.cpp


#include "stdafx.h"
#include "Currency.h"

using namespace OLEDBCLI;


//-------------------------------------------------------------------------
//
//	CDbValueRef
//
//-------------------------------------------------------------------------


CDbValueRef::CDbValueRef()
:	m_pLength	(NULL),
	m_pStatus	(NULL),
	m_wType		(DBTYPE_EMPTY),
	m_nMaxSize	(0),
	m_pValue	(NULL),
	m_bIsLong	(false)
{
}


CDbValueRef::CDbValueRef(BOUNDCOLUMN *pBoundColumn, BYTE *pData)
{
	ATLASSERT(pBoundColumn != NULL);
	ATLASSERT(pData != NULL);

	m_pLength	= (ULONG*)		(pData + pBoundColumn->obLength);
	m_pStatus	= (DBSTATUS*)	(pData + pBoundColumn->obStatus);
	m_pValue	= pData + pBoundColumn->obValue;
	m_wType		= pBoundColumn->wType;
	m_bIsLong	= (pBoundColumn->dwFlags & DBCOLUMNFLAGS_ISLONG) != 0;
	m_nMaxSize	= pBoundColumn->ulColumnSize;
}


CDbValueRef::CDbValueRef(DBTYPE wType, ULONG* pLength, DBSTATUS* pStatus, BYTE* pValue)
:	m_pLength	(pLength),
	m_pStatus	(pStatus),
	m_wType		(wType),
	m_nMaxSize	(0),
	m_pValue	(pValue),
	m_bIsLong	(false)
{
	ATLASSERT(pLength != NULL);
	ATLASSERT(pStatus != NULL);
	ATLASSERT(pValue != NULL);
}


void CDbValueRef::FreeStorage()
{
	if(*m_pStatus == DBSTATUS_S_OK)
	{
		IUnknown*	pUnknown = *(IUnknown**)m_pValue;

		if(pUnknown != NULL)
		{
			pUnknown->Release();
			*(IUnknown**)m_pValue = NULL;
		}
	}
}


bool CDbValueRef::GetValue(bool& bVal)
{
	ATLASSERT(m_pStatus != NULL);
	ATLASSERT(m_pValue != NULL);

	if(*m_pStatus == DBSTATUS_S_OK)
	{
		switch(m_wType)
		{
		case DBTYPE_BOOL:	bVal = *(VARIANT_BOOL*)m_pValue != 0;	return true;
		case DBTYPE_UI1:	bVal = *(BYTE*)m_pValue != 0;			return true;
		case DBTYPE_UI2:	bVal = *(USHORT*)m_pValue != 0;			return true;
		case DBTYPE_I2:		bVal = *(SHORT*)m_pValue != 0;			return true;
		case DBTYPE_UI4:	bVal = *(UINT*)m_pValue != 0;			return true;
		case DBTYPE_I4:		bVal = *(INT*)m_pValue != 0;			return true;
		}
	}
	return false;
}


// CDbValueRef::SetValue
//
//		Sets the column value as a boolean
//
bool CDbValueRef::SetValue(bool bVal)
{
	bool	bSet	= true;

	ATLASSERT(m_pStatus != NULL);
	ATLASSERT(m_pValue != NULL);

	switch(m_wType)
	{
	case DBTYPE_BOOL:	*(VARIANT_BOOL*)m_pValue	= bVal ? VARIANT_TRUE : VARIANT_FALSE;	break;
	case DBTYPE_UI1:	*(BYTE*)m_pValue			= bVal ? 1 : 0;							break;
	case DBTYPE_UI2:	*(USHORT*)m_pValue			= bVal ? 1 : 0;							break;
	case DBTYPE_I2:		*(SHORT*)m_pValue			= bVal ? 1 : 0;							break;
	case DBTYPE_UI4:	*(UINT*)m_pValue			= bVal ? 1 : 0;							break;
	case DBTYPE_I4:		*(int*)m_pValue				= bVal ? 1 : 0;							break;
	case DBTYPE_I8:		*(__int64*)m_pValue 		= bVal ? 1 : 0;							break;
	case DBTYPE_R4:		*(float*)m_pValue			= bVal ? 1.0f : 0.0f;					break;
	case DBTYPE_R8:		*(double*)m_pValue			= bVal ? 1.0 : 0.0;						break;

	default:
		bSet = false;
	}

	if(bSet)
		*m_pStatus = DBSTATUS_S_OK;
	return bSet;
}


// CDbValueRef::GetValue
//
//		Gets the column value as a short
//
bool CDbValueRef::GetValue(short& nVal)
{
	ATLASSERT(m_pStatus != NULL);
	ATLASSERT(m_pValue != NULL);

	if(*m_pStatus == DBSTATUS_S_OK)
	{
		switch(m_wType)
		{
		case DBTYPE_I8:		nVal = (short)(*(__int64*)m_pValue);	return true;
		case DBTYPE_UI4:	nVal = (short)(*(USHORT*)m_pValue);		return true;
		case DBTYPE_I4:		nVal = (short)(*(int*)m_pValue);		return true;
		case DBTYPE_UI2:	nVal = (short)(*(USHORT*)m_pValue);		return true;
		case DBTYPE_BOOL:
		case DBTYPE_I2:		nVal = *(short*)m_pValue;				return true;
		case DBTYPE_UI1:	nVal = (short)(*(BYTE*)m_pValue);		return true;
		case DBTYPE_R4:		nVal = (short)(*(float*)m_pValue);		return true;
		case DBTYPE_R8:		nVal = (short)(*(double*)m_pValue);		return true;
		case DBTYPE_CY:
			{
				CY	cy = *(CY*)m_pValue;
				nVal = short(cy.int64 / 10000);
			}
			return true;
		}
	}
	return false;
}


// CDbValueRef::GetValue
//
//		Gets the column value as an integer
//
bool CDbValueRef::GetValue(int &nVal)
{
	ATLASSERT(m_pStatus != NULL);
	ATLASSERT(m_pValue != NULL);

	if(*m_pStatus == DBSTATUS_S_OK)
	{
		switch(m_wType)
		{
		case DBTYPE_UI1:	nVal = (int)(*(BYTE*)m_pValue);		return true;
		case DBTYPE_UI2:	nVal = (int)(*(USHORT*)m_pValue);	return true;
		case DBTYPE_I2:		nVal = (int)(*(short*)m_pValue);	return true;
		case DBTYPE_UI4:	nVal = (int)(*(UINT*)m_pValue);		return true;
		case DBTYPE_I4:		nVal = *(int*)m_pValue;				return true;
		case DBTYPE_I8:		nVal = (int)(*(__int64*)m_pValue);	return true;
		case DBTYPE_R4:		nVal = (int)(*(float*)m_pValue);	return true;
		case DBTYPE_R8:		nVal = (int)(*(double*)m_pValue);	return true;
		case DBTYPE_CY:
			{
				CY	cy = *(CY*)m_pValue;
				nVal = int(cy.int64 / 10000);
			}
			return true;
		}
	}
	return false;
}


// CDbValueRef::SetValue
//
//		Sets the column value as an integer
//
bool CDbValueRef::SetValue(int nVal)
{
	bool	bSet	= true;

	ATLASSERT(m_pStatus != NULL);
	ATLASSERT(m_pValue != NULL);

	switch(m_wType)
	{
	case DBTYPE_UI1:	*(BYTE*)m_pValue	= (BYTE)nVal;	break;
	case DBTYPE_UI2:	*(USHORT*)m_pValue	= (USHORT)nVal;	break;
	case DBTYPE_I2:		*(SHORT*)m_pValue	= (SHORT)nVal;	break;
	case DBTYPE_UI4:	*(UINT*)m_pValue	= (UINT)nVal;	break;
	case DBTYPE_I4:		*(int*)m_pValue		= nVal;			break;
	case DBTYPE_I8:		*(__int64*)m_pValue = nVal;			break;
	case DBTYPE_R4:		*(float*)m_pValue	= (float)nVal;	break;
	case DBTYPE_R8:		*(double*)m_pValue	= nVal;			break;

	default:
		bSet = false;
	}

	if(bSet)
		*m_pStatus = DBSTATUS_S_OK;
	return bSet;
}


// CDbValueRef::GetValue
//
//		Gets the column value as an int64
//
bool CDbValueRef::GetValue(__int64& nVal)
{
	ATLASSERT(m_pStatus != NULL);
	ATLASSERT(m_pValue != NULL);

	if(*m_pStatus == DBSTATUS_S_OK)
	{
		switch(m_wType)
		{
		case DBTYPE_I8:		nVal = *(__int64*)m_pValue;				return true;
		case DBTYPE_UI4:	nVal = *(UINT*)m_pValue;				return true;
		case DBTYPE_I4:		nVal = *(int*)m_pValue;					return true;
		case DBTYPE_UI2:	nVal = *(USHORT*)m_pValue;				return true;
		case DBTYPE_I2:		nVal = *(short*)m_pValue;				return true;
		case DBTYPE_UI1:	nVal = *(BYTE*)m_pValue;				return true;
		case DBTYPE_R4:		nVal = (__int64)(*(float*)m_pValue);	return true;
		case DBTYPE_R8:		nVal = (__int64)(*(double*)m_pValue);	return true;
		}
	}
	return false;
}


// CDbValueRef::SetValue
//
//		Sets the column value as an int64
//
bool CDbValueRef::SetValue(__int64 nVal)
{
	bool	bSet	= true;

	ATLASSERT(m_pStatus != NULL);
	ATLASSERT(m_pValue != NULL);

	switch(m_wType)
	{
	case DBTYPE_UI1:	*(BYTE*)m_pValue	= (BYTE)nVal;	break;
	case DBTYPE_UI2:	*(USHORT*)m_pValue	= (USHORT)nVal;	break;
	case DBTYPE_I2:		*(short*)m_pValue	= (short)nVal;	break;
	case DBTYPE_UI4:	*(UINT*)m_pValue	= (UINT)nVal;	break;
	case DBTYPE_I4:		*(int*)m_pValue		= (int)nVal;	break;
	case DBTYPE_I8:		*(__int64*)m_pValue = nVal;			break;
	case DBTYPE_R4:		*(float*)m_pValue	= (float)nVal;	break;
	case DBTYPE_R8:		*(double*)m_pValue	= (double)nVal;	break;
	case DBTYPE_CY:
		{
			CY	cy;

			cy.int64		= nVal * 10000;
			*(CY*)m_pValue	= cy;
		}
		break;

	default:
		bSet = false;
	}

	if(bSet)
		*m_pStatus = DBSTATUS_S_OK;
	return bSet;
}


// CDbValueRef::GetValue
//
//		Gets the column value as a float
//
bool CDbValueRef::GetValue(float& fltVal)
{
	ATLASSERT(m_pStatus != NULL);
	ATLASSERT(m_pValue != NULL);

	if(*m_pStatus == DBSTATUS_S_OK)
	{
		switch(m_wType)
		{
		case DBTYPE_I8:		fltVal = (float)(*(__int64*)m_pValue);	return true;
		case DBTYPE_UI4:	fltVal = (float)(*(UINT*)m_pValue);		return true;
		case DBTYPE_I4:		fltVal = (float)(*(int*)m_pValue);		return true;
		case DBTYPE_UI2:	fltVal = (float)(*(USHORT*)m_pValue);	return true;
		case DBTYPE_I2:		fltVal = *(short*)m_pValue;				return true;
		case DBTYPE_UI1:	fltVal = *(BYTE*)m_pValue;				return true;
		case DBTYPE_R4:		fltVal = *(float*)m_pValue;				return true;
		case DBTYPE_R8:		fltVal = (float)(*(double*)m_pValue);	return true;
		case DBTYPE_CY:
			{
				CY	cy = *(CY*)m_pValue;

				fltVal = float((double)cy.int64 / 10000.0);
			}
			return true;
		}
	}
	return false;
}


// CDbValueRef::SetValue
//
//		Sets the column value as a float
//
bool CDbValueRef::SetValue(float fltVal)
{
	bool	bSet	= true;

	ATLASSERT(m_pStatus != NULL);
	ATLASSERT(m_pValue != NULL);

	switch(m_wType)
	{
	case DBTYPE_UI1:	*(BYTE*)m_pValue	= (BYTE)fltVal;		break;
	case DBTYPE_UI2:	*(USHORT*)m_pValue	= (USHORT)fltVal;	break;
	case DBTYPE_I2:		*(short*)m_pValue	= (short)fltVal;	break;
	case DBTYPE_UI4:	*(UINT*)m_pValue	= (UINT)fltVal;		break;
	case DBTYPE_I4:		*(int*)m_pValue		= (int)fltVal;		break;
	case DBTYPE_I8:		*(__int64*)m_pValue = (__int64)fltVal;	break;
	case DBTYPE_R4:		*(float*)m_pValue	= fltVal;			break;
	case DBTYPE_R8:		*(double*)m_pValue	= fltVal;			break;
	case DBTYPE_CY:		
		{
			CY	cyVal;

			cyVal.int64 = __int64(fltVal * 10000);
			*(CY*)m_pValue = cyVal;
		}
		break;

	default:
		bSet = false;
	}

	if(bSet)
		*m_pStatus = DBSTATUS_S_OK;
	return bSet;
}


// CDbValueRef::GetValue
//
//		Gets the column value as a double
//
bool CDbValueRef::GetValue(double& dblVal)
{
	ATLASSERT(m_pStatus != NULL);
	ATLASSERT(m_pValue != NULL);

	if(*m_pStatus == DBSTATUS_S_OK)
	{
		switch(m_wType)
		{
		case DBTYPE_I8:		dblVal = (double)(*(__int64*)m_pValue);	return true;
		case DBTYPE_UI4:	dblVal = (double)(*(UINT*)m_pValue);	return true;
		case DBTYPE_I4:		dblVal = (double)(*(int*)m_pValue);		return true;
		case DBTYPE_UI2:	dblVal = (double)(*(USHORT*)m_pValue);	return true;
		case DBTYPE_I2:		dblVal = *(short*)m_pValue;				return true;
		case DBTYPE_UI1:	dblVal = *(BYTE*)m_pValue;				return true;
		case DBTYPE_R4:		dblVal = *(float*)m_pValue;				return true;
		case DBTYPE_R8:		dblVal = *(double*)m_pValue;			return true;
		case DBTYPE_CY:
			{
				CY	cy = *(CY*)m_pValue;

				dblVal = double(cy.int64 / 10000.0);
			}
			return true;
		}
	}
	return false;
}


// CDbValueRef::SetValue
//
//		Sets the column value as double
//
bool CDbValueRef::SetValue(double dblVal)
{
	bool	bSet	= true;

	ATLASSERT(m_pStatus != NULL);
	ATLASSERT(m_pValue != NULL);

	switch(m_wType)
	{
	case DBTYPE_UI1:	*(BYTE*)m_pValue	= (BYTE)dblVal;		break;
	case DBTYPE_I2:		*(short*)m_pValue	= (short)dblVal;	break;
	case DBTYPE_I4:		*(int*)m_pValue		= (int)dblVal;		break;
	case DBTYPE_I8:		*(__int64*)m_pValue = (__int64)dblVal;	break;
	case DBTYPE_R4:		*(float*)m_pValue	= (float)dblVal;	break;
	case DBTYPE_R8:		*(double*)m_pValue	= dblVal;			break;
	case DBTYPE_CY:		
		{
			CY	cyVal;

			cyVal.int64 = __int64(dblVal * 10000);
			*(CY*)m_pValue = cyVal;
		}
		break;

	default:
		bSet = false;
	}

	if(bSet)
		*m_pStatus = DBSTATUS_S_OK;
	return bSet;
}


// CDbValueRef::GetValue
//
//		Gets the column value as a CY
//
bool CDbValueRef::GetValue(CY& cyVal)
{
	ATLASSERT(m_pStatus != NULL);
	ATLASSERT(m_pValue != NULL);

	if(*m_pStatus == DBSTATUS_S_OK)
	{
		switch(m_wType)
		{
		case DBTYPE_R4:
			{
				float val = *(float*)m_pValue;

				cyVal.int64 = __int64(val * 10000);
			}
			return true;

		case DBTYPE_R8:
			{
				double val = *(double*)m_pValue;

				cyVal.int64 = __int64(val * 10000);
			}
			return true;

		case DBTYPE_CY:
			cyVal = *(CY*)m_pValue;
			return true;
		}
	}
	return false;
}


// CDbValueRef::SetValue
//
//		Sets the column value as a CY
//
bool CDbValueRef::SetValue(CY cyVal)
{
	bool	bSet	= true;

	ATLASSERT(m_pStatus != NULL);
	ATLASSERT(m_pValue != NULL);

	switch(m_wType)
	{
	case DBTYPE_I2:
		*(short*)m_pValue = int(cyVal.int64 / 10000);
		break;

	case DBTYPE_I4:
		*(int*)m_pValue = int(cyVal.int64 / 10000);
		break;

	case DBTYPE_I8:
		*(__int64*)m_pValue = cyVal.int64 / 10000;
		break;

	case DBTYPE_R4:
		*(float*)m_pValue = float(cyVal.int64) / 10000;
		break;

	case DBTYPE_R8:
		*(double*)m_pValue = double(cyVal.int64) / 10000;
		break;

	case DBTYPE_CY:
		*(CY*)m_pValue = cyVal;
		break;

	default:
		bSet = false;
	}

	return bSet;
}


// CDbValueRef::GetValue
//
//		Gets the column value as a DB_NUMERIC
//
bool CDbValueRef::GetValue(DB_NUMERIC& numVal)
{
	ATLASSERT(m_pStatus != NULL);
	ATLASSERT(m_pValue != NULL);

	if(*m_pStatus == DBSTATUS_S_OK && m_wType == DBTYPE_NUMERIC)
	{
		numVal = *(DB_NUMERIC*)m_pValue;
		return true;
	}
	return false;
}


// CDbValueRef::GetValue
//
//		Gets the column value as a DBTIMESTAMP
//
bool CDbValueRef::GetValue(DBTIMESTAMP& dtVal)
{
	ATLASSERT(m_pStatus != NULL);
	ATLASSERT(m_pValue != NULL);

	if(*m_pStatus == DBSTATUS_S_OK && m_wType == DBTYPE_DBTIMESTAMP)
	{
		dtVal = *(DBTIMESTAMP*)m_pValue;
		return true;
	}
	return false;
}


// CDbValueRef::SetValue
//
//		Sets the column value as a DBTIMESTAMP
//
bool CDbValueRef::SetValue(DBTIMESTAMP& dtVal)
{
	ATLASSERT(m_pStatus != NULL);
	ATLASSERT(m_pValue != NULL);

	if(m_wType == DBTYPE_DBTIMESTAMP)
	{
		*(DBTIMESTAMP*)m_pValue	= dtVal;
		*m_pStatus				= DBSTATUS_S_OK;
		return true;
	}
	return false;
}


// CDbValueRef::GetValue
//
//		Gets the column value as a GUID
//
bool CDbValueRef::GetValue(GUID& guid)
{
	ATLASSERT(m_pStatus != NULL);
	ATLASSERT(m_pValue != NULL);

	if(*m_pStatus == DBSTATUS_S_OK && m_wType == DBTYPE_GUID)
	{
		guid = *(GUID*)m_pValue;
		return true;
	}
	return false;
}


// CDbValueRef::SetValue
//
//		Sets the column value as a GUID
//
bool CDbValueRef::SetValue(GUID& guid)
{
	ATLASSERT(m_pStatus != NULL);
	ATLASSERT(m_pValue != NULL);

	if(m_wType == DBTYPE_GUID)
	{
		*(GUID*)m_pValue	= guid;
		*m_pStatus			= DBSTATUS_S_OK;
		return true;
	}
	return false;
}


// CDbValueRef::GetValue
//
//		Gets the column value as a CString
//
bool CDbValueRef::GetValue(CString& strVal)
{
	ATLASSERT(m_pStatus != NULL);
	ATLASSERT(m_pValue != NULL);

	if(*m_pStatus == DBSTATUS_S_OK)
	{
		switch(m_wType)
		{
		case DBTYPE_UI1:
			strVal.Format(_T("%d"), *(BYTE*)m_pValue);
			return true;

		case DBTYPE_I2:
			strVal.Format(_T("%d"), *(short*)m_pValue);
			return true;

		case DBTYPE_I4:
			strVal.Format(_T("%d"), *(int*)m_pValue);
			return true;

		case DBTYPE_DBTIMESTAMP:
			{
				DBTIMESTAMP	dt = *(DBTIMESTAMP*)m_pValue;

				strVal.Format(_T("%d-%02d-%02d %02d:%02d:%02d"), dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second);
			}
			return true;

		case DBTYPE_CY:
			{
				CY			cy	= *(CY*)m_pValue;
				CCurrency	curr(cy);

				strVal = curr.Format(CCurrency::Currency);
			}
			return true;

		case DBTYPE_WSTR:
			if(m_bIsLong)
			{
				ISequentialStream*	pStream;
				TCHAR				buf[2048];
				ULONG				cb;
				
				pStream = *(ISequentialStream**)m_pValue;

				ATLASSERT(pStream != NULL);

				//
				// Enter a loop to read the string from the stream
				//
				do
				{
					pStream->Read(buf, sizeof(buf) - sizeof(TCHAR), &cb);

					if(cb > 0)
					{
						int	i = cb / sizeof(TCHAR);

						buf[i] = 0;
						strVal += buf;
					}
				} while(cb >= sizeof(buf));

				pStream->Release();
			}
			else
			{
				TCHAR*	pszText = (TCHAR*)m_pValue;
				ULONG	nLength	= *m_pLength / sizeof(wchar_t);

				pszText[nLength] = 0;

				strVal = pszText;
			}
			return true;
		}
	}
	else
		strVal.Empty();
	return false;
}


// CDbValueRef::SetValue
//
//		Sets the column value as a string
//
bool CDbValueRef::SetValue(LPCTSTR pszVal)
{
	ATLASSERT(m_pStatus != NULL);
	ATLASSERT(m_pValue != NULL);

	if(m_wType == DBTYPE_WSTR)
	{
		if(m_bIsLong)
		{
			CBlobStream* pBlobStream = new CBlobStream;

			if(pBlobStream == NULL)
				return false;

			ULONG	ulWritten;
			size_t	nStrLen	= wcslen(pszVal);
			HRESULT	hr		= pBlobStream->Write(pszVal, (nStrLen + 1) * sizeof(TCHAR), &ulWritten);

			if(SUCCEEDED(hr))
			{
				*(CBlobStream**)m_pValue	= pBlobStream;
				*m_pStatus					= DBSTATUS_S_OK;
				*m_pLength					= nStrLen;
			}
			else
			{
				delete pBlobStream;

				*(CBlobStream**)m_pValue	= NULL;
				*m_pStatus					= DBSTATUS_S_ISNULL;
				*m_pLength					= 0;
				return false;
			}
		}
		else
		{
			size_t	nStrLen = wcslen(pszVal);
			ULONG	nMaxLen = m_nMaxSize / sizeof(wchar_t);

			if(nStrLen > nMaxLen)
			{
				TCHAR*	pszBuf = (TCHAR*)m_pValue;

				wcsncpy(pszBuf, pszVal, nMaxLen);
				pszBuf[nMaxLen] = 0;
				nStrLen = nMaxLen;
			}
			else
			{
				wcscpy((TCHAR*)m_pValue, pszVal);
			}

			*m_pLength	= nStrLen;
			*m_pStatus	= DBSTATUS_S_OK;
		}

		return true;
	}
	return false;
}


// CDbValueRef::GetValue
//
//		Gets the column value into a byte buffer.
//		Does not work for BLOB columns.
//
bool CDbValueRef::GetValue(BYTE *pVal)
{
	ULONG	nLength;

	ATLASSERT(m_pStatus != NULL);
	ATLASSERT(m_pLength	!= NULL);
	ATLASSERT(m_pValue	!= NULL);
	ATLASSERT(pVal		!= NULL);

	nLength = * m_pLength;

	if(*m_pStatus == DBSTATUS_S_OK)
	{
		switch(m_wType)
		{
		case DBTYPE_I2:
		case DBTYPE_I4:
		case DBTYPE_I8:
		case DBTYPE_R4:
		case DBTYPE_R8:
		case DBTYPE_CY:
		case DBTYPE_NUMERIC:
		case DBTYPE_DBTIMESTAMP:
		case DBTYPE_GUID:
			memcpy(pVal, m_pValue, nLength);
			return true;

		case DBTYPE_WSTR:
			nLength *= sizeof(wchar_t);

		case DBTYPE_BYTES:
			if(!m_bIsLong)
			{
				memcpy(pVal, m_pValue, nLength);
				return true;
			}
		}
	}
	return false;
}


bool CDbValueRef::SetValue(BYTE *pVal, ULONG nLength)
{
	ATLASSERT(m_pStatus != NULL);
	ATLASSERT(m_pValue != NULL);

	if((m_wType == DBTYPE_BYTES) && m_bIsLong)
	{
		CBlobStream* pBlobStream = new CBlobStream;

		if(pBlobStream == NULL)
			return false;

		ULONG	ulWritten;
		HRESULT	hr		= pBlobStream->Write(pVal, nLength, &ulWritten);

		if(SUCCEEDED(hr))
		{
			*(CBlobStream**)m_pValue	= pBlobStream;
			*m_pStatus					= DBSTATUS_S_OK;
			*m_pLength					= nLength;
		}
		else
		{
			delete pBlobStream;

			*(CBlobStream**)m_pValue	= NULL;
			*m_pStatus					= DBSTATUS_S_ISNULL;
			*m_pLength					= 0;
			return false;
		}
	}
	else
	{
		if(nLength > m_nMaxSize)
			nLength = m_nMaxSize;

		memcpy(m_pValue, pVal, nLength);

		*m_pLength	= nLength;
		*m_pStatus	= DBSTATUS_S_OK;
	}


	return true;
}


// CDbValueRef::GetValue
//
//		Gets the column value as a BLOB
//
bool CDbValueRef::GetValue(CBlobStream& blob)
{
	ULONG	nLength,
			nWritten;
	HRESULT	hr;

	ATLASSERT(m_pStatus != NULL);
	ATLASSERT(m_pLength	!= NULL);
	ATLASSERT(m_pValue	!= NULL);

	blob.Clear();

	nLength = *m_pLength;

	if(*m_pStatus == DBSTATUS_S_OK)
	{
		switch(m_wType)
		{
		case DBTYPE_I2:
		case DBTYPE_I4:
		case DBTYPE_I8:
		case DBTYPE_R4:
		case DBTYPE_R8:
		case DBTYPE_CY:
		case DBTYPE_NUMERIC:
		case DBTYPE_DBTIMESTAMP:
		case DBTYPE_GUID:
			hr = blob.Write(m_pValue, nLength, &nWritten);
			if(SUCCEEDED(hr) && nWritten == nLength)
				return true;

		case DBTYPE_WSTR:
			nLength *= sizeof(wchar_t);

		case DBTYPE_BYTES:
			if(!m_bIsLong)
			{
				hr = blob.Write(m_pValue, nLength, &nWritten);
				if(SUCCEEDED(hr) && nWritten == nLength)
					return true;
			}
			else
			{
				ISequentialStream*	pStream = *(ISequentialStream**)m_pValue;

				hr = blob.WriteFromStream(pStream, nLength, &nWritten);
				pStream->Release();
				if(SUCCEEDED(hr) && nWritten == nLength)
					return true;
			}
		}
	}
	return false;
}


//-------------------------------------------------------------------------
//
//	CDbValue
//
//-------------------------------------------------------------------------


CDbValue::CDbValue()
:	CDbValueRef	(DBTYPE_EMPTY, &m_nLength, &m_status, (BYTE*)&m_val),
	m_nLength	(0),
	m_status	(DBSTATUS_S_ISNULL)
{
	memset(&m_val, 0, sizeof(m_val));
}


CDbValue::CDbValue(const CDbValue& dbVal)
{
	InternalCopy(dbVal);
}


CDbValue::CDbValue(DBTYPE type, ULONG nLength, DBSTATUS status, const void* pData)
:	CDbValueRef	(DBTYPE_EMPTY, &m_nLength, &m_status, (BYTE*)&m_val),
	m_nLength	(nLength),
	m_status	(status)
{
	memset(&m_val, 0, sizeof(m_val));

//	SetValue(type, nLength, status, pData);
}


CDbValue::~CDbValue()
{
	Clear();
}


void CDbValue::Initialize(DBTYPE type, ULONG nLength, ULONG nMaxLength, bool bIsLong)
{
	Clear();

	m_wType		= type;
	m_nMaxSize	= nMaxLength;
	m_nLength	= nLength;
	m_bIsLong	= bIsLong;
}


// CDbValue::InternalCopy
//
//		Copies two CDbValues
//
void CDbValue::InternalCopy(const CDbValue& dbVal)
{
	Clear();

	m_nLength	= dbVal.m_nLength;
	m_status	= dbVal.m_status;
	m_wType		= dbVal.m_wType;

	switch(m_wType)
	{
	case DBTYPE_WSTR:
		m_val.pszVal = new TCHAR[m_nLength + 1];
		if(m_val.pszVal != NULL)
			wcscpy(m_val.pszVal, dbVal.m_val.pszVal);
		else
			m_status = DBSTATUS_E_OUTOFSPACE;
		break;

	case DBTYPE_BYTES:
		m_val.pVal = new BYTE[m_nLength];
		if(m_val.pVal != NULL)
			memcpy(m_val.pVal, dbVal.m_val.pVal, m_nLength);
		else
			m_status = DBSTATUS_E_OUTOFSPACE;
		break;

	default:
		memcpy(&m_val, &dbVal.m_val, sizeof(m_val));
	}
}


// CDbValue::Clear
//
//		Clears the value
//
void CDbValue::Clear()
{
	if(m_wType == DBTYPE_WSTR)
	{
		delete [] m_val.pszVal;
		m_val.pszVal = NULL;
	}
	else if(m_wType == DBTYPE_BYTES)
	{
		delete [] m_val.pVal;
		m_val.pVal = NULL;
	}
	else
	{
		memset(&m_val, 0, sizeof(m_val));
	}

	m_nLength	= 0;
	m_status	= DBSTATUS_S_ISNULL;
}


// CDbValue::operator =
//
//		Assigns a CDbValue object to another
//
CDbValue& CDbValue::operator =(const OLEDBCLI::CDbValue &dbVal)
{
	if(this != &dbVal)
		InternalCopy(dbVal);
	return *this;
}


// CDbValue::SetValue
//
//		Sets a CDbValue from an OLE DB column definition
//
void CDbValue::SetValue(DBTYPE type, ULONG nLength, DBSTATUS status, const void* pData)
{
	Clear();

	m_wType		= type;
	m_nLength	= nLength;
	m_status	= status;

	if(status != DBSTATUS_S_OK)
		return;

	ATLASSERT(pData != NULL);

	switch(type)
	{
	case DBTYPE_UI1:	m_val.bVal		= *(BYTE*)pData;			break;
	case DBTYPE_I2:		m_val.shortVal	= *(short*)pData;			break;
	case DBTYPE_I4:		m_val.intVal	= *(int*)pData;				break;
	case DBTYPE_I8:		m_val.lngVal	= *(__int64*)pData;			break;
	case DBTYPE_R4:		m_val.fltVal	= *(float*)pData;			break;
	case DBTYPE_R8:		m_val.dblVal	= *(double*)pData;			break;
	case DBTYPE_CY:		m_val.cyVal		= *(CY*)pData;				break;
	case DBTYPE_GUID:	m_val.guidVal	= *(GUID*)pData;			break;
	case DBTYPE_BOOL:	m_val.boolVal	= *(VARIANT_BOOL*)pData;	break;

	case DBTYPE_DBTIMESTAMP:
		memcpy(&m_val.dtVal, pData, sizeof(m_val.dtVal));
		break;

	case DBTYPE_NUMERIC:
		memcpy(&m_val.numVal, pData, sizeof(m_val.numVal));
		break;

	case DBTYPE_BYTES:
		m_val.pVal = new BYTE[nLength];
		if(m_val.pVal != NULL)
		{
			memcpy(m_val.pVal, pData, nLength);
		}
		else
		{
			m_status	= DBSTATUS_S_ISNULL;
			m_nLength	= 0;
		}
		break;

	case DBTYPE_WSTR:
		m_val.pszVal = new TCHAR[nLength + 1];
		if(m_val.pszVal != NULL)
		{
			memset(m_val.pszVal, 0, sizeof(TCHAR) * (nLength + 1));
			memcpy(m_val.pszVal, pData, nLength * sizeof(TCHAR));
		}
		else
		{
			m_status	= DBSTATUS_S_ISNULL;
			m_nLength	= 0;
		}
		break;
	}
}


// CDbValue::SetValue
//
//		Sets a CDbValue from a BLOB
//
HRESULT CDbValue::SetValue(DBTYPE type, ULONG nLength, DBSTATUS status, ISequentialStream* pStream)
{
	HRESULT hr	= E_FAIL;

	Clear();

	m_wType		= type;
	m_nLength	= nLength;
	m_status	= status;

	if(status != DBSTATUS_S_OK)
		return S_OK;

	ATLASSERT(pStream != NULL);

	ULONG	nRead;

	if(type == DBTYPE_WSTR)
	{
		m_val.pszVal = new TCHAR[nLength + 1];
		if(m_val.pszVal != NULL)
		{
			memset(m_val.pszVal, 0, sizeof(TCHAR) * (nLength + 1));
			hr = pStream->Read(m_val.pszVal, nLength * sizeof(TCHAR), &nRead);
		}
		else
		{
			m_nLength	= 0;
			m_status	= DBSTATUS_S_ISNULL;
			hr			= E_OUTOFMEMORY;
		}
	}
	else if(type == DBTYPE_BYTES)
	{
		m_val.pVal = new BYTE[nLength];
		if(m_val.pVal != NULL)
		{
			hr = pStream->Read(m_val.pVal, nLength, &nRead);
		}
		else
		{
			m_nLength		= 0;
			m_status	= DBSTATUS_S_ISNULL;
			hr			= E_OUTOFMEMORY;
		}
	}

	return hr;
}


// CDbValue::SetValue
//
//		Sets a string value allowing the string buffer to increase its maximum size.
//		This is useful for command parameters where values are indirectly set through CDbValues.
//
bool CDbValue::SetValue(LPCTSTR pszVal)
{
	if(m_wType == DBTYPE_WSTR)
	{
		ULONG	nLength	= wcslen(pszVal) + 1;

		if(m_bIsLong)
		{
			SetValue(DBTYPE_WSTR, nLength, DBSTATUS_S_OK, pszVal);
			if(m_nMaxSize < nLength)
				m_nMaxSize = nLength;
		}
		else
		{
			if(nLength > m_nMaxSize)
				nLength = m_nMaxSize;
			SetValue(DBTYPE_WSTR, nLength, DBSTATUS_S_OK, pszVal);
		}

		return true;
	}
	return false;
}


bool CDbValue::SetValue(BYTE* pValue, ULONG nSize)
{
	if(m_wType == DBTYPE_BYTES)
	{
		if(m_bIsLong)
		{
			SetValue(DBTYPE_BYTES, nSize, DBSTATUS_S_OK, pValue);
			if(m_nMaxSize < nSize)
				m_nMaxSize = nSize;
		}
		else
		{
			if(nSize > m_nMaxSize)
				nSize = m_nMaxSize;
			SetValue(DBTYPE_BYTES, nSize, DBSTATUS_S_OK, pValue);
		}

		return true;
	}
	return false;
}


// CDbValue::GetDataPtr
//
//		Gets the underlying data pointer.
//
void* CDbValue::GetDataPtr()
{
	if(m_wType == DBTYPE_WSTR)
		return m_val.pszVal;

	if(m_wType == DBTYPE_BYTES)
		return m_val.pVal;

	return &m_val;
}
<file_sep>/7-Zip/CPP/7zip/UI/FileManager/AppState.h
// AppState.h

#ifndef __APP_STATE_H
#define __APP_STATE_H

#include "Windows/Synchronization.h"

#include "ViewSettings.h"

void inline AddUniqueStringToHead(UStringVector &list,
    const UString &string)
{
  for(int i = 0; i < list.Size();)
    if (string.CompareNoCase(list[i]) == 0)
      list.Delete(i);
    else
      i++;
  list.Insert(0, string);
}

class CFastFolders
{
  NWindows::NSynchronization::CCriticalSection _criticalSection;
public:
  UStringVector Strings;
  void SetString(int index, const UString &string)
  {
    NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
    while(Strings.Size() <= index)
      Strings.Add(UString());
    Strings[index] = string;
  }
  UString GetString(int index)
  {
    NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
    if (index >= Strings.Size())
      return UString();
    return Strings[index];
  }
  void Save()
  {
    NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
    SaveFastFolders(Strings);
  }
  void Read()
  {
    NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
    ReadFastFolders(Strings);
  }
};

class CFolderHistory
{
  NWindows::NSynchronization::CCriticalSection _criticalSection;
  UStringVector Strings;
  void Normalize()
  {
    const int kMaxSize = 100;
    if (Strings.Size() > kMaxSize)
      Strings.Delete(kMaxSize, Strings.Size() - kMaxSize);
  }
  
public:
  
  void GetList(UStringVector &foldersHistory)
  {
    NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
    foldersHistory = Strings;
  }
  
  void AddString(const UString &string)
  {
    NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
    AddUniqueStringToHead(Strings, string);
    Normalize();
  }
  
  void RemoveAll()
  {
    NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
    Strings.Clear();
  }
  
  void Save()
  {
    NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
    SaveFolderHistory(Strings);
  }
  
  void Read()
  {
    NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
    ReadFolderHistory(Strings);
    Normalize();
  }
};

struct CAppState
{
  CFastFolders FastFolders;
  CFolderHistory FolderHistory;
  void Save()
  {
    FastFolders.Save();
    FolderHistory.Save();
  }
  void Read()
  {
    FastFolders.Read();
    FolderHistory.Read();
  }
};


#endif<file_sep>/FingerSuite/FingerMenuDLL/InterceptEngine.cpp
#include "stdafx.h"
#include <windows.h>
#include "hook\SysDecls.h" 
#include "hook\undocWM5.h"
#include "InterceptEngine.h"
#include <tlhelp32.h>
#include "..\Common\log\logger.h"
#include "..\Common\utils.h"

// globals
HINSTANCE   g_hInst = NULL; 
UINT        UWM_INTERCEPT_MENU;
UINT        UWM_INTERCEPT_MSGBOX;
UINT        UWM_INTERCEPT_NOTIF;
UINT        UWM_NOTIF_POPUP;
HWND        g_hWndHHTaskBar = 0;

#pragma data_seg("SH_DATA")
// for SH_WMGR apiset replacement
CINFO *   m_pNewWmgrApiSet = NULL;
CINFO *   m_pOldWmgrApiSet = NULL;
// end SH_WMGR
// for SH_SHELL apiset replacement
CINFO *   m_pNewShellApiSet = NULL;
CINFO *   m_pOldShellApiSet = NULL;
// end SH_SHELL

HWND      g_hWndServer = 0;
HWND      g_hWndServerMsgBox = 0;
HWND      g_hWndServerNotif = 0;

HANDLE    m_hDestProcess = NULL;
HINSTANCE m_hDllInst = 0;

BOOL      g_bTrackPopupMenuExResult = FALSE;
int       g_iMsgBoxResult = 0;

PFNVOID   g_pOrigTrackPopupMenuEx = NULL;
PFNVOID   g_pOrigMessageBoxW = NULL;

PFNVOID   g_pOrigSHNotificationAddII = NULL;
PFNVOID   g_pOrigSHNotificationUpdateII = NULL;
PFNVOID   g_pOrigSHNotificationRemoveII = NULL;

#pragma data_seg()
#pragma comment( linker, "/SECTION:SH_DATA,SRW" )



__declspec(dllexport) 
HANDLE CreateWaitEvent(LPTSTR szEvt)
{
	HANDLE hEvt = CreateEvent(NULL, TRUE, FALSE, szEvt);
	if ( (hEvt != NULL) && (GetLastError() == ERROR_ALREADY_EXISTS) )
		ResetEvent(hEvt);
	return hEvt;
}

__declspec(dllexport) 
BOOL ResetWaitEvent(LPTSTR szEvt)
{
	HANDLE hEvt = OpenEvent(EVENT_ALL_ACCESS, FALSE, szEvt);
	if (hEvt != NULL)
	{
		BOOL bRes = ResetEvent(hEvt);
		CloseHandle(hEvt);
		return bRes;
	}
	
	return FALSE;
}

__declspec(dllexport) 
BOOL SignalWaitEvent(LPTSTR szEvt)
{
	BOOL bRes = FALSE;
	//wprintf(L"SignalWaitEvent...");

	HANDLE hEvt = OpenEvent(EVENT_ALL_ACCESS, FALSE, szEvt);
	if (hEvt != NULL)
	{
		bRes = SetEvent(hEvt);
		CloseHandle(hEvt);
	}
	//wprintf(L"...done\n");	
	return bRes;
}


/*-------------------------------------------------------------
   FUNCTION: HookTrackPopupMenuEx
   PURPOSE:  Interceptor for TrackPopupMenuEx API
   Parameters and return value are identical to the documented
   HookTrackPopupMenuEx function.
-------------------------------------------------------------*/
BOOL HookTrackPopupMenuEx
(
        HMENU       p_hmenu,
        UINT        p_uFlags,
        int         p_x,
        int         p_y,
        HWND        p_hWnd,
        LPTPMPARAMS p_lptpm
)
{
	BOOL bResult = FALSE;

	if (!(IsWindow(g_hWndServer)))
		goto normal;

	if (p_hWnd == g_hWndHHTaskBar)
		goto normal;

	UINT msgToBeSent = UWM_INTERCEPT_MENU;
	//if (p_uFlags & TPM_RETURNCMD)

	TRACKPOPUPMENUINFO info;
	info.hMenu = p_hmenu;
	info.hWnd = p_hWnd;
	info.uFlags = p_uFlags;

	BOOL bInterceptRes =  (BOOL)SendMessageRemote(g_hWndServer, msgToBeSent, (WPARAM)0, (LPARAM)&info, sizeof(TRACKPOPUPMENUINFO));

	if (bInterceptRes) 
	{
		goto normal;
	}

	HANDLE arr[1];
	arr[0] = CreateWaitEvent(EVT_FNGRMENU);
	
	DWORD dwRes;
	MSG msg;
	do
	{
		dwRes = MsgWaitForMultipleObjectsEx(1, arr, INFINITE, QS_ALLINPUT, 0);
		if (dwRes != WAIT_OBJECT_0 + 0)
		{
			if (GetMessage( &msg, NULL, 0, 0 ))
			{
				TranslateMessage( &msg );
				DispatchMessage( &msg );
			}
		}
	}
	while (dwRes != WAIT_OBJECT_0 + 0);

	CloseHandle(arr[0]);


	if (g_bTrackPopupMenuExResult == -1)
	{
		goto normal;
	}

	if (p_uFlags & TPM_RETURNCMD)
	{
		// calling process should call SetTrackPopupMenuExResult
		return g_bTrackPopupMenuExResult; 
	}
	else
		return bResult;

normal:
	
    if(g_pOrigTrackPopupMenuEx)
    {
        bResult = ((BOOL (*)(
            HMENU, UINT, int, int,
            HWND, LPTPMPARAMS))g_pOrigTrackPopupMenuEx)
            (
				p_hmenu,
				p_uFlags,
				p_x,
				p_y,
				p_hWnd,
				p_lptpm
            );
    }//if(g_pOrigTrackPopupMenuEx)
    
    return bResult;
}//HANDLE HookTrackPopupMenuEx

/*-------------------------------------------------------------
BOOL HookTrackPopupMenuEx
(
        HMENU       p_hmenu,
        UINT        p_uFlags,
        int         p_x,
        int         p_y,
        HWND        p_hWnd,
        LPTPMPARAMS p_lptpm
)
{
	BOOL bResult = FALSE;

	if (!(IsWindow(g_hWndServer)))
		goto normal;

	if (p_hWnd == g_hWndHHTaskBar)
		goto normal;

	UINT msg = 0;
	if (p_uFlags & TPM_RETURNCMD)
		msg = UWM_INTERCEPT_MENU2;
	else
		msg = UWM_INTERCEPT_MENU1;

	BOOL bInterceptRes =  (BOOL)SendMessage(g_hWndServer, msg, (WPARAM)p_hmenu, (LPARAM)p_hWnd);

	if (bInterceptRes) 
	{
		goto normal;
	}

	HANDLE hEvt = CreateWaitEvent(EVT_FNGRMENU);
	DWORD dwRes = WaitForSingleObject(hEvt, INFINITE);
	if (dwRes == WAIT_OBJECT_0)
	{

	}

	CloseHandle(hEvt);

	if (g_bTrackPopupMenuExResult == -1)
	{
		goto normal;
	}

	if (p_uFlags & TPM_RETURNCMD)
	{
		// calling process should call SetTrackPopupMenuExResult
		return g_bTrackPopupMenuExResult; 
	}
	else
		return bResult;

normal:
	
    if(g_pOrigTrackPopupMenuEx)
    {
        bResult = ((BOOL (*)(
            HMENU, UINT, int, int,
            HWND, LPTPMPARAMS))g_pOrigTrackPopupMenuEx)
            (
				p_hmenu,
				p_uFlags,
				p_x,
				p_y,
				p_hWnd,
				p_lptpm
            );
    }//if(g_pOrigTrackPopupMenuEx)
    
    return bResult;
}

int HookMessageBoxW(
                HWND    hwnd,
        const   WCHAR*  szText,
        const   WCHAR*  szCaption,
                UINT    uType,
                MSG*    pMsg
        )
{
	int iResult = 0;

	if (!(IsWindow(g_hWndServerMsgBox)))
		goto normal;

	LPMSGBOXINFO info = (MSGBOXINFO*)g_sharedMsgBoxMem.GetValue();

	ZeroMemory(info, sizeof(MSGBOXINFO));
	wsprintf(info->szCaption, L"%s", szCaption);
	wsprintf(info->szText, L"%s", szText);

	//g_sharedMsgBoxMem.SetValue(&info, sizeof(info));

	BOOL bInterceptRes =  (BOOL)SendMessage(g_hWndServerMsgBox, UWM_INTERCEPT_MSGBOX, (WPARAM)hwnd, (LPARAM)uType);

	if (bInterceptRes) 
	{
		goto normal;
	}

	HANDLE hEvt = CreateWaitEvent(EVT_FNGRMSGBOX);
	DWORD dwRes = WaitForSingleObject(hEvt, INFINITE);
	if (dwRes == WAIT_OBJECT_0)
	{
		if (g_iMsgBoxResult == -1)
		{
			goto normal;
		}

		return g_iMsgBoxResult;
	}
normal:
	
	if (g_pOrigMessageBoxW)
    {
		iResult = ((int (*)(HWND, 
			                const WCHAR*, 
						    const WCHAR*, 
						    UINT, 
						    MSG*))g_pOrigMessageBoxW)
            (
              hwnd,
              szText,
              szCaption,
              uType,
              pMsg
            );
    }//if(g_pOrigMessageBoxW)
    
    return iResult;
}
-------------------------------------------------------------*/


int HookMessageBoxW(
                HWND    hwnd,
        const   WCHAR*  szText,
        const   WCHAR*  szCaption,
                UINT    uType,
                MSG*    pMsg
        )
{
	int iResult = 0;

	if (!(IsWindow(g_hWndServerMsgBox)))
		goto normal;

	MSGBOXINFO info;
	info.hWnd = hwnd;
	info.uType = uType;
	wsprintf(info.szCaption, L"%s", szCaption);
	wsprintf(info.szText, L"%s", szText);

	BOOL bInterceptRes =  (BOOL)SendMessageRemote(g_hWndServerMsgBox, UWM_INTERCEPT_MSGBOX, (WPARAM)0, (LPARAM)&info, sizeof(MSGBOXINFO));

	if (bInterceptRes) 
	{
		goto normal;
	}

	HANDLE arr[1];
	arr[0] = CreateWaitEvent(EVT_FNGRMSGBOX);
	
	DWORD dwRes;
	do
	{
		dwRes = MsgWaitForMultipleObjectsEx(1, arr, INFINITE, QS_ALLINPUT, 0);
		if (dwRes != WAIT_OBJECT_0 + 0)
		{
			MSG msg;
			if (GetMessage( &msg, NULL, 0, 0 ))
			{
				TranslateMessage( &msg );
				DispatchMessage( &msg );
			}
		}
	}
	while (dwRes != WAIT_OBJECT_0 + 0);

	CloseHandle(arr[0]);

	if (dwRes == WAIT_OBJECT_0)
	{
		if (g_iMsgBoxResult == -1)
		{
			goto normal;
		}

		return g_iMsgBoxResult;
	}




normal:
	
	if (g_pOrigMessageBoxW)
    {
		iResult = ((int (*)(HWND, 
			                const WCHAR*, 
						    const WCHAR*, 
						    UINT, 
						    MSG*))g_pOrigMessageBoxW)
            (
              hwnd,
              szText,
              szCaption,
              uType,
              pMsg
            );
    }//if(g_pOrigMessageBoxW)
    
    return iResult;
}




/*-------------------------------------------------------------------
   FUNCTION: DllMain
   PURPOSE: Regular DLL initialization point. Used to initialize
    per-process data structures, such as the tracing engine
-------------------------------------------------------------------*/
BOOL WINAPI DllMain(HANDLE hInstance, DWORD dwReason, 
                    LPVOID /*lpReserved*/)
{
    TCHAR l_szPath[_MAX_PATH];
    *l_szPath = 0;
    GetModuleFileName(NULL, l_szPath, _MAX_PATH);
    

    static long s_lLoadCount = 0;

	switch (dwReason)
	{
		case DLL_PROCESS_ATTACH:
        {
            g_hInst = (HINSTANCE)hInstance;

			UWM_INTERCEPT_MENU = RegisterWindowMessage(UWM_INTERCEPT_MENU_MSG);
			UWM_INTERCEPT_MSGBOX = RegisterWindowMessage(UWM_INTERCEPT_MSGBOX_MSG);
			UWM_INTERCEPT_NOTIF = RegisterWindowMessage(UWM_INTERCEPT_NOTIF_MSG);
			UWM_NOTIF_POPUP = RegisterWindowMessage(UWM_NOTIF_POPUP_MSG);

			g_hWndHHTaskBar = FindWindow(L"HHTaskBar", NULL);

            if(InterlockedIncrement(&s_lLoadCount) == 1)
            {
                DWORD l_dwOldProtect;
				BOOL bRes = VirtualProtect(&m_pNewWmgrApiSet, sizeof(m_pNewWmgrApiSet),
                    PAGE_READWRITE | PAGE_NOCACHE, &l_dwOldProtect);
            }
			
        }
        break;
        case DLL_PROCESS_DETACH:
        {
            if(InterlockedDecrement(&s_lLoadCount) == 0)
            {
            }

        }
        break;
    }
    return TRUE;
}//BOOL WINAPI DllMain


__declspec(dllexport) 
BOOL SetHWndServer(HWND hWndServer)
{
	g_hWndServer = hWndServer;
	return TRUE;
}

__declspec(dllexport) 
BOOL SetHWndServerMsgBox(HWND hWndServer)
{
	g_hWndServerMsgBox = hWndServer;
	return TRUE;
}

__declspec(dllexport) 
BOOL SetHWndServerNotif(HWND hWndServer)
{
	g_hWndServerNotif = hWndServer;
	return TRUE;
}


/*-------------------------------------------------------------------
   FUNCTION: ProcessAddress
   PURPOSE:  
   returns an address of memory slot for the given process index.
   PARAMETERS:
    BYTE p_byProcNum - process number (slot index) between 0 and 31
   RETURNS:
    Address of the memory slot.
-------------------------------------------------------------------*/
inline DWORD ProcessAddress(BYTE p_byProcNum)
{
    return 0x02000000 * (p_byProcNum+1);
}

/*-------------------------------------------------------------------
   FUNCTION: ConvertAddr
   PURPOSE:  
    ConvertAddr does the same as MapPtrToProcess - maps an address in
    slot 0 to the address in the slot of the given process. Unlike 
    MapPtrToProcess, which accepts process handle, ConvertAddr uses
    undocumented PROCESS structure.
   PARAMETERS:
    LPVOID p_pAddr - address to convert
    PPROCESS p_pProcess - internal kernel Process structure
   RETURNS:
    Address mapped to the slot of the given process
-------------------------------------------------------------------*/
LPVOID ConvertAddr(LPVOID p_pAddr, PPROCESS p_pProcess)
{
    if( ((DWORD)p_pAddr) < 0x2000000 && p_pProcess)
    {//Slot 0 and process is not the kernel
        LPVOID l_pOld = p_pAddr;
        BYTE l_byProcNum = 
            *(((LPBYTE)p_pProcess) + PROCESS_NUM_OFFSET);
        p_pAddr = (LPVOID) (((DWORD)p_pAddr) + 
            ProcessAddress(l_byProcNum));
    }
    return p_pAddr;
}

int FilterException(LPEXCEPTION_POINTERS pEx)
{
	DWORD exCode = pEx->ExceptionRecord->ExceptionCode;
	BOOL bRes = (exCode == EXCEPTION_ACCESS_VIOLATION);
	return EXCEPTION_EXECUTE_HANDLER;
}

void * AllocateMemInKernelProc(int p_iSize)
{
	LPVOID pAllocated = NULL;
	// find process id of nk.exe
	HANDLE snapShot = INVALID_HANDLE_VALUE;
	DWORD dwNKProcessId = 0;
	__try
	{
	    snapShot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS | TH32CS_SNAPNOHEAPS, 0);
	    if (snapShot != INVALID_HANDLE_VALUE)
		{
			// Build new list
			PROCESSENTRY32 processEntry;
			processEntry.dwSize = sizeof(PROCESSENTRY32);
			BOOL ret = Process32First(snapShot, &processEntry);
			while (ret == TRUE)
			{
				if (lstrcmpi(processEntry.szExeFile, L"nk.exe") == 0)
				{
					dwNKProcessId = processEntry.th32ProcessID;
					break;
				}
				ret = Process32Next(snapShot, &processEntry);
			}
			CloseToolhelp32Snapshot(snapShot);
		}
	} __except (EXCEPTION_EXECUTE_HANDLER)
	{
		if (snapShot != INVALID_HANDLE_VALUE)
		{
			CloseToolhelp32Snapshot(snapShot);
		}
		return NULL;
	}

	HANDLE hNKProcess = OpenProcess(0, FALSE, dwNKProcessId);
	if (hNKProcess == NULL)
		return NULL;

	HINSTANCE hCoreDll = LoadLibrary(_T("COREDLL"));
	CALLBACKINFO cbi;
	cbi.m_hDestinationProcessHandle = hNKProcess;
	cbi.m_pFunction = (FARPROC)MapPtrToProcess(GetProcAddress(hCoreDll, L"VirtualAlloc"), hNKProcess);
	cbi.m_pFirstArgument = (LPVOID)0; 
	DWORD dwParam2 = p_iSize;
    DWORD dwParam3 = MEM_COMMIT;
	DWORD dwParam4 = PAGE_EXECUTE_READWRITE;
	DWORD dwPtr = PerformCallBack4(&cbi, dwParam2, dwParam3, dwParam4); //returns 1 if correctly executed	

	pAllocated = MapPtrToProcess( (LPVOID)dwPtr, hNKProcess);
	CloseHandle(hNKProcess);
	return pAllocated;
}

__declspec(dllexport) 
BOOL InstallHook()
{
    static long s_lCount = 0;
    if (InterlockedIncrement(&s_lCount) > 1)
    {
		// no need to install again
		return TRUE;
	}

	BOOL bResult = TRUE;

	if (m_hDestProcess == NULL)
	{
		int iAPISetId = SH_WMGR; 
		DWORD dwOldPermissions = 0;
		SetKMode(TRUE);
		dwOldPermissions = SetProcPermissions(-1);    
		__try
		{
			CINFO ** pSystemAPISets = (CINFO**)(UserKInfo[KINX_APISETS]);
			m_hDestProcess = pSystemAPISets[iAPISetId]->m_pProcessServer->hProc;

			CALLBACKINFO cbi;
			ZeroMemory(&cbi, sizeof(CALLBACKINFO));
			cbi.m_hDestinationProcessHandle = m_hDestProcess;
			cbi.m_pFunction = (FARPROC)MapPtrToProcess(GetProcAddress(GetModuleHandle(L"COREDLL"), L"LoadLibraryW"), m_hDestProcess);
			cbi.m_pFirstArgument = (LPVOID)MapPtrToProcess(L"\\Windows\\FingerSuiteDll.dll", GetCurrentProcess());
			m_hDllInst = (HINSTANCE)PerformCallBack4(&cbi, 0,0,0); //returns the HINSTANCE from LoadLibraryW

			Sleep(1000);

			ZeroMemory(&cbi, sizeof(CALLBACKINFO));
			cbi.m_hDestinationProcessHandle = m_hDestProcess;
			cbi.m_pFunction = (FARPROC)MapPtrToProcess(GetProcAddress(m_hDllInst, L"StartHookOnServer"), m_hDestProcess);
			cbi.m_pFirstArgument = NULL; 
			DWORD dw = PerformCallBack4(&cbi, 0,0,0); //returns 1 if correctly executed		

			Sleep(1000);
		}
		__except(FilterException(GetExceptionInformation()))
		{
			bResult = FALSE;
		}
		if(dwOldPermissions)
		{
			SetProcPermissions(dwOldPermissions);
		}
		SetKMode(FALSE);
	}
	return bResult;
}

__declspec(dllexport) 
BOOL RemoveHook()
{
    static long s_lCount = 0;
    if (InterlockedIncrement(&s_lCount) > 1)
    {
		// no need to remove now
		return TRUE;
	}

	BOOL bResult = TRUE;

	if (m_hDestProcess != NULL)
	{
		int iAPISetId = SH_WMGR; 
		DWORD dwOldPermissions = 0;
		SetKMode(TRUE);
		dwOldPermissions = SetProcPermissions(-1);    
		__try
		{
			CALLBACKINFO cbi;
			ZeroMemory(&cbi, sizeof(CALLBACKINFO));
			cbi.m_hDestinationProcessHandle = m_hDestProcess;
			cbi.m_pFunction = (FARPROC)MapPtrToProcess(GetProcAddress(m_hDllInst, L"StopHookOnServer"), m_hDestProcess);
			cbi.m_pFirstArgument = NULL;
			BOOL bRes = (BOOL)PerformCallBack4(&cbi, 0,0,0); //returns the HINSTANCE from LoadLibraryW

			Sleep(1000);

			ZeroMemory(&cbi, sizeof(CALLBACKINFO));
			cbi.m_hDestinationProcessHandle = m_hDestProcess;
			cbi.m_pFunction = (FARPROC)MapPtrToProcess(GetProcAddress(GetModuleHandle(L"COREDLL"), L"FreeLibraryW"), m_hDestProcess);
			cbi.m_pFirstArgument = m_hDllInst;
			bRes = (BOOL)PerformCallBack4(&cbi, 0,0,0); //returns the HINSTANCE from LoadLibraryW

			Sleep(1000);
		}				
		__except(FilterException(GetExceptionInformation()))
		{
			bResult = FALSE;
		}
		if(dwOldPermissions)
		{
			SetProcPermissions(dwOldPermissions);
		}
		SetKMode(FALSE);
	}
	
	StopHookOnSIP();


	return bResult;
}



__declspec(dllexport) 
BOOL StartHookOnServer()
{
	BOOL bResult = TRUE;

	int iAPISetId = SH_WMGR; 
    int iMethodIndex = WMGR_TrackPopupMenuEx;
	int iMethodIndex2 = WMGR_MessageBoxW;

    //HANDLE hCurProc = GetCurrentProcess();
	CINFO * pOrigApiSet; pOrigApiSet = NULL;
	
	DWORD dwOldPermissions = 0;
    SetKMode(TRUE);
    dwOldPermissions = SetProcPermissions(-1);    
	__try
	{
		CINFO ** pSystemAPISets = (CINFO**)(UserKInfo[KINX_APISETS]);
		pOrigApiSet = pSystemAPISets[iAPISetId];

		PFNVOID * pHookMthds = NULL;
		DWORD   * pdwHookSignatures = NULL;
		PFNVOID * pOrigMethods = (PFNVOID *)ConvertAddr(pOrigApiSet->m_ppMethods, pOrigApiSet->m_pProcessServer);
		DWORD   * pOrigSignatures = (DWORD *)ConvertAddr(pOrigApiSet->m_pdwMethodSignatures, pOrigApiSet->m_pProcessServer);

		m_pNewWmgrApiSet = (CINFO *)AllocateMemInKernelProc(sizeof(CINFO));

		int iNewNumMethods = pOrigApiSet->m_wNumMethods;


		// duplicate method table
		int iSize = (sizeof(PFNVOID) * iNewNumMethods + sizeof(DWORD) * iNewNumMethods);
		LPBYTE pRemoteMem = (LPBYTE)AllocateMemInKernelProc(iSize);

		pHookMthds = (PFNVOID *)pRemoteMem;
		pdwHookSignatures = (DWORD*)(pRemoteMem + sizeof(PFNVOID)*iNewNumMethods);
		
		for (int i = 0; i < iNewNumMethods; i++)
		{
			pHookMthds[i] = pOrigMethods[i];
			pdwHookSignatures[i] = pOrigSignatures? pOrigSignatures[i] : FNSIG0();
		}

		memcpy(m_pNewWmgrApiSet, pOrigApiSet, sizeof(CINFO));

		//But replace the method and signature tables:
		m_pNewWmgrApiSet->m_ppMethods = pHookMthds;
		m_pNewWmgrApiSet->m_pdwMethodSignatures = pdwHookSignatures;
		m_pNewWmgrApiSet->m_wNumMethods = (WORD)iNewNumMethods;

		// replace pointer with hooked procedure
		g_pOrigTrackPopupMenuEx = ((PFNVOID *)m_pNewWmgrApiSet->m_ppMethods)[iMethodIndex];
		((PFNVOID *)m_pNewWmgrApiSet->m_ppMethods)[iMethodIndex] = (PFNVOID)HookTrackPopupMenuEx;


		g_pOrigMessageBoxW = ((PFNVOID *)m_pNewWmgrApiSet->m_ppMethods)[iMethodIndex2];
		((PFNVOID *)m_pNewWmgrApiSet->m_ppMethods)[iMethodIndex2] = (PFNVOID)HookMessageBoxW;


		//And finally, replace the pointer to the original CINFO
		//by the pointer to ours.
		m_pOldWmgrApiSet = pSystemAPISets[iAPISetId];
		pSystemAPISets[iAPISetId] = m_pNewWmgrApiSet;

	}
	__except(FilterException(GetExceptionInformation()))
	{
		bResult = FALSE;
	}
    if(dwOldPermissions)
    {
        SetProcPermissions(dwOldPermissions);
    }
    SetKMode(FALSE);

	return bResult;
}

__declspec(dllexport) 
BOOL StopHookOnServer()
{
	BOOL bResult = TRUE;

	int iAPISetId = SH_WMGR; 
	DWORD dwOldPermissions = 0;
    SetKMode(TRUE);
    dwOldPermissions = SetProcPermissions(-1);    
	__try
	{
		CINFO ** pSystemAPISets = (CINFO**)(UserKInfo[KINX_APISETS]);
		//restore the pointer to the original CINFO
		if (m_pOldWmgrApiSet != NULL)
		{
			pSystemAPISets[iAPISetId] = m_pOldWmgrApiSet;

			// TODO 
			// free mem allocated for m_pNewApiSet
		}

	}
	__except(FilterException(GetExceptionInformation()))
	{
		bResult = FALSE;
	}
    if(dwOldPermissions)
    {
        SetProcPermissions(dwOldPermissions);
    }
    SetKMode(FALSE);

	return bResult;
}


__declspec(dllexport) 
void SetMsgBoxResult(int iResult)
{
	g_iMsgBoxResult = iResult;
}


__declspec(dllexport) 
void SetTrackPopupMenuExResult(BOOL bResult)
{
	g_bTrackPopupMenuExResult = bResult;
}

/// SHELL ////////////////
//////////////////////////

LRESULT UpdateBuffer(LPNOTIFICATIONINFO pInfo, const CLSID *pclsid, DWORD dwID, DWORD grfFlagsOriginal)
{
	SHNOTIFICATIONDATA shnd;
	ZeroMemory(&shnd, sizeof(SHNOTIFICATIONDATA));
	shnd.cbStruct = sizeof(SHNOTIFICATIONDATA);
	LRESULT lRes = SHNotificationGetData(pclsid, dwID, &shnd);


	// notification data
	if (lRes == ERROR_SUCCESS)
	{
		ZeroMemory(pInfo, sizeof(NOTIFICATIONINFO));
		memcpy(&pInfo->nd, &shnd, sizeof(SHNOTIFICATIONDATA));

		pInfo->grfFlagsOriginal = grfFlagsOriginal;

		// strings
		wsprintf(pInfo->szTitle, L"%s", shnd.pszTitle);
		wsprintf(pInfo->szHTML, L"%s", shnd.pszHTML);
		if (shnd.pszHTML) 
			free((LPVOID)shnd.pszHTML);
		shnd.pszHTML = NULL;
		if (shnd.pszTitle) 
			free((LPVOID)shnd.pszTitle);
		shnd.pszTitle = NULL;
		
		// adjust pointers
		pInfo->nd.pszTitle = pInfo->szTitle;
		pInfo->nd.pszHTML = pInfo->szHTML;

		// menu
		if (shnd.grfFlags & SHNF_HASMENU)
		{
			memcpy(pInfo->rgskc, shnd.skm.prgskc, sizeof(SOFTKEYMENU) * shnd.skm.cskc);
			// adjust pointers
			pInfo->nd.skm.prgskc = pInfo->rgskc;
		}
		else
		{
			if (shnd.rgskn[0].pszTitle != NULL) wsprintf(pInfo->sk1Title, L"%s", shnd.rgskn[0].pszTitle);
			if (shnd.rgskn[1].pszTitle != NULL) wsprintf(pInfo->sk2Title, L"%s", shnd.rgskn[1].pszTitle);

			// adjust pointers
			pInfo->nd.rgskn[0].pszTitle = pInfo->sk1Title;
			pInfo->nd.rgskn[1].pszTitle = pInfo->sk2Title;
		}
	}
	return lRes;
}


LRESULT WINAPI HookSHNotificationAddII( SHNOTIFICATIONDATA *pndAdd, DWORD cbData, LPTSTR pszTitle, LPTSTR pszHTML )
{
	LRESULT lResult = ERROR_INVALID_PARAMETER;
	NOTIFICATIONINFO info;

	DWORD grfFlagsOriginal = pndAdd->grfFlags;

	BOOL bIsManaged = IsManagedNotification(pndAdd->clsid);
	

	if ((IsWindow(g_hWndServerNotif)) && (pndAdd->npPriority & SHNP_INFORM) && (bIsManaged))
	{
		//modifica parametri pndAdd 
		pndAdd->grfFlags |= SHNF_STRAIGHTTOTRAY;
		pndAdd->grfFlags &= (~SHNF_FORCEMESSAGE);
	}

    if (g_pOrigSHNotificationAddII)
    {
        	lResult = ((LRESULT (*)(
				SHNOTIFICATIONDATA *, DWORD, LPTSTR, LPTSTR))g_pOrigSHNotificationAddII)
				(
					pndAdd,
					cbData,
					pszTitle,
					pszHTML
				);
    } //if (g_pOrigSHNotificationAddII)

	if (lResult != ERROR_SUCCESS)
		goto normal;

	if (pndAdd->npPriority == SHNP_ICONIC)
		goto normal;

	if (!(IsWindow(g_hWndServerNotif)))
		goto normal;
	
	lResult = UpdateBuffer(&info, &pndAdd->clsid, pndAdd->dwID, grfFlagsOriginal);
	
	info.isManaged = bIsManaged;

	BOOL bInterceptRes =  (BOOL)SendMessageRemote(g_hWndServerNotif, UWM_INTERCEPT_NOTIF, NOTIF_ADD, (LPARAM)&info, sizeof(NOTIFICATIONINFO));

	if (bInterceptRes) 
	{
		goto normal;
	}

normal:
	return lResult;
}


LRESULT WINAPI HookSHNotificationUpdateII(DWORD grnumUpdateMask, SHNOTIFICATIONDATA *pndNew, DWORD cbData, LPTSTR pszTitle, LPTSTR pszHTML)
{
	LRESULT lResult = ERROR_INVALID_PARAMETER;

	NOTIFICATIONINFO info;

	DWORD grfFlagsOriginal = pndNew->grfFlags;

	BOOL bIsManaged = IsManagedNotification(pndNew->clsid);

	if (IsWindow(g_hWndServerNotif) && (bIsManaged))
	{
		pndNew->grfFlags |= SHNF_STRAIGHTTOTRAY;
		pndNew->grfFlags &= (~SHNF_FORCEMESSAGE);
	}

	if (g_pOrigSHNotificationUpdateII)
    {
        	lResult = ((LRESULT (*)(
				DWORD, SHNOTIFICATIONDATA *, DWORD, LPTSTR, LPTSTR))g_pOrigSHNotificationUpdateII)
				(
				    grnumUpdateMask,
					pndNew,
					cbData,
					pszTitle,
					pszHTML
				);
    } //if (g_pOrigSHNotificationUpdateII)

	if (lResult != ERROR_SUCCESS)
		goto normal;

	if (!(IsWindow(g_hWndServerNotif)))
		goto normal;

	lResult = UpdateBuffer(&info, &pndNew->clsid, pndNew->dwID, grfFlagsOriginal);

	if (lResult != ERROR_SUCCESS)
		goto normal;

	info.isManaged = bIsManaged;

	BOOL bInterceptRes =  (BOOL)SendMessageRemote(g_hWndServerNotif, UWM_INTERCEPT_NOTIF, NOTIF_UPD, (LPARAM)&info, sizeof(NOTIFICATIONINFO));

	if (bInterceptRes) 
	{
		goto normal;
	}

normal:
    return lResult;
}


LRESULT WINAPI HookSHNotificationRemoveII(const CLSID *pclsid, DWORD cbCLSID, DWORD dwID)
{
	LRESULT lResult = ERROR_INVALID_PARAMETER;

	if (IsWindow(g_hWndServerNotif))
	{
	}

	NOTIFICATIONINFO info;
	ZeroMemory(&info, sizeof(NOTIFICATIONINFO));
	memcpy(&info.nd.clsid, pclsid, sizeof(CLSID));
	info.nd.dwID = dwID;

	if (g_pOrigSHNotificationRemoveII)
    {
        	lResult = ((LRESULT (*)(
				const CLSID *, DWORD, DWORD))g_pOrigSHNotificationRemoveII)
				(
					pclsid, 
					cbCLSID,
					dwID
				);
    } //if (g_pOrigSHNotificationRemoveII)

	if (lResult != ERROR_SUCCESS)
		goto normal;

	if (!(IsWindow(g_hWndServerNotif)))
		goto normal;

	BOOL bInterceptRes =  (BOOL)SendMessageRemote(g_hWndServerNotif, UWM_INTERCEPT_NOTIF, NOTIF_DEL, (LPARAM)&info, sizeof(NOTIFICATIONINFO));

	if (bInterceptRes) 
	{
		goto normal;
	}


normal:
    return lResult;
}

// NON SERVE PIU
/*
BOOL WINAPI HookShell_NotifyIconI(DWORD dwMsg, PNOTIFYICONDATA pNID, DWORD cbNID)
{
	LOG(L"Start HookShell_NotifyIconI ...\n");

	BOOL bResult = FALSE;

	LPNOTIFICATIONINFO info = NULL;

	if (IsWindow(g_hWndServerNotif))
	{
		info = (NOTIFICATIONINFO*)g_sharedNotifMem.GetValue();
		ZeroMemory(info, sizeof(NOTIFICATIONINFO));
		info->dwType = NTF_TYPE_NOTIFYICONDATA;
		info->info2.dwMessage = dwMsg;
		memcpy(&info->info2.nid, pNID, sizeof(PNOTIFYICONDATA));

		//modifica parametri pndAdd 
		//pndAdd->npPriority = SHNP_ICONIC;
	}

	if (g_pOrigShell_NotifyIconI)
    {
        	bResult = ((BOOL (*)(
				DWORD, PNOTIFYICONDATA, DWORD))g_pOrigShell_NotifyIconI)
				(
					dwMsg, 
					pNID, 
					cbNID
				);
    } //if (g_pOrigShell_NotifyIconI)

	if (bResult == FALSE)
		goto normal;

	if (!(IsWindow(g_hWndServerNotif)))
		goto normal;

	BOOL bInterceptRes =  (BOOL)SendMessage(g_hWndServerNotif, UWM_INTERCEPT_SHELLNOTIFICON, 0, 0);

	if (bInterceptRes) 
	{
		goto normal;
	}


normal:
    LOG(L"End HookShell_NotifyIconI .....\n");

    return bResult;
}
*/


__declspec(dllexport) 
BOOL InstallHookOnShell()
{
    static long s_lCount = 0;
    if (InterlockedIncrement(&s_lCount) > 1)
    {
		// no need to install again
		return TRUE;
	}

	BOOL bResult = TRUE;
	HANDLE    hDestProcess = NULL;
	HINSTANCE hDllInst = 0;

	int iAPISetId = SH_SHELL; 
	DWORD dwOldPermissions = 0;
	SetKMode(TRUE);
	dwOldPermissions = SetProcPermissions(-1);    
	__try
	{
		CINFO ** pSystemAPISets = (CINFO**)(UserKInfo[KINX_APISETS]);
		hDestProcess = pSystemAPISets[iAPISetId]->m_pProcessServer->hProc; // should be shell32.exe

		CALLBACKINFO cbi;
		ZeroMemory(&cbi, sizeof(CALLBACKINFO));
		cbi.m_hDestinationProcessHandle = hDestProcess;
		cbi.m_pFunction = (FARPROC)MapPtrToProcess(GetProcAddress(GetModuleHandle(L"COREDLL"), L"LoadLibraryW"), hDestProcess);
		cbi.m_pFirstArgument = (LPVOID)MapPtrToProcess(L"\\Windows\\FingerSuiteDll.dll", GetCurrentProcess());
		hDllInst = (HINSTANCE)PerformCallBack4(&cbi, 0,0,0); //returns the HINSTANCE from LoadLibraryW

		Sleep(1000);

		ZeroMemory(&cbi, sizeof(CALLBACKINFO));
		cbi.m_hDestinationProcessHandle = hDestProcess;
		cbi.m_pFunction = (FARPROC)MapPtrToProcess(GetProcAddress(hDllInst, L"StartHookOnShellServer"), hDestProcess);
		cbi.m_pFirstArgument = NULL; 
		DWORD dw = PerformCallBack4(&cbi, 0,0,0); //returns 1 if correctly executed		

		Sleep(1000);
	}
	__except(FilterException(GetExceptionInformation()))
	{
		bResult = FALSE;
	}
	if(dwOldPermissions)
	{
		SetProcPermissions(dwOldPermissions);
	}
	SetKMode(FALSE);

	return bResult;
}



__declspec(dllexport) 
BOOL StartHookOnShellServer()
{
	BOOL bResult = TRUE;

	int iAPISetId = SH_SHELL; 
    int iMethodIndex = SHELL_SHNotificationAddII;
	int iMethodIndex2 = SHELL_SHNotificationUpdateII;
	int iMethodIndex3 = SHELL_SHNotificationRemoveII;

    //HANDLE hCurProc = GetCurrentProcess();
	CINFO * pOrigApiSet; pOrigApiSet = NULL;
	
	DWORD dwOldPermissions = 0;
    SetKMode(TRUE);
    dwOldPermissions = SetProcPermissions(-1);    
	__try
	{
		CINFO ** pSystemAPISets = (CINFO**)(UserKInfo[KINX_APISETS]);
		pOrigApiSet = pSystemAPISets[iAPISetId];

		PFNVOID * pHookMthds = NULL;
		DWORD   * pdwHookSignatures = NULL;
		PFNVOID * pOrigMethods = (PFNVOID *)ConvertAddr(pOrigApiSet->m_ppMethods, pOrigApiSet->m_pProcessServer);
		DWORD   * pOrigSignatures = (DWORD *)ConvertAddr(pOrigApiSet->m_pdwMethodSignatures, pOrigApiSet->m_pProcessServer);

		m_pNewShellApiSet = (CINFO *)AllocateMemInKernelProc(sizeof(CINFO));

		int iNewNumMethods = pOrigApiSet->m_wNumMethods;


		// duplicate method table
		int iSize = (sizeof(PFNVOID) * iNewNumMethods + sizeof(DWORD) * iNewNumMethods);
		LPBYTE pRemoteMem = (LPBYTE)AllocateMemInKernelProc(iSize);

		pHookMthds = (PFNVOID *)pRemoteMem;
		pdwHookSignatures = (DWORD*)(pRemoteMem + sizeof(PFNVOID)*iNewNumMethods);
		
		for (int i = 0; i < iNewNumMethods; i++)
		{
			pHookMthds[i] = pOrigMethods[i];
			pdwHookSignatures[i] = pOrigSignatures? pOrigSignatures[i] : FNSIG0();
		}

		memcpy(m_pNewShellApiSet, pOrigApiSet, sizeof(CINFO));

		//But replace the method and signature tables:
		m_pNewShellApiSet->m_ppMethods = pHookMthds;
		m_pNewShellApiSet->m_pdwMethodSignatures = pdwHookSignatures;
		m_pNewShellApiSet->m_wNumMethods = (WORD)iNewNumMethods;

		// replace pointer with hooked procedure
		g_pOrigSHNotificationAddII = ((PFNVOID *)m_pNewShellApiSet->m_ppMethods)[iMethodIndex];
		((PFNVOID *)m_pNewShellApiSet->m_ppMethods)[iMethodIndex] = (PFNVOID)HookSHNotificationAddII;


		g_pOrigSHNotificationUpdateII = ((PFNVOID *)m_pNewShellApiSet->m_ppMethods)[iMethodIndex2];
		((PFNVOID *)m_pNewShellApiSet->m_ppMethods)[iMethodIndex2] = (PFNVOID)HookSHNotificationUpdateII;

		g_pOrigSHNotificationRemoveII = ((PFNVOID *)m_pNewShellApiSet->m_ppMethods)[iMethodIndex3];
		((PFNVOID *)m_pNewShellApiSet->m_ppMethods)[iMethodIndex3] = (PFNVOID)HookSHNotificationRemoveII;

		//And finally, replace the pointer to the original CINFO
		//by the pointer to ours.
		m_pOldShellApiSet = pSystemAPISets[iAPISetId];
		pSystemAPISets[iAPISetId] = m_pNewShellApiSet;

	}
	__except(FilterException(GetExceptionInformation()))
	{
		bResult = FALSE;
	}
    if(dwOldPermissions)
    {
        SetProcPermissions(dwOldPermissions);
    }
    SetKMode(FALSE);
	return bResult;
}

/////////////////////////////////// SIP BUTTON HOOK //////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
////// SIP Hook
LONG oldSIPBtnWindowProc;
DWORD dwSIPBtnStartTime;
DWORD dwSIPBtnInterval;

LRESULT CALLBACK newSIPBtnWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 
{
	//LOG(L"Interceptiong SIP Button message...\n");
	BOOL bStartSIPMenu = FALSE;

	if (!(IsWindow(g_hWndServer)))
		goto normal;

	switch (uMsg){
	case WM_LBUTTONDOWN:
		dwSIPBtnStartTime = ::GetTickCount();
		break;
	case WM_LBUTTONUP:
		if ((::GetTickCount() - dwSIPBtnStartTime) > dwSIPBtnInterval)
			bStartSIPMenu = TRUE;
		break;
	default:
		break;
	}

normal:

	LRESULT lResult = CallWindowProc((WNDPROC)oldSIPBtnWindowProc, hwnd, uMsg, wParam, lParam);
	if (bStartSIPMenu)
	{
		RECT rc; ::GetClientRect(hwnd, &rc);
		LPARAM lParam = ((rc.bottom / 2) << 16) + (rc.right - 10);
		::PostMessage(hwnd, WM_LBUTTONDOWN, (WPARAM)0x00000001, lParam);
	}

	return lResult;
}

__declspec(dllexport) 
BOOL StartHookOnSIP()
{
	BOOL bResult = TRUE;
	HWND hWndSIPButton = ::FindWindow(L"MS_SIPBUTTON", NULL);
	if (hWndSIPButton != NULL)
	{
		HWND hWndToolbar = ::GetWindow(hWndSIPButton, GW_CHILD);
		if (hWndToolbar != NULL)
		{
			oldSIPBtnWindowProc = ::GetWindowLong(hWndToolbar, GWL_WNDPROC);
			if (::SetWindowLong(hWndToolbar, GWL_WNDPROC, (LONG)newSIPBtnWindowProc) == 0)
			{
				LOG(L"Errore StartHookOnSIP\n");
				return FALSE;
			}
		}
	}

	if (RegistryGetDWORD(HKEY_LOCAL_MACHINE, L"Software\\FingerMenu", L"SIPBtnPressInterval", &dwSIPBtnInterval) != S_OK)
		dwSIPBtnInterval = 500;

	LOG(L"StartHookOnSIP OK\n");
	return TRUE;
}

__declspec(dllexport) 
BOOL StopHookOnSIP()
{
	BOOL bResult = TRUE;
	HWND hWndSIPButton = ::FindWindow(L"MS_SIPBUTTON", NULL);
	if (hWndSIPButton != NULL)
	{
		HWND hWndToolbar = ::GetWindow(hWndSIPButton, GW_CHILD);
		if (hWndToolbar != NULL)
		{
			if (oldSIPBtnWindowProc != NULL)
				::SetWindowLong(hWndToolbar, GWL_WNDPROC, (LONG)oldSIPBtnWindowProc);
		}
	}

	LOG(L"StopHookOnSIP OK\n");
	return TRUE;
}


__declspec(dllexport) 
BOOL InstallHookOnSIP()
{
    static long s_lCount = 0;
    if (InterlockedIncrement(&s_lCount) > 1)
    {
		// no need to install again
		return TRUE;
	}

	BOOL bResult = TRUE;
	HANDLE    hDestProcess = NULL;
	HINSTANCE hDllInst = 0;

	DWORD dwOldPermissions = 0;
	SetKMode(TRUE);
	dwOldPermissions = SetProcPermissions(-1);    
	__try
	{
		HWND hWndSIPButton = ::FindWindow(L"MS_SIPBUTTON", NULL);
		DWORD dwProcessId; GetWindowThreadProcessId(hWndSIPButton, &dwProcessId);
		hDestProcess = (HANDLE)dwProcessId;

		CALLBACKINFO cbi;
		ZeroMemory(&cbi, sizeof(CALLBACKINFO));
		cbi.m_hDestinationProcessHandle = hDestProcess;
		cbi.m_pFunction = (FARPROC)MapPtrToProcess(GetProcAddress(GetModuleHandle(L"COREDLL"), L"LoadLibraryW"), hDestProcess);
		cbi.m_pFirstArgument = (LPVOID)MapPtrToProcess(L"\\Windows\\FingerSuiteDll.dll", GetCurrentProcess());
		hDllInst = (HINSTANCE)PerformCallBack4(&cbi, 0,0,0); //returns the HINSTANCE from LoadLibraryW

		Sleep(1000);

		ZeroMemory(&cbi, sizeof(CALLBACKINFO));
		cbi.m_hDestinationProcessHandle = hDestProcess;
		cbi.m_pFunction = (FARPROC)MapPtrToProcess(GetProcAddress(hDllInst, L"StartHookOnSIP"), hDestProcess);
		cbi.m_pFirstArgument = NULL; 
		DWORD dw = PerformCallBack4(&cbi, 0,0,0); //returns 1 if correctly executed		

		Sleep(1000);
	}
	__except(FilterException(GetExceptionInformation()))
	{
		bResult = FALSE;
	}
	if(dwOldPermissions)
	{
		SetProcPermissions(dwOldPermissions);
	}
	SetKMode(FALSE);

	return bResult;
}




/////////////////////////////////// TITLEBAR HOOK //////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
typedef enum {QVGA = 320, WQVGA = 400, VGA = 640, WVGA = 800} RESOLUTION;

int scaleFactor = 0;

LONG oldHHTaskbarWindowProc;

LRESULT CALLBACK newHHTaskbarWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 
{
	switch (uMsg){
	case WM_LBUTTONDOWN:

		if (!(::IsWindow(g_hWndServerNotif)))
			break;

		RECT rc; ::GetClientRect(hwnd, &rc);
		::InflateRect(&rc, -27 * scaleFactor, 0); // only VGA
		POINT pt; pt.x  = LOWORD(lParam); pt.y = HIWORD(lParam);

		if (::PtInRect(&rc, pt))
		{
			::PostMessage(g_hWndServerNotif, UWM_NOTIF_POPUP, 0, 0);
			return 0;
		}
		break;
	default:
		break;
	}
	LRESULT lResult = CallWindowProc((WNDPROC)oldHHTaskbarWindowProc, hwnd, uMsg, wParam, lParam);

	return lResult;
}

__declspec(dllexport) 
BOOL StartHookOnHHTaskBar()
{
	BOOL bResult = TRUE;
	HWND hWndHHTaskbar = ::FindWindow(L"HHTaskBar", NULL);
	if (hWndHHTaskbar != NULL)
	{
		oldHHTaskbarWindowProc = ::GetWindowLong(hWndHHTaskbar, GWL_WNDPROC);
		if (::SetWindowLong(hWndHHTaskbar, GWL_WNDPROC, (LONG)newHHTaskbarWindowProc) == 0)
		{
			LOG(L"Errore StartHookOnHHTaskBar\n");
			return FALSE;
		}
	}

	// detect resolution
	RESOLUTION resolution = QVGA;
	DEVMODE dm;
	::ZeroMemory(&dm, sizeof(DEVMODE));
	dm.dmSize = sizeof(DEVMODE);
	if (EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dm))
	{
		resolution = (RESOLUTION)dm.dmPelsHeight;
	}

	// load icon images
	switch (resolution)
	{
	case QVGA:
	case WQVGA:
		scaleFactor = 1;
		break;
	case VGA:
	case WVGA:
		scaleFactor = 2;
		break;
	}

	LOG(L"Tutto OK StartHookOnHHTaskBar\n");
	return TRUE;
}

__declspec(dllexport) 
BOOL InstallHookOnHHTaskBar()
{
    static long s_lCount = 0;
    if (InterlockedIncrement(&s_lCount) > 1)
    {
		// no need to install again
		return TRUE;
	}

	BOOL bResult = TRUE;
	HANDLE    hDestProcess = NULL;
	HINSTANCE hDllInst = 0;

	DWORD dwOldPermissions = 0;
	SetKMode(TRUE);
	dwOldPermissions = SetProcPermissions(-1);    
	__try
	{
		HWND hWndHHTaskbar = ::FindWindow(L"HHTaskBar", NULL);
		DWORD dwProcessId; GetWindowThreadProcessId(hWndHHTaskbar, &dwProcessId);
		hDestProcess = (HANDLE)dwProcessId;

		CALLBACKINFO cbi;
		ZeroMemory(&cbi, sizeof(CALLBACKINFO));
		cbi.m_hDestinationProcessHandle = hDestProcess;
		cbi.m_pFunction = (FARPROC)MapPtrToProcess(GetProcAddress(GetModuleHandle(L"COREDLL"), L"LoadLibraryW"), hDestProcess);
		cbi.m_pFirstArgument = (LPVOID)MapPtrToProcess(L"\\Windows\\FingerSuiteDll.dll", GetCurrentProcess());
		hDllInst = (HINSTANCE)PerformCallBack4(&cbi, 0,0,0); //returns the HINSTANCE from LoadLibraryW

		Sleep(1000);

		ZeroMemory(&cbi, sizeof(CALLBACKINFO));
		cbi.m_hDestinationProcessHandle = hDestProcess;
		cbi.m_pFunction = (FARPROC)MapPtrToProcess(GetProcAddress(hDllInst, L"StartHookOnHHTaskBar"), hDestProcess);
		cbi.m_pFirstArgument = NULL; 
		DWORD dw = PerformCallBack4(&cbi, 0,0,0); //returns 1 if correctly executed		

		Sleep(1000);
	}
	__except(FilterException(GetExceptionInformation()))
	{
		bResult = FALSE;
	}
	if(dwOldPermissions)
	{
		SetProcPermissions(dwOldPermissions);
	}
	SetKMode(FALSE);

	return bResult;
}


__declspec(dllexport) 
BOOL IsManagedNotification(REFCLSID clsid)
{
	LPOLESTR pOleStr;
	StringFromCLSID(clsid, &pOleStr);

	LOG(L"IsManagedNotification notif = %s\n", (WCHAR*)pOleStr);
	
	BOOL bResult = FALSE;
	for (int i = 0; i < MANAGED_NOTIF_SIZE; i++)
	{
		if ( lstrcmpi(g_szManagedNotificationCLSID[i], (WCHAR*)pOleStr) == 0 )
		{
			bResult = TRUE;
			break;
		}
	}

	CoTaskMemFree(pOleStr);

	return bResult;
}<file_sep>/FingerSuite/FingerNotification/Commons.h
#ifndef COMMONS_H
#define COMMONS_H

#pragma once

template <class T>
class CNotificationInfoEqualHelper
{
public:
	static bool IsEqual(const T& t1, const T& t2)
	{
		return false;
	}
};

#endif // COMMONS_H<file_sep>/FBReader/zlibrary/ui/src/win32/dialogs/ZLWin32SelectionDialog.cpp
/*
 * Copyright (C) 2007-2010 <NAME> <<EMAIL>>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 * 02110-1301, USA.
 */

#include <ZLApplication.h>
#include <ZLibrary.h>
#include <ZLFile.h>

#include <ZLDialogManager.h>

#include "ZLWin32SelectionDialog.h"

#include "../w32widgets/W32Container.h"
#include "../w32widgets/W32Control.h"

#include "../application/ZLWin32ApplicationWindow.h"
#include "../../../../core/src/win32/util/W32WCHARUtil.h"

const int ICON_SIZE = 22;

ZLWin32SelectionDialog::ZLWin32SelectionDialog(ZLWin32ApplicationWindow &window, const std::string &caption, ZLTreeHandler &handler) : ZLDesktopSelectionDialog(handler), myWindow(window), myPanel(myWindow.mainWindow(), caption) {
	myPanel.setResizeable(true);
	myPanel.setExitOnOk(false);
	myPanel.addListener(this);

	W32VBorderBox *panelBox = new W32VBorderBox();
	panelBox->setSpacing(4);
	panelBox->setMargins(4, 4, 4, 4);
	myPanel.setElement(panelBox);

	myLineEditor = new W32LineEditor("");
	myLineEditor->setVisible(true);
	myLineEditor->setEnabled(!handler.isOpenHandler());
	panelBox->setTopElement(myLineEditor);

	myTreeView = new W32TreeView(ICON_SIZE);
	myTreeView->setVisible(true);
	myTreeView->addListener(this);
	panelBox->setCenterElement(myTreeView);

	W32HBox *buttonBox = new W32HBox();
	panelBox->setBottomElement(buttonBox);
	buttonBox->setHomogeneous(true);
	buttonBox->setAlignment(W32HBox::RIGHT);
	buttonBox->setSpacing(4);
	buttonBox->setMargins(4, 4, 4, 4);
	myOkButton = new W32PushButton(ZLDialogManager::buttonName(ZLDialogManager::OK_BUTTON));
	myOkButton->addListener(this);
	buttonBox->addElement(myOkButton);
	buttonBox->addElement(new W32PushButton(ZLDialogManager::buttonName(ZLDialogManager::CANCEL_BUTTON), W32PushButton::CANCEL_BUTTON));
	buttonBox->setVisible(true);

	update();
}

ZLWin32SelectionDialog::~ZLWin32SelectionDialog() {
	for(std::map<std::string,HICON>::iterator it = myIcons.begin(); it != myIcons.end(); ++it) {
		DestroyIcon(it->second);
	}
}

HICON ZLWin32SelectionDialog::getIcon(const ZLTreeNodePtr node) {
	const std::string &pixmapName = node->pixmapName();
	std::map<std::string,HICON>::const_iterator it = myIcons.find(pixmapName);
	if (it == myIcons.end()) {
		std::string imageFileName = ZLibrary::ApplicationImageDirectory() + ZLibrary::FileNameDelimiter + pixmapName + ".ico";
		ZLFile file(imageFileName);
		ZLUnicodeUtil::Ucs2String wPath;
		HICON icon = (HICON)LoadImageW(0, ::wchar(::createNTWCHARString(wPath, file.path())), IMAGE_ICON, ICON_SIZE, ICON_SIZE, LR_LOADFROMFILE);
		myIcons[pixmapName] = icon;
		return icon;
	} else {
		return it->second;
	}
}

void ZLWin32SelectionDialog::updateStateLine() {
	myLineEditor->setText(handler().stateDisplayName());
}

void ZLWin32SelectionDialog::updateList() {
	myTreeView->clear();

	const std::vector<ZLTreeNodePtr> &nodes = handler().subnodes();
	if (nodes.empty()) {
		return;
	}

	for (std::vector<ZLTreeNodePtr>::const_iterator it = nodes.begin(); it != nodes.end(); ++it) {
		myTreeView->insert((*it)->displayName(), getIcon(*it));
	}
}

void ZLWin32SelectionDialog::selectItem(int index) {
	myTreeView->select(index);
}

bool ZLWin32SelectionDialog::run() {
	myWindow.blockMouseEvents(true);
	bool result = myPanel.runDialog(myWidth, myHeight);
	W32Widget::Size size = myPanel.size();
	myWidth = size.Width;
	myHeight = size.Height;
	myWindow.blockMouseEvents(false);
	return result;
}

void ZLWin32SelectionDialog::exitDialog() {
	myPanel.endDialog(true);
}

void ZLWin32SelectionDialog::setSize(int width, int height) {
	myWidth = width;
	myHeight = height;
}

int ZLWin32SelectionDialog::width() const {
	return myWidth;
}

int ZLWin32SelectionDialog::height() const {
	return myHeight;
}

void ZLWin32SelectionDialog::onEvent(const std::string &event, W32EventSender&) {
	if ((event == W32StandaloneDialogPanel::OK_EVENT) ||
			(event == W32TreeView::ITEM_DOUBLE_CLICKED_EVENT) ||
			(event == W32PushButton::RELEASED_EVENT)) {
		if (handler().isOpenHandler()) {
			int index = myTreeView->selectedIndex();
			const std::vector<ZLTreeNodePtr> &nodes = handler().subnodes();
			if ((index >= 0) && (index < (int)nodes.size())) {
				runNode(nodes[index]);
			}
		} else {
			//runState(gtk_entry_get_text(myStateLine));	
		}
	} else if (event == W32TreeView::ITEM_SELECTED_EVENT) {
		int index = myTreeView->selectedIndex();
		const std::vector<ZLTreeNodePtr> &nodes = handler().subnodes();
		if ((index >= 0) && (index < (int)nodes.size())) {
			myOkButton->setEnabled(!nodes[index]->isFolder());
		}
	}
}
<file_sep>/FBReader/makefiles/arch/iliad.mk
include $(ROOTDIR)/makefiles/arch/unix.mk

BASEPATH = /opt/iLiad/usr/local/arm/oe
TOOLSPATH = $(BASEPATH)/bin
INCPATH = $(BASEPATH)/arm-linux/include
LIBPATH = $(BASEPATH)/arm-linux/lib

RM = rm -rvf
RM_QUIET = rm -rf
GTKINCLUDE = -I$(LIBPATH)/glib-2.0/include -I$(LIBPATH)/gtk-2.0/include -I$(INCPATH)/glib-2.0 -I$(INCPATH)/gtk-2.0 -I$(INCPATH)/pango-1.0 -I$(INCPATH)/atk-1.0
MOC = $(TOOLSPATH)/moc
CC = $(TOOLSPATH)/arm-linux-gcc
AR = $(TOOLSPATH)/arm-linux-ar rsu
LD = $(TOOLSPATH)/arm-linux-g++

UILIBS = -lgtk-x11-2.0 -lgdk-x11-2.0 -lgdk_pixbuf-2.0

CFLAGS = -pipe -DOPIE_NO_DEBUG -DQT_NO_DEBUG -DQWS -fno-exceptions -fno-rtti -march=armv4 -mtune=xscale --param inline-unit-growth=200 --param large-function-growth=2000 -Wall -Wno-ctor-dtor-privacy -W -Winline
LDFLAGS = -Wl,-rpath,$(LIBDIR)
<file_sep>/SQLCEHelper/Include/sqlce_ex.h
#ifndef __sqlce_ex_h__
#define __sqlce_ex_h__

#ifdef __cplusplus
extern "C"{
#endif 

/***************************************************************************
****************************************************************************
        SQL CE specific GUIDS
***************************************************************************
***************************************************************************/


// Microsoft SQL Server for Windows CE 1.0 Provider (Microsoft.SQLSERVER.OLEDB.CE.1.0)
//
extern const OLEDBDECLSPEC GUID CLSID_SQLSERVERCE_1_0 = {0x7D0703CB,0x4C23,0x11d2,{0x88,0x82,0x00,0xC0,0x4F,0xD9,0x37,0xF0}};

// Microsoft SQL Server for Windows CE 2.0 Provider (Microsoft.SQLSERVER.OLEDB.CE.2.0)
//
extern const OLEDBDECLSPEC GUID CLSID_SQLSERVERCE_2_0 = {0x76A85B2E,0x9DE0,0x4ded,{0x8E,0x69,0x4D,0xEF,0xDB,0x9C,0x09,0x17}};

// Microsoft SQL Server Lite for Windows 3.0 Provider (Microsoft.SQLSERVER.OLEDB.CE.3.0)
//
// {32CE2952-2585-49a6-AEFF-1732076C2945}
//
extern const OLEDBDECLSPEC GUID CLSID_SQLSERVERCE_3_0 = {0x32ce2952, 0x2585, 0x49a6, {0xae, 0xff, 0x17, 0x32, 0x7, 0x6c, 0x29, 0x45}};

/*

// Microsoft SQL Server Lite for Windows 3.5 Provider (Microsoft.SQLSERVER.CE.OLEDB.3.5)
//
// {F49C559D-E9E5-467C-8C18-3326AAE4EBCC}
//
extern const OLEDBDECLSPEC GUID CLSID_SQLSERVERCE_3_5 = {0xf49c559d, 0xe9e5, 0x467c, {0x8c, 0x18, 0x33, 0x26, 0xaa, 0xe4, 0xeb, 0xcc}};

// PUBLISHED: Provider Specific Property Sets
//
// Provider-Specific DBInit Property Set
// {2B9AB5BA-4F6C-4ddd-BF18-24DD4BD41848}
//
//extern const OLEDBDECLSPEC GUID DBPROPSET_SSCE_DBINIT = {0x2b9ab5ba, 0x4f6c, 0x4ddd, {0xbf, 0x18, 0x24, 0xdd, 0x4b, 0xd4, 0x18, 0x48}};

// Provider-Specific Column Property Set
// {352CC8D5-9181-11d3-B27B-00C04F68DBFF}
//
//extern const OLEDBDECLSPEC GUID DBPROPSET_SSCE_COLUMN = {0x352cc8d5, 0x9181, 0x11d3, {0xb2, 0x7b, 0x0, 0xc0, 0x4f, 0x68, 0xdb, 0xff}};

// Provider-Specific Rowset Property Set
// {5C17C602-A107-11d3-B27B-00C04F68DBFF}
//
//extern const OLEDBDECLSPEC GUID DBPROPSET_SSCE_ROWSET = {0x5c17c602, 0xa107, 0x11d3, {0xb2, 0x7b, 0x0, 0xc0, 0x4f, 0x68, 0xdb, 0xff}};

// Provider-Specific Session Property Set
// {22FE7D33-5E5C-4a45-B723-8BED2374A06B}
//
//extern const OLEDBDECLSPEC GUID DBPROPSET_SSCE_SESSION = {0x22fe7d33, 0x5e5c, 0x4a45, {0xb7, 0x23, 0x8b, 0xed, 0x23, 0x74, 0xa0, 0x6b}};

*/

#ifndef GUIDS_ONLY

#undef DBPROP_SSCE_COL_ROWGUID
#undef DBPROP_SSCE_MAXBUFFERSIZE
#undef DBPROP_SSCE_DBPASSWORD
#undef DBPROP_SSCE_ENCRYPTDATABASE
#undef DBPROP_SSCE_TEMPFILE_DIRECTORY


// PUBLISHED Provider specific properties
//
#define DBPROP_SSCE3_COL_ROWGUID					0x1F9L      // SSCE_COLUMN
#define DBPROP_SSCE3_MAXBUFFERSIZE					0x1FAL      // SSCE_DBINIT
#define DBPROP_SSCE3_DBPASSWORD						0x1FBL      // SSCE_DBINIT
#define DBPROP_SSCE3_ENCRYPTDATABASE				0x1FCL      // SSCE_DBINIT
#define DBPROP_SSCE3_TEMPFILE_DIRECTORY				0x1FEL      // SSCE_DBINIT


// FOR SQL CE 2.0 ONLY
//
#define DBPROP_SSCE_TBL_DISTINCT					0x64
#define DBPROP_SSCE_COL_TTKEYASCENDING				0x65
#define DBPROP_SSCE_COL_TTKEYORDINAL				0x66
#define DBPROP_SSCE_TBL_TTTYPE						0x67
#define DBPROP_SSCE_PARTIALSETDATA					0x68

#define DBPROP_SSCE2_COL_ROWGUID					0x69
#define DBPROP_SSCE2_MAXBUFFERSIZE					0x70
#define DBPROP_SSCE2_DBPASSWORD						0x71
#define DBPROP_SSCE2_ENCRYPTDATABASE				0x72
#define DBPROP_SSCE2_TEMPFILE_DIRECTORY				0x73

#endif

/*********************************************************************/

#ifdef __cplusplus
}
#endif

#endif // __sqlce_ex_h__
<file_sep>/7-Zip/CPP/7zip/UI/FileManager/PropertyNameRes.h
#define IDS_PROP_PATH                3
#define IDS_PROP_NAME                4
#define IDS_PROP_EXTENSION           5
#define IDS_PROP_IS_FOLDER           6
#define IDS_PROP_SIZE                7
#define IDS_PROP_PACKED_SIZE         8
#define IDS_PROP_ATTRIBUTES          9
#define IDS_PROP_CTIME              10
#define IDS_PROP_ATIME              11
#define IDS_PROP_MTIME              12
#define IDS_PROP_SOLID              13
#define IDS_PROP_C0MMENTED          14
#define IDS_PROP_ENCRYPTED          15
#define IDS_PROP_DICTIONARY_SIZE    16
#define IDS_PROP_SPLIT_BEFORE       17
#define IDS_PROP_SPLIT_AFTER        18
#define IDS_PROP_CRC                19
#define IDS_PROP_FILE_TYPE          20
#define IDS_PROP_ANTI               21
#define IDS_PROP_METHOD             22
#define IDS_PROP_HOST_OS            23
#define IDS_PROP_FILE_SYSTEM        24
#define IDS_PROP_USER               25
#define IDS_PROP_GROUP              26
#define IDS_PROP_BLOCK              27
#define IDS_PROP_COMMENT            28
#define IDS_PROP_POSITION           29
#define IDS_PROP_PREFIX             30
#define IDS_PROP_FOLDERS            31
#define IDS_PROP_FILES              32
#define IDS_PROP_VERSION            33
#define IDS_PROP_VOLUME             34
#define IDS_PROP_IS_VOLUME          35
#define IDS_PROP_OFFSET             36
#define IDS_PROP_LINKS              37
#define IDS_PROP_NUM_BLOCKS         38
#define IDS_PROP_NUM_VOLUMES        39

#define IDS_PROP_BIT64              41
#define IDS_PROP_BIG_ENDIAN         42
#define IDS_PROP_CPU                43
#define IDS_PROP_PHY_SIZE           44
#define IDS_PROP_HEADERS_SIZE       45
#define IDS_PROP_CHECKSUM           46
#define IDS_PROP_CHARACTS           47
#define IDS_PROP_VA                 48
#define IDS_PROP_ID                 49
#define IDS_PROP_SHORT_NAME         50
#define IDS_PROP_CREATOR_APP        51
#define IDS_PROP_SECTOR_SIZE        52
#define IDS_PROP_POSIX_ATTRIB       53
#define IDS_PROP_LINK               54
<file_sep>/7-Zip/CPP/7zip/Archive/Wim/WimHandler.h
// WimHandler.h

#ifndef __ARCHIVE_WIM_HANDLER_H
#define __ARCHIVE_WIM_HANDLER_H

#include "Common/MyCom.h"
#include "Common/MyXml.h"

#include "../IArchive.h"
#include "WimIn.h"

namespace NArchive {
namespace NWim {

struct CVolume
{
  CHeader Header;
  CMyComPtr<IInStream> Stream;
};

struct CImageInfo
{
  bool CTimeDefined;
  bool MTimeDefined;
  bool NameDefined;
  // bool IndexDefined;
  
  FILETIME CTime;
  FILETIME MTime;
  UString Name;
  // UInt32 Index;
  
  CImageInfo(): CTimeDefined(false), MTimeDefined(false), NameDefined(false)
      // , IndexDefined(false)
      {}
  void Parse(const CXmlItem &item);
};

struct CXml
{
  CByteBuffer Data;
  UInt16 VolIndex;

  CObjectVector<CImageInfo> Images;

  void Parse();
};

class CHandler:
  public IInArchive,
  public CMyUnknownImp
{
public:
  MY_UNKNOWN_IMP1(IInArchive)
  INTERFACE_IInArchive(;)

private:
  CDatabase m_Database;
  CObjectVector<CVolume> m_Volumes;
  CObjectVector<CXml> m_Xmls;
  int m_NameLenForStreams;
};

}}

#endif
<file_sep>/FingerSuite/Common/AboutView.h
// Test99View.h : interface of the CTest99View class
//
/////////////////////////////////////////////////////////////////////////////

#pragma once

#ifndef __cplusplus
  #error ATL requires C++ compilation (use a .cpp suffix)
#endif

#ifndef __ATLMISC_H__
  #error AboutView.h requires atlmisc.h to be included first
#endif

// Extracted from MFC 7.0 source code by <NAME>
BOOL AfxExtractSubString(CString& rString, LPCTSTR lpszFullString,
	int iSubString, TCHAR chSep)
{
	if (lpszFullString == NULL)
		return FALSE;

	while (iSubString--)
	{
		lpszFullString = _tcschr(lpszFullString, chSep);
		if (lpszFullString == NULL)
		{
			rString.Empty();        // return empty string as well
			return FALSE;
		}
		lpszFullString++;       // point past the separator
	}
	LPCTSTR lpchEnd = _tcschr(lpszFullString, chSep);
	int nLen = (lpchEnd == NULL) ?
		lstrlen(lpszFullString) : (int)(lpchEnd - lpszFullString);
	ATLASSERT(nLen >= 0);
	memcpy(rString.GetBufferSetLength(nLen), lpszFullString, nLen*sizeof(TCHAR));
	return TRUE;
}

class CAboutView : public CWindowImpl<CAboutView>
{
public:
	DECLARE_WND_CLASS(NULL)

	BOOL PreTranslateMessage(MSG* pMsg)
	{
		pMsg;
		return FALSE;
	}

	void SetCredits(LPCTSTR lpszCredits)
	{
		m_strCredits = lpszCredits;
	}

	void SetBitmap(HBITMAP hBmp, int x, int y)
	{
		m_hBitmap = hBmp;
		m_ptPos.x = x;
		m_ptPos.y = y;
	}

	BEGIN_MSG_MAP(CAboutView)
		MESSAGE_HANDLER(WM_PAINT, OnPaint)
	END_MSG_MAP()

// Handler prototypes (uncomment arguments if needed):
//	LRESULT MessageHandler(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
//	LRESULT CommandHandler(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
//	LRESULT NotifyHandler(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/)

	LRESULT OnPaint(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		CPaintDC dc(m_hWnd);
		RECT rc; GetClientRect(&rc);

		//TODO: Add your drawing code here
		CFont cOldFont;

		CFont cFontNormal = dc.GetCurrentFont();
		LOGFONT lf; cFontNormal.GetLogFont(lf);

		lf.lfWeight = FW_BOLD;
		CFont cFontBold; cFontBold.CreateFontIndirect(&lf);

		lf.lfHeight -= 2;
		CFont cFontTitle; cFontTitle.CreateFontIndirect(&lf);

		dc.SetBkMode(TRANSPARENT);

		CString strSub;
		int nCount=0;
		// draw each line, based on specified type
		while(AfxExtractSubString(strSub, m_strCredits, nCount++, '\n'))
		{
			TCHAR nType = 0;

			if (!strSub.IsEmpty())
				nType = strSub.GetAt(0);

			switch(nType)
			{
				case '\t':	// title
					dc.SetTextColor(RGB(16,140,231));
					cOldFont = dc.SelectFont(cFontTitle);
					strSub.TrimLeft('\t');
					dc.DrawText(strSub, strSub.GetLength(), &rc, DT_TOP|DT_CENTER|DT_NOPREFIX | DT_SINGLELINE);
					dc.SelectFont(cOldFont);
					break;
				case '\r':	// bold
					dc.SetTextColor(RGB(0,0,0));
					cOldFont = dc.SelectFont(cFontBold);
					strSub.TrimLeft('\r');
					dc.DrawText(strSub, strSub.GetLength(), &rc, DT_TOP|DT_CENTER|DT_NOPREFIX | DT_SINGLELINE);
					dc.SelectFont(cOldFont);
					break;
				default:	// normal
					dc.SetTextColor(RGB(0,0,0));
					cOldFont = dc.SelectFont(cFontNormal);
					dc.DrawText(strSub, strSub.GetLength(), &rc, DT_TOP|DT_CENTER|DT_NOPREFIX | DT_SINGLELINE);
					dc.SelectFont(cOldFont);
					break;
			}
			// next line
			TEXTMETRIC tm;  
			dc.GetTextMetricsW(&tm);
			rc.top += tm.tmHeight;
		}
		return 0;
	}

private:
	CString m_strCredits;
	HBITMAP m_hBitmap;
	POINT m_ptPos;


};
<file_sep>/FBReaderJ/jni/HanvonUtil.h

#ifndef HANVONUTIL_H_
#define HANVONUTIL_H_


#ifdef DEBUG_LOG
#include <android/log.h>
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,	"=== HAN.WANG ===",	__VA_ARGS__)
#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,	"=== HAN.WANG ===",	__VA_ARGS__)
#define LOGI(...) __android_log_print(ANDROID_LOG_INFO,		"=== HAN.WANG ===",	__VA_ARGS__)
#define LOGV(...) __android_log_print(ANDROID_LOG_VERBOSE,	"=== HAN.WANG ===",	__VA_ARGS__)
#define LOGW(...) __android_log_print(ANDROID_LOG_WARN,		"=== HAN.WANG ===",	__VA_ARGS__)

#else
#define LOGD(...)
#define LOGE(...)
#define LOGI(...)
#define LOGV(...)
#define LOGW(...)

#endif

#endif /* HANVONUTIL_H_ */
<file_sep>/FingerSuite/FingerNotification/MainFrm.h
// MainFrm.h : interface of the CMainFrame class
//
/////////////////////////////////////////////////////////////////////////////

#pragma once

#include "..\Common\AboutView.h"

typedef enum {QVGA = 320, WQVGA = 400, VGA = 640, WVGA = 800} RESOLUTION;

static UINT UWM_INTERCEPT_NOTIF = ::RegisterWindowMessage(UWM_INTERCEPT_NOTIF_MSG);
static UINT UWM_NOTIF_POPUP = ::RegisterWindowMessage(UWM_NOTIF_POPUP_MSG);





typedef struct tagNMSHN_LINK
{
	NMSHN inner;
	WCHAR szLink[1024];
} NMSHN_LINK, *LPNMSHN_LINK;





class CMainFrame : public CFrameWindowImpl<CMainFrame>, public CUpdateUI<CMainFrame>,
 	public CFullScreenFrame<CMainFrame, false>, public CMessageFilter, public CIdleHandler
{
public:
	DECLARE_FRAME_WND_CLASS(NULL, IDR_MAINFRAME)

	CHTMLNotifWindow m_notif;
	CNotifListWindow m_list;
	CAboutView       m_aboutView;

	virtual BOOL PreTranslateMessage(MSG* pMsg)
	{
		if(CFrameWindowImpl<CMainFrame>::PreTranslateMessage(pMsg))
			return TRUE;

		return m_list.PreTranslateMessage(pMsg);
	}

	virtual BOOL OnIdle()
	{
		return FALSE;
	}


	BEGIN_UPDATE_UI_MAP(CMainFrame)
	END_UPDATE_UI_MAP()

	BEGIN_MSG_MAP(CMainFrame)
		MESSAGE_HANDLER(WM_CREATE, OnCreate)
		MESSAGE_HANDLER(WM_SIZE, OnSize)
		MESSAGE_HANDLER(WM_ACTIVATE, OnActivate)
		MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBkgnd)
		MESSAGE_HANDLER(UWM_INTERCEPT_NOTIF, OnInterceptNotif)
		MESSAGE_HANDLER(UWM_NOTIF_POPUP, OnNotifPopup)
		MESSAGE_HANDLER(WM_NOTIFY, OnNotify)
		MESSAGE_HANDLER(UM_SELECTNOTIF, OnSelectNotif)
		MESSAGE_HANDLER(UM_MINIMIZE, OnMinimize)
		COMMAND_ID_HANDLER(ID_MENU_EXIT, OnMenuExit)
		COMMAND_ID_HANDLER(ID_MENU_ABOUT, OnMenuAbout)
		COMMAND_ID_HANDLER(ID_MENU_SHOWORIGINAL, OnMenuShowOriginal)
		MESSAGE_HANDLER(WM_COMMAND, OnCommand)
		CHAIN_MSG_MAP(CUpdateUI<CMainFrame>)
		CHAIN_MSG_MAP(CFrameWindowImpl<CMainFrame>)
	END_MSG_MAP()

// Handler prototypes (uncomment arguments if needed):
//	LRESULT MessageHandler(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
//	LRESULT CommandHandler(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
//	LRESULT NotifyHandler(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/)

	LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		CreateSimpleCEMenuBar();

		LoadConfiguration();

		m_hWndClient = m_list.Create(m_hWnd, rcDefault, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN);

		m_notif.Create(m_hWnd, rcDefault, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN);

		CString strCredits = "\n\n"
			    "\tFingerNotification v1.00\n\n"
				"\rDeveloped by:\n"
				"<NAME>\n"
				"<<EMAIL>>\n"
				"\n\n"
				"http://forum.xda-developers.com/\n"
				"                showthread.php?t=459125\n";

		m_aboutView.SetCredits(strCredits);
		m_aboutView.Create(m_hWnd, rcDefault, NULL, WS_CHILD | WS_VISIBLE |WS_CLIPSIBLINGS | WS_CLIPCHILDREN);  //


		// register object for message filtering and idle updates
		CMessageLoop* pLoop = _Module.GetMessageLoop();
		ATLASSERT(pLoop != NULL);
		pLoop->AddMessageFilter(this);
		pLoop->AddIdleHandler(this);

		SetHWndServerNotif(m_hWnd);

		InstallHookOnShell();

		Sleep(1000);

		//ParseStandardNotification();
		ModifyStyle(0, WS_NONAVDONEBUTTON, SWP_NOSIZE);

		InstallHookOnHHTaskBar();

		LOG(L"FingerNotification started.\n");

		return 0;
	}

	LRESULT OnSize(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled)
	{
		if(wParam != SIZE_MINIMIZED)
		{
		}
			
		return 0;
	}

	LRESULT OnActivate(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		int fActive = LOWORD(wParam); 
		if ((fActive == WA_ACTIVE) || (fActive == WA_CLICKACTIVE))
		{
		}
		else if (fActive == WA_INACTIVE)
		{
			if (IsWindowVisible())
			{
				Minimize();
			}
		}
		return 0;
	}

	LRESULT OnEraseBkgnd(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		CDCHandle dc( (HDC) wParam );
		RECT rc; GetClientRect(&rc);

		if (m_bDisabledTransp)
		{
			dc.FillSolidRect(&rc, m_clNoTranspBackground);
		}
		else
		{
			if (!(m_imgBkg.IsValid()))
				CaptureScreen(dc);

			m_imgBkg.Draw(dc, rc);
		}
		return 1;
	}



	LRESULT OnInterceptNotif(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/)
	{
		int idx;
		LPNOTIFICATIONINFO pInfo = (LPNOTIFICATIONINFO)malloc(sizeof(NOTIFICATIONINFO));
		memcpy(pInfo, (LPNOTIFICATIONINFO)lParam, sizeof(NOTIFICATIONINFO));

		// adjust pointers
		pInfo->nd.pszTitle = pInfo->szTitle;
		pInfo->nd.pszHTML = pInfo->szHTML;

		// menu
		if (pInfo->nd.grfFlags & SHNF_HASMENU)
		{
			pInfo->nd.skm.prgskc = pInfo->rgskc;
		}
		else
		{
			pInfo->nd.rgskn[0].pszTitle = pInfo->sk1Title;
			pInfo->nd.rgskn[1].pszTitle = pInfo->sk2Title;
		}

		DUMP_SHN(&pInfo->nd);


		switch (wParam)
		{
		case NOTIF_ADD:

			LOG(L"\nNOTIF_ADD\n");

			g_pNotifications.Add(pInfo);

			if (pInfo->isManaged)
			{
				// tempor disabled
				//ShowNotification(g_pNotifications.GetSize() - 1); // show last notification added
			}
			
			break;
		case NOTIF_UPD:

			LOG(L"\nNOTIF_UPD\n");

			idx = -1;
			for (int i = 0; i < g_pNotifications.GetSize(); i++)
			{
				LPNOTIFICATIONINFO pFind = g_pNotifications[i];
				if (
					//(pFind->nd.dwID == pData->nd.dwID) &&
					(IsEqualCLSID(pFind->nd.clsid, pInfo->nd.clsid)))
				{
					idx = i;
					break;
				}
			}

			if (idx > -1)
			{
				free(g_pNotifications[idx]);
				g_pNotifications.RemoveAt(idx);
				g_pNotifications.Add(pInfo);

				// tempor disabled
				if (pInfo->isManaged)
					ShowNotification(g_pNotifications.GetSize() - 1); // show last notification added
			}

			break;
		case NOTIF_DEL:

			LOG(L"\nNOTIF_DEL\n");

			idx = -1;
			for (int i = 0; i < g_pNotifications.GetSize(); i++)
			{
				LPNOTIFICATIONINFO pFind = g_pNotifications[i];
				if (
					//(pFind->nd.dwID == pData->nd.dwID) &&
					(IsEqualCLSID(pFind->nd.clsid, pInfo->nd.clsid)))
				{
					idx = i;
					break;
				}
			}

			if (idx > -1)
			{
				free(g_pNotifications[idx]);
				g_pNotifications.RemoveAt(idx);
			}


			break;
		} // end switch

		return 0;
	}

	LRESULT OnNotifPopup(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		ShowNotificationList();
		return 0;
	}

	LRESULT OnCommand(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		WORD wID = LOWORD(wParam); 

		// ricerca 
		LPNOTIFICATIONINFO pInfo = g_pNotifications[m_idx];
		BOOL bSendCommand = TRUE;
		DWORD dwSoftkeyType = 0;
		HWND hwndSink = pInfo->nd.hwndSink;

		if (pInfo->nd.grfFlags & SHNF_HASMENU)
		{
			for (UINT i = 0; i < pInfo->nd.skm.cskc; i++)
			{
				if (wID == pInfo->nd.skm.prgskc[i].wpCmd)
				{
					dwSoftkeyType = pInfo->nd.skm.prgskc[i].grfFlags;
					break; // exit for
				}
			}
		}
		else
		{
			if (pInfo->nd.rgskn[0].skc.wpCmd == wID)
				dwSoftkeyType = pInfo->nd.rgskn[0].skc.grfFlags;

			if (pInfo->nd.rgskn[1].skc.wpCmd == wID)
				dwSoftkeyType = pInfo->nd.rgskn[1].skc.grfFlags;
		}


		if (dwSoftkeyType == NOTIF_SOFTKEY_FLAGS_DISMISS)
		{
			SendNotifyDismiss(pInfo, FALSE);
			SHNotificationRemove(&pInfo->nd.clsid, pInfo->nd.dwID);
			Minimize();
		}
		if (dwSoftkeyType & NOTIF_SOFTKEY_FLAGS_HIDE)
		{
			Minimize();
		}
		if (dwSoftkeyType & NOTIF_SOFTKEY_FLAGS_STAYOPEN)
		{
		}
		if (dwSoftkeyType & NOTIF_SOFTKEY_FLAGS_SUBMIT_FORM)
		{
			bSendCommand = FALSE;
			m_notif.SubmitForm();
			Minimize();
		}

		if (bSendCommand)
			::PostMessage(hwndSink, WM_COMMAND, (WPARAM)wID, (LPARAM)0);


		return 0;
	}

	LRESULT OnNotify(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/)
	{
		LOG(L"\n");

		LPNOTIFICATIONINFO pInfo = g_pNotifications[m_idx];

		DWORD dwCmd = 0;

		int idCtrl = (int) wParam; 

		NM_HTMLVIEW * pnmHTML = (NM_HTMLVIEW *) lParam;
		LPNMHDR pnmh = (LPNMHDR) &(pnmHTML->hdr);

		switch (pnmh->code)
		{
		case NM_INLINE_IMAGE:
			LOG(L"NM_INLINE_IMAGE\n\n");
		   	if (lstrcmpi(pnmHTML->szTarget, L"fngrnotif_btn_bkg.gif") == 0)
			{
				INLINEIMAGEINFO imageInfo;
				imageInfo.dwCookie    = pnmHTML->dwCookie;
				imageInfo.bOwnBitmap  = FALSE;
				imageInfo.hbm         = m_bmpHtmlButton;
				imageInfo.iOrigWidth  = 1;
				imageInfo.iOrigHeight = 70;

				m_notif.m_html.SetImage(&imageInfo);
			}

			break;
		case NM_HOTSPOT:
			LOG(L"NM_HOTSPOT\n\n");

			SendNotifyDismiss(pInfo, FALSE);
			Minimize();

			// command in format of cmd:XXX 
			// sent to hwndSink
			
			swscanf(pnmHTML->szTarget, L"cmd:%d", &dwCmd);

			if (dwCmd != 0)
			{
				::PostMessage(pInfo->nd.hwndSink, WM_COMMAND, (WPARAM)dwCmd, (LPARAM)0);
			}
			else
			{
				// send SHNM_LINKSEL
				SendNotifyLink(pInfo, pnmHTML->szTarget);
			}

			break;
		
		case NM_BEFORENAVIGATE:
			LOG(L"NM_BEFORENAVIGATE\n");
			LOG(L"\n");
			break;
		case NM_DOCUMENTCOMPLETE:
			LOG(L"NM_DOCUMENTCOMPLETE\n");
			LOG(L"\n");
			m_notif.UpdateWindow();
			break;
		
		default:
			LOG(L"NOT MANAGED: %X\n", pnmh->code);
			LOG(L"\n");
		}

		LOG(L"pnmHTML->szTarget: %s\n", pnmHTML->szTarget);
		LOG(L"pnmHTML->szData: %s\n", pnmHTML->szData);
		LOG(L"pnmHTML->szExInfo: %s\n", pnmHTML->szExInfo);

		return 0;
	}

	LRESULT OnSelectNotif(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		int idx = (int)wParam;
		LPNOTIFICATIONINFO pInfo = g_pNotifications[idx];
		if (pInfo->nd.npPriority != SHNP_ICONIC)
			ShowNotification(idx);
		return 0;
	}

	LRESULT OnMinimize(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		Minimize();
		return 0;
	}

	LRESULT OnMenuExit(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& bHandled)
	{
		Minimize();

		PostMessage(WM_CLOSE);

		bHandled = TRUE;
		return 0;
	}


	LRESULT OnMenuAbout(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& bHandled)
	{
		SwitchToAboutView();
		SetForegroundWindow((HWND)((ULONG) m_hWnd | 0x00000001));
		ShowWindow(SW_SHOW);	
		bHandled = TRUE;
		return 0;
	}		

	LRESULT OnMenuShowOriginal(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& bHandled)
	{
		Minimize();
		// TODO
		
		bHandled = TRUE;
		return 0;
	}

public:


	static HRESULT ActivatePreviousInstance(HINSTANCE hInstance)
	{
		const TCHAR* pszMutex = L"FINGERNOTIFMUTEX";
		const TCHAR* pszClass = L"FINGER_NOTIFICATION";

		const DWORD dRetryInterval = 100; 

		const int iMaxRetries = 25;

		for(int i = 0; i < iMaxRetries; ++i)
		{
			HANDLE hMutex = CreateMutex(NULL, FALSE, pszMutex);

			DWORD dw = GetLastError();

			if(hMutex == NULL)
			{
				HRESULT hr = (dw == ERROR_INVALID_HANDLE) ? E_INVALIDARG : E_FAIL;
				return hr;
			}

			if(dw == ERROR_ALREADY_EXISTS)
			{
				CloseHandle(hMutex);

				HWND hwnd = FindWindow(pszClass, NULL);

				if(hwnd == NULL)
				{
					Sleep(dRetryInterval);
					continue;
				}
				else
				{
					if(SetForegroundWindow(reinterpret_cast<HWND>(reinterpret_cast<ULONG>(hwnd) | 0x1)) != 0)
					{
						return S_FALSE;
					}
				}
			}
			else
			{
				return S_OK;
			}
		}

		return S_OK;
	}

	void Show()
	{
		SetForegroundWindow((HWND)((ULONG) m_hWnd | 0x00000001));
		ShowWindow(SW_SHOW);
	}

	void Minimize()
	{
		ShowWindow(SW_HIDE);
	}

private:

	int m_idx;
	CxImage m_imgBkg;
	DWORD m_iTransp;
	BOOL m_bDisabledTransp;
	COLORREF m_clNoTranspBackground;
	HBITMAP m_bmpHtmlButton;

	void SendNotifyDismiss(LPNOTIFICATIONINFO pData, BOOL bTimeout)
	{
		NMSHN nm;
		ZeroMemory(&nm, sizeof(NMSHN));
		nm.hdr.code = SHNN_DISMISS;
		nm.hdr.idFrom = pData->nd.dwID;
		nm.lParam = pData->nd.lParam;
		nm.fTimeout = bTimeout;
		
		SendMessageRemote(pData->nd.hwndSink, WM_NOTIFY, 0, (LPARAM)&nm, sizeof(NMSHN));
	}

	void SendNotifyShow(LPNOTIFICATIONINFO pData)
	{
		NMSHN nm;
		ZeroMemory(&nm, sizeof(NMSHN));
		nm.hdr.code = SHNN_SHOW;
		nm.hdr.idFrom = pData->nd.dwID;
		nm.lParam = pData->nd.lParam;
		nm.pt.x = 1;
		nm.pt.y = 1;
		
		SendMessageRemote(pData->nd.hwndSink, WM_NOTIFY, 0, (LPARAM)&nm, sizeof(NMSHN));
	}

	void SendNotifyLink(LPNOTIFICATIONINFO pData, LPCTSTR pszLink)
	{
		HANDLE hFile = NULL;
		LPVOID pView = PrepareRemoteMessage(&hFile, sizeof(NMSHN_LINK));

		if (pView != NULL)
		{
			LPNMSHN_LINK lpnm = (LPNMSHN_LINK)pView;
			ZeroMemory(lpnm, sizeof(NMSHN_LINK));
			lpnm->inner.hdr.code = SHNN_LINKSEL;
			lpnm->inner.hdr.idFrom = pData->nd.dwID;
			lpnm->inner.lParam = pData->nd.lParam;
			lpnm->inner.dwReturn = 1;
			wsprintf(lpnm->szLink, L"%s", pszLink);
			lpnm->inner.pszLink = lpnm->szLink;
			
			SendMessage(pData->nd.hwndSink, WM_NOTIFY, 0, (LPARAM)lpnm);
			
			CloseRemoteMessage(hFile, pView);
		}
	}

	void LoadConfiguration()
	{
		WCHAR keyName[] = L"Software\\FingerNotification";

		// load transparency level

		m_iTransp = 128;
		if (!(RegReadDWORD(HKEY_LOCAL_MACHINE, keyName, L"TransparencyLevel", m_iTransp)))
			wprintf(L"Unable to read TransparencyLevel from registry: %s\n", ErrorString(GetLastError()));
		m_iTransp = m_iTransp;

		m_bDisabledTransp = FALSE;
		if (!(RegReadBOOL(HKEY_LOCAL_MACHINE, keyName, L"DisableTransparency", m_bDisabledTransp)))
			wprintf(L"Unable to read DisableTransparency from registry: %s\n", ErrorString(GetLastError()));

		m_clNoTranspBackground = RGB(0,0,0);
		RegReadColor(HKEY_LOCAL_MACHINE, keyName, L"NoTranspBkgColor", m_clNoTranspBackground);

		m_notif.m_bEnableAnimation = TRUE;
		if (!(RegReadBOOL(HKEY_LOCAL_MACHINE, keyName, L"EnableAnimation", m_notif.m_bEnableAnimation)))
			LOG(L"Unable to read EnableAnimation from registry: %s\n", ErrorString(GetLastError()));
		
		if ( RegistryGetDWORD ( HKEY_LOCAL_MACHINE, keyName, L"AutoMinimizeInterval", &m_list.m_tmrMinimize) != S_OK )
			m_list.m_tmrMinimize = 3000;


		WCHAR szSkin[60] = L"default";
		RegReadString(HKEY_LOCAL_MACHINE, keyName, L"Skin", szSkin);
		WCHAR szAppPath[MAX_PATH] = L"";
		CString strAppDirectory;
		GetModuleFileName(NULL, szAppPath, MAX_PATH);
		strAppDirectory = szAppPath;
		strAppDirectory = strAppDirectory.Left(strAppDirectory.ReverseFind('\\'));
		CString skinBasePath; skinBasePath.Format(L"%s\\skins\\%s", strAppDirectory, szSkin);
		
		// detect resolution
		RESOLUTION resolution = QVGA;
		DEVMODE dm;
		::ZeroMemory(&dm, sizeof(DEVMODE));
		dm.dmSize = sizeof(DEVMODE);
		if (EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dm))
		{
			resolution = (RESOLUTION)dm.dmPelsHeight;
		}

		// load icon images
		switch (resolution)
		{
		case QVGA:
		case WQVGA:
			m_notif.SetScaleFactor(1);
			m_list.SetScaleFactor(1);
			break;
		case VGA:
		case WVGA:
			m_notif.SetScaleFactor(2);			
			m_list.SetScaleFactor(2);			
			break;
		}		

		if ( (resolution == VGA) || (resolution == WVGA))
		{
			m_notif.m_imgHeader.Load(skinBasePath + L"\\notif_header_vga.png", CXIMAGE_FORMAT_PNG);
			m_notif.m_imgCalendar.Load(skinBasePath + L"\\icon_calendar_vga.png", CXIMAGE_FORMAT_PNG);
			m_list.m_notiflist.m_imgSelection.Load(skinBasePath + L"\\list_selection_vga.png", CXIMAGE_FORMAT_PNG);
			//m_list.m_imgIconBkg.Load(skinBasePath + L"\\icon_bkg_vga.png", CXIMAGE_FORMAT_PNG);

			// normal
			AddStaticSet(m_list.m_arrStaticImages, NORMAL, skinBasePath + L"\\notif_button_normal_vga.png");

			// pressed
			AddStaticSet(m_list.m_arrStaticImages, PUSHED, skinBasePath + L"\\notif_button_pressed_vga.png");

			// icons
			m_list.m_notiflist.AddIcon(L"missedcall", skinBasePath + L"\\icons\\notifications_icon_MissedCall_vga.png");
			m_list.m_notiflist.AddIcon(L"reminder", skinBasePath + L"\\icons\\notifications_icon_Reminder_vga.png");
			m_list.m_notiflist.AddIcon(L"message", skinBasePath + L"\\icons\\notifications_icon_Messages_vga.png");
			m_list.m_notiflist.AddIcon(L"warning", skinBasePath + L"\\icons\\notifications_icon_Warning_vga.png");
			m_list.m_notiflist.AddIcon(L"email", skinBasePath + L"\\icons\\notifications_icon_Email_vga.png");
			m_list.m_notiflist.AddIcon(L"wifi", skinBasePath + L"\\icons\\notifications_icon_Wifi_vga.png");
			m_list.m_notiflist.AddIcon(L"bluetooth", skinBasePath + L"\\icons\\notifications_icon_Bluetooth_vga.png");

		}
		else
		{
			m_notif.m_imgHeader.Load(skinBasePath + L"\\notif_header_qvga.png", CXIMAGE_FORMAT_PNG);
			m_notif.m_imgCalendar.Load(skinBasePath + L"\\icon_calendar_qvga.png", CXIMAGE_FORMAT_PNG);
			m_list.m_notiflist.m_imgSelection.Load(skinBasePath + L"\\list_selection_qvga.png", CXIMAGE_FORMAT_PNG);
			//m_list.m_imgIconBkg.Load(skinBasePath + L"\\icon_bkg_qvga.png", CXIMAGE_FORMAT_PNG);

			// normal
			AddStaticSet(m_list.m_arrStaticImages, NORMAL, skinBasePath + L"\\notif_button_normal_qvga.png");

			// pressed
			AddStaticSet(m_list.m_arrStaticImages, PUSHED, skinBasePath + L"\\notif_button_pressed_qvga.png");

			// icons
			m_list.m_notiflist.AddIcon(L"missedcall", skinBasePath + L"\\icons\\notifications_icon_MissedCall_qvga.png");
			m_list.m_notiflist.AddIcon(L"reminder", skinBasePath + L"\\icons\\notifications_icon_Reminder_qvga.png");
			m_list.m_notiflist.AddIcon(L"message", skinBasePath + L"\\icons\\notifications_icon_Messages_qvga.png");
			m_list.m_notiflist.AddIcon(L"warning", skinBasePath + L"\\icons\\notifications_icon_Warning_qvga.png");
			m_list.m_notiflist.AddIcon(L"email", skinBasePath + L"\\icons\\notifications_icon_Email_qvga.png");
			m_list.m_notiflist.AddIcon(L"wifi", skinBasePath + L"\\icons\\notifications_icon_Wifi_qvga.png");
			m_list.m_notiflist.AddIcon(L"bluetooth", skinBasePath + L"\\icons\\notifications_icon_Bluetooth_qvga.png");

		}

		m_bmpHtmlButton = SHLoadImageFile(skinBasePath + L"\\fngrnotif_btn_bkg.gif");
		
		// load skin settings
		CSimpleIniW ini(TRUE, TRUE, TRUE);
		SI_Error rc = ini.LoadFile(skinBasePath + L"\\settings_fingernotif.ini");

		// load background and selected color
		COLORREF clValue = 0;
		m_notif.m_clCaptionText     = (StringRGBToColor(ini.GetValue(L"colors", L"CaptionTextColor"), clValue)) ? clValue : RGB(255,255,255);
		m_list.m_clText             = (StringRGBToColor(ini.GetValue(L"colors", L"TextColor"), clValue)) ? clValue : RGB(255,255,255);
		m_list.m_notiflist.m_clText = m_list.m_clText;
		m_list.m_clLine             = (StringRGBToColor(ini.GetValue(L"colors", L"LineColor"), clValue)) ? clValue : RGB(97,97,97);
		m_list.m_notiflist.m_clLine = m_list.m_clLine;
		m_list.m_notiflist.m_clBkg  = (StringRGBToColor(ini.GetValue(L"colors", L"ListBkgColor"), clValue)) ? clValue : RGB(60,60,60);
		m_list.m_clBkgHeader        = (StringRGBToColor(ini.GetValue(L"colors", L"ListBkgHeaderColor"), clValue)) ? clValue : RGB(40,40,40);

		LOGFONT lf;
		if (StringToLogFont(ini.GetValue(L"fonts", L"NotifCaptionFont"), lf))
		{
			m_notif.m_fCaption.CreateFontIndirect(&lf);
		}
		if (StringToLogFont(ini.GetValue(L"fonts", L"ListHeaderTextFont"), lf))
		{
			m_list.m_fHeaderText.CreateFontIndirect(&lf);
		}
		if (StringToLogFont(ini.GetValue(L"fonts", L"ListTextFont"), lf))
		{
			m_list.m_notiflist.m_fText.CreateFontIndirect(&lf);
		}
		if (StringToLogFont(ini.GetValue(L"fonts", L"ListTitleFont"), lf))
		{
			m_list.m_fTitleText.CreateFontIndirect(&lf);
		}
	}



	void ShowNotification(int idx)
	{
		m_idx = idx;  

		LPNOTIFICATIONINFO pInfo = g_pNotifications[m_idx];

		if (pInfo->nd.npPriority != SHNP_ICONIC)
		{
			if (   (!(pInfo->grfFlagsOriginal & SHNF_STRAIGHTTOTRAY)) 
				|| (!(pInfo->grfFlagsOriginal & SHNF_SILENT)) 
				|| (pInfo->grfFlagsOriginal & SHNF_FORCEMESSAGE)
				|| (pInfo->grfFlagsOriginal & SHNF_CRITICAL)
				 )
			{
				CreateMenuBar(pInfo);
				SendNotifyShow(pInfo);
				m_list.StopMinimizeTimer();
				m_notif.SetNotification(pInfo);
				SetFullScreen(false);
				Show();
				SwitchToNotifView();
				m_notif.Show();
			}
		}
	}

	void ShowNotificationList()
	{
		SwitchToListView();
		
		SetFullScreen(true);
		
		Show();
		m_list.Show();
	}

	void CreateMenuBar(LPNOTIFICATIONINFO pData)
	{
		if (::IsWindow(m_hWndCECommandBar))
		{
			::DestroyWindow(m_hWndCECommandBar);
		}

		if (pData->nd.grfFlags  & SHNF_HASMENU)
		{
			SHMENUBARINFO mbi;
			ZeroMemory(&mbi, sizeof(SHMENUBARINFO));
			mbi.cbSize     = sizeof(SHMENUBARINFO);
			mbi.hwndParent = m_hWnd;
			mbi.nToolBarId = (UINT)(pData->nd.skm.hMenu);
			mbi.hInstRes   = ModuleHelper::GetModuleInstance();
			mbi.dwFlags    = SHCMBF_HMENU;
			if(SHCreateMenuBar(&mbi))
			{
				m_hWndCECommandBar = mbi.hwndMB;
				SizeToMenuBar();
			}
			else
			{
				LOG(L"Error: %s\n", ErrorString(GetLastError()));
			}
		}
		else
		{
			// menu from soft key
			CMenuHandle m; m.CreatePopupMenu();
			if (pData->nd.rgskn[0].skc.wpCmd != 0)
				m.AppendMenu(MF_STRING, pData->nd.rgskn[0].skc.wpCmd, pData->nd.rgskn[0].pszTitle);
			if (pData->nd.rgskn[1].skc.wpCmd != 0)
				m.AppendMenu(MF_STRING, pData->nd.rgskn[1].skc.wpCmd, pData->nd.rgskn[1].pszTitle);
			
			SHMENUBARINFO mbi;
			ZeroMemory(&mbi, sizeof(SHMENUBARINFO));
			mbi.cbSize     = sizeof(SHMENUBARINFO);
			mbi.hwndParent = m_hWnd;
			mbi.nToolBarId = (UINT)m.m_hMenu;
			mbi.hInstRes   = ModuleHelper::GetModuleInstance();
			mbi.dwFlags    = SHCMBF_HMENU;
			if(SHCreateMenuBar(&mbi))
			{
				m_hWndCECommandBar = mbi.hwndMB;
				SizeToMenuBar();
			}
			else
			{
				LOG(L"Error: %s\n", ErrorString(GetLastError()));
			}
		}
	}


	void ParseStandardNotification()
	{
		CSimpleArray<CString> clsids;

		SHNOTIFICATIONDATA shnd;
		CLSID clsid;
		LRESULT result;
		DWORD dwID = 0;

		clsids.Add("{A877D661-239C-47a7-9304-0D347F580408}");
		clsids.Add("{A877D660-239C-47a7-9304-0D347F580408}");
		clsids.Add("{A877D65A-239C-47a7-9304-0D347F580408}");
		clsids.Add("{A877D65D-239C-47a7-9304-0D347F580408}");
		clsids.Add("{A877D659-239C-47a7-9304-0D347F580408}");
		clsids.Add("{A877D658-239C-47a7-9304-0D347F580408}");
		clsids.Add("{15F11F90-8A5F-454c-89FC-BA9B7AAB0CAD}");
		clsids.Add("{B67B425B-365E-42c0-95F7-B75503D775B8}");
		clsids.Add("{DDBD3B44-80B0-4b24-9DC4-839FEA6E559E}");
		clsids.Add("{8ddf46e8-56ed-4750-9e58-afc6ce486d03}");
		clsids.Add("{8ddf46e7-56ed-4750-9e58-afc6ce486d03}");
		clsids.Add("{0D3132C4-1298-469c-B2B8-F28CE2D649D0}");
		clsids.Add("{A877D663-239C-47a7-9304-0D347F580408}");
		clsids.Add("{E0F2B9DD-EDC6-45d4-B440-2C5B5A04A3E3}");
		clsids.Add("{A877D65B-239C-47a7-9304-0D347F580408}");
		clsids.Add("{F55615D6-D29E-4db8-8C75-98125D1A7253}");

		LOG(L"BEGIN parse\n");

		for (int i = 0; i < clsids.GetSize(); i++)
		{
			LOG(L"\nFinding %s\n", clsids[i]);

			LPOLESTR c = (LPOLESTR)((LPCTSTR)clsids[i]);
			if (0 == CLSIDFromString(c, &clsid)) 
			{
				dwID = 0;
				memset(&shnd, 0, sizeof(shnd));
				shnd.cbStruct = sizeof(SHNOTIFICATIONDATA);
				do {
					LOG(L".");

					result = SHNotificationGetData(&clsid, dwID, &shnd);
					if (ERROR_SUCCESS == result) {

						LOG(L"\nNotification found\n");
						DUMP_SHN(&shnd);
						LOG(L"\n\n");

						if (shnd.pszHTML) free((void *) shnd.pszHTML);
						shnd.pszHTML = NULL;
						if (shnd.pszTitle) free((void *) shnd.pszTitle);
						shnd.pszTitle = NULL;
					} else dwID++;
				} while ((ERROR_SUCCESS != result) && (dwID < 70000));
			}
		}

		LOG(L"END parse\n");
	}


	void SwitchToNotifView()
	{
		m_hWndClient = m_notif;

		m_list.ShowWindow(SW_HIDE);
		m_list.SetWindowLongPtr(GWL_ID, 0);

		m_notif.ShowWindow(SW_SHOW);
		m_notif.SetWindowLongPtr(GWL_ID, ATL_IDW_PANE_FIRST);
		m_notif.SetFocus();
	}

	void SwitchToListView()
	{
		m_hWndClient = m_list;

		m_notif.ShowWindow(SW_HIDE);
		m_notif.SetWindowLongPtr(GWL_ID, 0);

		m_list.ShowWindow(SW_SHOW);
		m_list.SetWindowLongPtr(GWL_ID, ATL_IDW_PANE_FIRST);
		m_list.SetFocus();
		m_list.Invalidate();
		m_list.UpdateWindow();

	}

	void SwitchToAboutView()
	{
		SetFullScreen(FALSE);

		m_hWndClient = m_aboutView;

		m_list.ShowWindow(SW_HIDE);
		m_list.SetWindowLongPtr(GWL_ID, 0);

		m_notif.ShowWindow(SW_HIDE);
		m_notif.SetWindowLongPtr(GWL_ID, 0);

		m_aboutView.ShowWindow(SW_SHOW);
		m_aboutView.SetWindowLongPtr(GWL_ID, ATL_IDW_PANE_FIRST);
		m_aboutView.SetFocus();
		UpdateLayout();
	}

	void CaptureScreen(CDCHandle dc)
	{
		RECT rc; GetClientRect(&rc);
		CDC dcTemp; dcTemp.CreateCompatibleDC(dc);
		CBitmap bmpBkg; bmpBkg.CreateCompatibleBitmap(dc, rc.right, rc.bottom);
		CBitmap bmpOld = dcTemp.SelectBitmap(bmpBkg);
		dcTemp.FillSolidRect(&rc, RGB(0,0,0));
		dcTemp.SelectBitmap(bmpOld);
		m_imgBkg.CreateFromHBITMAP(bmpBkg);
		m_imgBkg.AlphaCreate();
		m_imgBkg.AlphaSet((BYTE)m_iTransp);
	}

};
<file_sep>/SQLCEHelper/Include/sqlce_oledb.h
//=============================================================================
// Microsoft SQL Server Compact Edition (Version 3.5)
//
// Copyright (c)  Microsoft Corporation. All rights reserved.
//
// Component: Programmability (Native)
// 
// File:  sqlce_oledb.h
//
// File Comments:   OLE DB Native Programming Interfaces
//=============================================================================

#include "rpc.h"
#include "rpcndr.h"
#ifndef COM_NO_WINDOWS_H
#include "windows.h"
#include "ole2.h"
#endif /*COM_NO_WINDOWS_H*/


#ifndef __SQLCE_OLEDB_H__
#define __SQLCE_OLEDB_H__


#ifndef GUIDS_ONLY

#ifdef __cplusplus
extern "C"{
#endif 

/* Forward Declarations */ 

#ifndef __IAccessor_FWD_DEFINED__
#define __IAccessor_FWD_DEFINED__
typedef interface IAccessor IAccessor;
#endif 	/* __IAccessor_FWD_DEFINED__ */


#ifndef __IRowset_FWD_DEFINED__
#define __IRowset_FWD_DEFINED__
typedef interface IRowset IRowset;
#endif 	/* __IRowset_FWD_DEFINED__ */


#ifndef __IRowsetInfo_FWD_DEFINED__
#define __IRowsetInfo_FWD_DEFINED__
typedef interface IRowsetInfo IRowsetInfo;
#endif 	/* __IRowsetInfo_FWD_DEFINED__ */


#ifndef __IRowsetLocate_FWD_DEFINED__
#define __IRowsetLocate_FWD_DEFINED__
typedef interface IRowsetLocate IRowsetLocate;
#endif 	/* __IRowsetLocate_FWD_DEFINED__ */


#ifndef __IRowsetResynch_FWD_DEFINED__
#define __IRowsetResynch_FWD_DEFINED__
typedef interface IRowsetResynch IRowsetResynch;
#endif 	/* __IRowsetResynch_FWD_DEFINED__ */


#ifndef __IRowsetScroll_FWD_DEFINED__
#define __IRowsetScroll_FWD_DEFINED__
typedef interface IRowsetScroll IRowsetScroll;
#endif 	/* __IRowsetScroll_FWD_DEFINED__ */


#ifndef __IChapteredRowset_FWD_DEFINED__
#define __IChapteredRowset_FWD_DEFINED__
typedef interface IChapteredRowset IChapteredRowset;
#endif 	/* __IChapteredRowset_FWD_DEFINED__ */


#ifndef __IRowsetFind_FWD_DEFINED__
#define __IRowsetFind_FWD_DEFINED__
typedef interface IRowsetFind IRowsetFind;
#endif 	/* __IRowsetFind_FWD_DEFINED__ */


#ifndef __IRowPosition_FWD_DEFINED__
#define __IRowPosition_FWD_DEFINED__
typedef interface IRowPosition IRowPosition;
#endif 	/* __IRowPosition_FWD_DEFINED__ */


#ifndef __IRowPositionChange_FWD_DEFINED__
#define __IRowPositionChange_FWD_DEFINED__
typedef interface IRowPositionChange IRowPositionChange;
#endif 	/* __IRowPositionChange_FWD_DEFINED__ */


#ifndef __IViewRowset_FWD_DEFINED__
#define __IViewRowset_FWD_DEFINED__
typedef interface IViewRowset IViewRowset;
#endif 	/* __IViewRowset_FWD_DEFINED__ */


#ifndef __IViewChapter_FWD_DEFINED__
#define __IViewChapter_FWD_DEFINED__
typedef interface IViewChapter IViewChapter;
#endif 	/* __IViewChapter_FWD_DEFINED__ */


#ifndef __IViewSort_FWD_DEFINED__
#define __IViewSort_FWD_DEFINED__
typedef interface IViewSort IViewSort;
#endif 	/* __IViewSort_FWD_DEFINED__ */


#ifndef __IViewFilter_FWD_DEFINED__
#define __IViewFilter_FWD_DEFINED__
typedef interface IViewFilter IViewFilter;
#endif 	/* __IViewFilter_FWD_DEFINED__ */


#ifndef __IRowsetView_FWD_DEFINED__
#define __IRowsetView_FWD_DEFINED__
typedef interface IRowsetView IRowsetView;
#endif 	/* __IRowsetView_FWD_DEFINED__ */


#ifndef __IRowsetExactScroll_FWD_DEFINED__
#define __IRowsetExactScroll_FWD_DEFINED__
typedef interface IRowsetExactScroll IRowsetExactScroll;
#endif 	/* __IRowsetExactScroll_FWD_DEFINED__ */


#ifndef __IRowsetChange_FWD_DEFINED__
#define __IRowsetChange_FWD_DEFINED__
typedef interface IRowsetChange IRowsetChange;
#endif 	/* __IRowsetChange_FWD_DEFINED__ */


#ifndef __IRowsetUpdate_FWD_DEFINED__
#define __IRowsetUpdate_FWD_DEFINED__
typedef interface IRowsetUpdate IRowsetUpdate;
#endif 	/* __IRowsetUpdate_FWD_DEFINED__ */


#ifndef __IRowsetIdentity_FWD_DEFINED__
#define __IRowsetIdentity_FWD_DEFINED__
typedef interface IRowsetIdentity IRowsetIdentity;
#endif 	/* __IRowsetIdentity_FWD_DEFINED__ */


#ifndef __IRowsetNotify_FWD_DEFINED__
#define __IRowsetNotify_FWD_DEFINED__
typedef interface IRowsetNotify IRowsetNotify;
#endif 	/* __IRowsetNotify_FWD_DEFINED__ */


#ifndef __IRowsetIndex_FWD_DEFINED__
#define __IRowsetIndex_FWD_DEFINED__
typedef interface IRowsetIndex IRowsetIndex;
#endif 	/* __IRowsetIndex_FWD_DEFINED__ */


#ifndef __ICommand_FWD_DEFINED__
#define __ICommand_FWD_DEFINED__
typedef interface ICommand ICommand;
#endif 	/* __ICommand_FWD_DEFINED__ */


#ifndef __IMultipleResults_FWD_DEFINED__
#define __IMultipleResults_FWD_DEFINED__
typedef interface IMultipleResults IMultipleResults;
#endif 	/* __IMultipleResults_FWD_DEFINED__ */


#ifndef __IConvertType_FWD_DEFINED__
#define __IConvertType_FWD_DEFINED__
typedef interface IConvertType IConvertType;
#endif 	/* __IConvertType_FWD_DEFINED__ */


#ifndef __ICommandPrepare_FWD_DEFINED__
#define __ICommandPrepare_FWD_DEFINED__
typedef interface ICommandPrepare ICommandPrepare;
#endif 	/* __ICommandPrepare_FWD_DEFINED__ */


#ifndef __ICommandProperties_FWD_DEFINED__
#define __ICommandProperties_FWD_DEFINED__
typedef interface ICommandProperties ICommandProperties;
#endif 	/* __ICommandProperties_FWD_DEFINED__ */


#ifndef __ICommandText_FWD_DEFINED__
#define __ICommandText_FWD_DEFINED__
typedef interface ICommandText ICommandText;
#endif 	/* __ICommandText_FWD_DEFINED__ */


#ifndef __ICommandWithParameters_FWD_DEFINED__
#define __ICommandWithParameters_FWD_DEFINED__
typedef interface ICommandWithParameters ICommandWithParameters;
#endif 	/* __ICommandWithParameters_FWD_DEFINED__ */


#ifndef __IColumnsRowset_FWD_DEFINED__
#define __IColumnsRowset_FWD_DEFINED__
typedef interface IColumnsRowset IColumnsRowset;
#endif 	/* __IColumnsRowset_FWD_DEFINED__ */


#ifndef __IColumnsInfo_FWD_DEFINED__
#define __IColumnsInfo_FWD_DEFINED__
typedef interface IColumnsInfo IColumnsInfo;
#endif 	/* __IColumnsInfo_FWD_DEFINED__ */


#ifndef __IDBCreateCommand_FWD_DEFINED__
#define __IDBCreateCommand_FWD_DEFINED__
typedef interface IDBCreateCommand IDBCreateCommand;
#endif 	/* __IDBCreateCommand_FWD_DEFINED__ */


#ifndef __IDBCreateSession_FWD_DEFINED__
#define __IDBCreateSession_FWD_DEFINED__
typedef interface IDBCreateSession IDBCreateSession;
#endif 	/* __IDBCreateSession_FWD_DEFINED__ */


#ifndef __ISourcesRowset_FWD_DEFINED__
#define __ISourcesRowset_FWD_DEFINED__
typedef interface ISourcesRowset ISourcesRowset;
#endif 	/* __ISourcesRowset_FWD_DEFINED__ */


#ifndef __IDBProperties_FWD_DEFINED__
#define __IDBProperties_FWD_DEFINED__
typedef interface IDBProperties IDBProperties;
#endif 	/* __IDBProperties_FWD_DEFINED__ */


#ifndef __IDBInitialize_FWD_DEFINED__
#define __IDBInitialize_FWD_DEFINED__
typedef interface IDBInitialize IDBInitialize;
#endif 	/* __IDBInitialize_FWD_DEFINED__ */


#ifndef __IDBInfo_FWD_DEFINED__
#define __IDBInfo_FWD_DEFINED__
typedef interface IDBInfo IDBInfo;
#endif 	/* __IDBInfo_FWD_DEFINED__ */


#ifndef __IDBDataSourceAdmin_FWD_DEFINED__
#define __IDBDataSourceAdmin_FWD_DEFINED__
typedef interface IDBDataSourceAdmin IDBDataSourceAdmin;
#endif 	/* __IDBDataSourceAdmin_FWD_DEFINED__ */


#ifndef __IDBAsynchNotify_FWD_DEFINED__
#define __IDBAsynchNotify_FWD_DEFINED__
typedef interface IDBAsynchNotify IDBAsynchNotify;
#endif 	/* __IDBAsynchNotify_FWD_DEFINED__ */


#ifndef __IDBAsynchStatus_FWD_DEFINED__
#define __IDBAsynchStatus_FWD_DEFINED__
typedef interface IDBAsynchStatus IDBAsynchStatus;
#endif 	/* __IDBAsynchStatus_FWD_DEFINED__ */


#ifndef __ISessionProperties_FWD_DEFINED__
#define __ISessionProperties_FWD_DEFINED__
typedef interface ISessionProperties ISessionProperties;
#endif 	/* __ISessionProperties_FWD_DEFINED__ */


#ifndef __IIndexDefinition_FWD_DEFINED__
#define __IIndexDefinition_FWD_DEFINED__
typedef interface IIndexDefinition IIndexDefinition;
#endif 	/* __IIndexDefinition_FWD_DEFINED__ */


#ifndef __ITableDefinition_FWD_DEFINED__
#define __ITableDefinition_FWD_DEFINED__
typedef interface ITableDefinition ITableDefinition;
#endif 	/* __ITableDefinition_FWD_DEFINED__ */


#ifndef __IOpenRowset_FWD_DEFINED__
#define __IOpenRowset_FWD_DEFINED__
typedef interface IOpenRowset IOpenRowset;
#endif 	/* __IOpenRowset_FWD_DEFINED__ */


#ifndef __IDBSchemaRowset_FWD_DEFINED__
#define __IDBSchemaRowset_FWD_DEFINED__
typedef interface IDBSchemaRowset IDBSchemaRowset;
#endif 	/* __IDBSchemaRowset_FWD_DEFINED__ */


#ifndef __IMDDataset_FWD_DEFINED__
#define __IMDDataset_FWD_DEFINED__
typedef interface IMDDataset IMDDataset;
#endif 	/* __IMDDataset_FWD_DEFINED__ */


#ifndef __IMDFind_FWD_DEFINED__
#define __IMDFind_FWD_DEFINED__
typedef interface IMDFind IMDFind;
#endif 	/* __IMDFind_FWD_DEFINED__ */


#ifndef __IMDRangeRowset_FWD_DEFINED__
#define __IMDRangeRowset_FWD_DEFINED__
typedef interface IMDRangeRowset IMDRangeRowset;
#endif 	/* __IMDRangeRowset_FWD_DEFINED__ */


#ifndef __IAlterTable_FWD_DEFINED__
#define __IAlterTable_FWD_DEFINED__
typedef interface IAlterTable IAlterTable;
#endif 	/* __IAlterTable_FWD_DEFINED__ */


#ifndef __IAlterIndex_FWD_DEFINED__
#define __IAlterIndex_FWD_DEFINED__
typedef interface IAlterIndex IAlterIndex;
#endif 	/* __IAlterIndex_FWD_DEFINED__ */


#ifndef __IRowsetChapterMember_FWD_DEFINED__
#define __IRowsetChapterMember_FWD_DEFINED__
typedef interface IRowsetChapterMember IRowsetChapterMember;
#endif 	/* __IRowsetChapterMember_FWD_DEFINED__ */


#ifndef __ICommandPersist_FWD_DEFINED__
#define __ICommandPersist_FWD_DEFINED__
typedef interface ICommandPersist ICommandPersist;
#endif 	/* __ICommandPersist_FWD_DEFINED__ */


#ifndef __IRowsetRefresh_FWD_DEFINED__
#define __IRowsetRefresh_FWD_DEFINED__
typedef interface IRowsetRefresh IRowsetRefresh;
#endif 	/* __IRowsetRefresh_FWD_DEFINED__ */


#ifndef __IParentRowset_FWD_DEFINED__
#define __IParentRowset_FWD_DEFINED__
typedef interface IParentRowset IParentRowset;
#endif 	/* __IParentRowset_FWD_DEFINED__ */


#ifndef __IErrorRecords_FWD_DEFINED__
#define __IErrorRecords_FWD_DEFINED__
typedef interface IErrorRecords IErrorRecords;
#endif 	/* __IErrorRecords_FWD_DEFINED__ */


#ifndef __IErrorLookup_FWD_DEFINED__
#define __IErrorLookup_FWD_DEFINED__
typedef interface IErrorLookup IErrorLookup;
#endif 	/* __IErrorLookup_FWD_DEFINED__ */


#ifndef __ISQLErrorInfo_FWD_DEFINED__
#define __ISQLErrorInfo_FWD_DEFINED__
typedef interface ISQLErrorInfo ISQLErrorInfo;
#endif 	/* __ISQLErrorInfo_FWD_DEFINED__ */


#ifndef __IGetDataSource_FWD_DEFINED__
#define __IGetDataSource_FWD_DEFINED__
typedef interface IGetDataSource IGetDataSource;
#endif 	/* __IGetDataSource_FWD_DEFINED__ */


#ifndef __ITransactionLocal_FWD_DEFINED__
#define __ITransactionLocal_FWD_DEFINED__
typedef interface ITransactionLocal ITransactionLocal;
#endif 	/* __ITransactionLocal_FWD_DEFINED__ */


#ifndef __ITransactionJoin_FWD_DEFINED__
#define __ITransactionJoin_FWD_DEFINED__
typedef interface ITransactionJoin ITransactionJoin;
#endif 	/* __ITransactionJoin_FWD_DEFINED__ */


#ifndef __ITransactionObject_FWD_DEFINED__
#define __ITransactionObject_FWD_DEFINED__
typedef interface ITransactionObject ITransactionObject;
#endif 	/* __ITransactionObject_FWD_DEFINED__ */


#ifndef __ITrusteeAdmin_FWD_DEFINED__
#define __ITrusteeAdmin_FWD_DEFINED__
typedef interface ITrusteeAdmin ITrusteeAdmin;
#endif 	/* __ITrusteeAdmin_FWD_DEFINED__ */


#ifndef __ITrusteeGroupAdmin_FWD_DEFINED__
#define __ITrusteeGroupAdmin_FWD_DEFINED__
typedef interface ITrusteeGroupAdmin ITrusteeGroupAdmin;
#endif 	/* __ITrusteeGroupAdmin_FWD_DEFINED__ */


#ifndef __IObjectAccessControl_FWD_DEFINED__
#define __IObjectAccessControl_FWD_DEFINED__
typedef interface IObjectAccessControl IObjectAccessControl;
#endif 	/* __IObjectAccessControl_FWD_DEFINED__ */


#ifndef __ISecurityInfo_FWD_DEFINED__
#define __ISecurityInfo_FWD_DEFINED__
typedef interface ISecurityInfo ISecurityInfo;
#endif 	/* __ISecurityInfo_FWD_DEFINED__ */


#ifndef __ITableCreation_FWD_DEFINED__
#define __ITableCreation_FWD_DEFINED__
typedef interface ITableCreation ITableCreation;
#endif 	/* __ITableCreation_FWD_DEFINED__ */


#ifndef __ITableDefinitionWithConstraints_FWD_DEFINED__
#define __ITableDefinitionWithConstraints_FWD_DEFINED__
typedef interface ITableDefinitionWithConstraints ITableDefinitionWithConstraints;
#endif 	/* __ITableDefinitionWithConstraints_FWD_DEFINED__ */


#ifndef __IRow_FWD_DEFINED__
#define __IRow_FWD_DEFINED__
typedef interface IRow IRow;
#endif 	/* __IRow_FWD_DEFINED__ */


#ifndef __IRowChange_FWD_DEFINED__
#define __IRowChange_FWD_DEFINED__
typedef interface IRowChange IRowChange;
#endif 	/* __IRowChange_FWD_DEFINED__ */


#ifndef __IRowSchemaChange_FWD_DEFINED__
#define __IRowSchemaChange_FWD_DEFINED__
typedef interface IRowSchemaChange IRowSchemaChange;
#endif 	/* __IRowSchemaChange_FWD_DEFINED__ */


#ifndef __IGetRow_FWD_DEFINED__
#define __IGetRow_FWD_DEFINED__
typedef interface IGetRow IGetRow;
#endif 	/* __IGetRow_FWD_DEFINED__ */


#ifndef __IBindResource_FWD_DEFINED__
#define __IBindResource_FWD_DEFINED__
typedef interface IBindResource IBindResource;
#endif 	/* __IBindResource_FWD_DEFINED__ */


#ifndef __IScopedOperations_FWD_DEFINED__
#define __IScopedOperations_FWD_DEFINED__
typedef interface IScopedOperations IScopedOperations;
#endif 	/* __IScopedOperations_FWD_DEFINED__ */


#ifndef __ICreateRow_FWD_DEFINED__
#define __ICreateRow_FWD_DEFINED__
typedef interface ICreateRow ICreateRow;
#endif 	/* __ICreateRow_FWD_DEFINED__ */


#ifndef __IDBBinderProperties_FWD_DEFINED__
#define __IDBBinderProperties_FWD_DEFINED__
typedef interface IDBBinderProperties IDBBinderProperties;
#endif 	/* __IDBBinderProperties_FWD_DEFINED__ */


#ifndef __IColumnsInfo2_FWD_DEFINED__
#define __IColumnsInfo2_FWD_DEFINED__
typedef interface IColumnsInfo2 IColumnsInfo2;
#endif 	/* __IColumnsInfo2_FWD_DEFINED__ */


#ifndef __IRegisterProvider_FWD_DEFINED__
#define __IRegisterProvider_FWD_DEFINED__
typedef interface IRegisterProvider IRegisterProvider;
#endif 	/* __IRegisterProvider_FWD_DEFINED__ */


#ifndef __IGetSession_FWD_DEFINED__
#define __IGetSession_FWD_DEFINED__
typedef interface IGetSession IGetSession;
#endif 	/* __IGetSession_FWD_DEFINED__ */


#ifndef __IGetSourceRow_FWD_DEFINED__
#define __IGetSourceRow_FWD_DEFINED__
typedef interface IGetSourceRow IGetSourceRow;
#endif 	/* __IGetSourceRow_FWD_DEFINED__ */


#ifndef __IRowsetCurrentIndex_FWD_DEFINED__
#define __IRowsetCurrentIndex_FWD_DEFINED__
typedef interface IRowsetCurrentIndex IRowsetCurrentIndex;
#endif 	/* __IRowsetCurrentIndex_FWD_DEFINED__ */


/* header files for imported files */
#include "wtypes.h"
#include "oaidl.h"
#include "ocidl.h"
#ifndef UNDER_CE
#include "urlmon.h"
#endif
#include "transact.h"

void __RPC_FAR * __RPC_USER MIDL_user_allocate(size_t);
void __RPC_USER MIDL_user_free( void __RPC_FAR * ); 

/****************************************
 * Generated header for interface: __MIDL_itf_oledb_0000
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [local] */ 


//+---------------------------------------------------------------------------
//
//  Microsoft OLE DB
//  Copyright (C) Microsoft Corporation, 1994 - 1998.
//
//----------------------------------------------------------------------------

#include <pshpack2.h>	// 2-byte structure packing

extern RPC_IF_HANDLE __MIDL_itf_oledb_0000_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_oledb_0000_v0_0_s_ifspec;

#ifndef __DBStructureDefinitions_INTERFACE_DEFINED__
#define __DBStructureDefinitions_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: DBStructureDefinitions
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [auto_handle][unique][uuid] */ 


#ifndef UNALIGNED
#if defined(_MIPS_) || defined(_ALPHA_) || defined(_PPC_)
#define UNALIGNED __unaligned
#else
#define UNALIGNED
#endif
#endif //UNALIGNED
#undef OLEDBDECLSPEC
#if _MSC_VER >= 1100 && (!defined(SHx) || (defined(SHx) && _MSC_VER >= 1200))
#define OLEDBDECLSPEC __declspec(selectany)
#else
#define OLEDBDECLSPEC 
#endif //_MSC_VER
typedef DWORD DBKIND;


enum DBKINDENUM
    {	DBKIND_GUID_NAME	= 0,
	DBKIND_GUID_PROPID	= DBKIND_GUID_NAME + 1,
	DBKIND_NAME	= DBKIND_GUID_PROPID + 1,
	DBKIND_PGUID_NAME	= DBKIND_NAME + 1,
	DBKIND_PGUID_PROPID	= DBKIND_PGUID_NAME + 1,
	DBKIND_PROPID	= DBKIND_PGUID_PROPID + 1,
	DBKIND_GUID	= DBKIND_PROPID + 1
    };

#if defined(MIPSII_FP) || defined(MIPSIV) || defined(MIPSIV_FP)
#pragma pack(push,8)
#endif

typedef struct  tagDBID
    {
    /* [switch_is][switch_type] */ union 
        {
        /* [case()] */ GUID guid;
        /* [case()] */ GUID __RPC_FAR *pguid;
        /* [default] */  /* Empty union arm */ 
        }	uGuid;
    DBKIND eKind;
    /* [switch_is][switch_type] */ union 
        {
        /* [case()] */ LPOLESTR pwszName;
        /* [case()] */ ULONG ulPropid;
        /* [default] */  /* Empty union arm */ 
        }	uName;
    }	DBID;

#if defined(MIPSII_FP) || defined(MIPSIV) || defined(MIPSIV_FP)
#pragma pack(pop)
#endif

typedef struct  tagDB_NUMERIC
    {
    BYTE precision;
    BYTE scale;
    BYTE sign;
    BYTE val[ 16 ];
    }	DB_NUMERIC;

#ifndef _ULONGLONG_
typedef hyper LONGLONG;

typedef MIDL_uhyper ULONGLONG;

typedef LONGLONG __RPC_FAR *PLONGLONG;

typedef ULONGLONG __RPC_FAR *PULONGLONG;

#endif // _ULONGLONG_
#ifndef DECIMAL_NEG
#ifndef DECIMAL_SETZERO
typedef struct tagDEC {
    USHORT wReserved;
    union {
        struct {
            BYTE scale;
            BYTE sign;
        };
        USHORT signscale;
    };
    ULONG Hi32;
    union {
        struct {
#ifdef _MAC
            ULONG Mid32;
            ULONG Lo32;
#else
            ULONG Lo32;
            ULONG Mid32;
#endif
        };
        ULONGLONG Lo64;
    };
} DECIMAL;
#define DECIMAL_NEG ((BYTE)0x80)
#define DECIMAL_SETZERO(dec) {(dec).Lo64 = 0; (dec).Hi32 = 0; (dec).signscale = 0;}
#endif // DECIMAL_SETZERO
#endif // DECIMAL_NEG
typedef struct  tagDBVECTOR
    {
    ULONG size;
    /* [size_is] */ void __RPC_FAR *ptr;
    }	DBVECTOR;

typedef struct  tagDBDATE
    {
    SHORT year;
    USHORT month;
    USHORT day;
    }	DBDATE;

typedef struct  tagDBTIME
    {
    USHORT hour;
    USHORT minute;
    USHORT second;
    }	DBTIME;

typedef struct  tagDBTIMESTAMP
    {
    SHORT year;
    USHORT month;
    USHORT day;
    USHORT hour;
    USHORT minute;
    USHORT second;
    ULONG fraction;
    }	DBTIMESTAMP;

#if !defined(_WINBASE_) && !defined(_FILETIME_)
#define _FILETIME_
typedef struct _FILETIME {
		DWORD dwLowDateTime;
		DWORD dwHighDateTime;
     }	FILETIME;
#endif // !_FILETIME
typedef signed char SBYTE;

typedef struct  tagDB_VARNUMERIC
    {
    BYTE precision;
    SBYTE scale;
    BYTE sign;
    BYTE val[ 1 ];
    }	DB_VARNUMERIC;

typedef struct  _SEC_OBJECT_ELEMENT
    {
    GUID guidObjectType;
    DBID ObjectID;
    }	SEC_OBJECT_ELEMENT;

typedef struct  _SEC_OBJECT
    {
    DWORD cObjects;
    /* [size_is] */ SEC_OBJECT_ELEMENT __RPC_FAR *prgObjects;
    }	SEC_OBJECT;

typedef struct  tagDBIMPLICITSESSION
    {
    IUnknown __RPC_FAR *pUnkOuter;
    IID __RPC_FAR *piid;
    IUnknown __RPC_FAR *pSession;
    }	DBIMPLICITSESSION;

typedef WORD DBTYPE;


enum DBTYPEENUM
    {	DBTYPE_EMPTY	= 0,
	DBTYPE_NULL	= 1,
	DBTYPE_I2	= 2,
	DBTYPE_I4	= 3,
	DBTYPE_R4	= 4,
	DBTYPE_R8	= 5,
	DBTYPE_CY	= 6,
	DBTYPE_DATE	= 7,
	DBTYPE_BSTR	= 8,
	DBTYPE_IDISPATCH	= 9,
	DBTYPE_ERROR	= 10,
	DBTYPE_BOOL	= 11,
	DBTYPE_VARIANT	= 12,
	DBTYPE_IUNKNOWN	= 13,
	DBTYPE_DECIMAL	= 14,
	DBTYPE_UI1	= 17,
	DBTYPE_ARRAY	= 0x2000,
	DBTYPE_BYREF	= 0x4000,
	DBTYPE_I1	= 16,
	DBTYPE_UI2	= 18,
	DBTYPE_UI4	= 19,
	DBTYPE_I8	= 20,
	DBTYPE_UI8	= 21,
	DBTYPE_GUID	= 72,
	DBTYPE_VECTOR	= 0x1000,
	DBTYPE_RESERVED	= 0x8000,
	DBTYPE_BYTES	= 128,
	DBTYPE_STR	= 129,
	DBTYPE_WSTR	= 130,
	DBTYPE_NUMERIC	= 131,
	DBTYPE_UDT	= 132,
	DBTYPE_DBDATE	= 133,
	DBTYPE_DBTIME	= 134,
	DBTYPE_DBTIMESTAMP	= 135
    };

enum DBTYPEENUM15
    {	DBTYPE_HCHAPTER	= 136
    };

enum DBTYPEENUM20
    {	DBTYPE_FILETIME	= 64,
	DBTYPE_PROPVARIANT	= 138,
	DBTYPE_VARNUMERIC	= 139
    };

typedef DWORD DBPART;


enum DBPARTENUM
    {	DBPART_INVALID	= 0,
	DBPART_VALUE	= 0x1,
	DBPART_LENGTH	= 0x2,
	DBPART_STATUS	= 0x4
    };
typedef DWORD DBPARAMIO;


enum DBPARAMIOENUM
    {	DBPARAMIO_NOTPARAM	= 0,
	DBPARAMIO_INPUT	= 0x1,
	DBPARAMIO_OUTPUT	= 0x2
    };

typedef DWORD DBBINDFLAG;

enum DBBINDFLAGENUM
    {	DBBINDFLAG_HTML	= 0x1
    };

typedef DWORD DBMEMOWNER;


enum DBMEMOWNERENUM
    {	DBMEMOWNER_CLIENTOWNED	= 0,
	DBMEMOWNER_PROVIDEROWNED	= 0x1
    };

typedef struct  tagDBOBJECT
    {
    DWORD dwFlags;
    IID iid;
    }	DBOBJECT;

typedef DWORD DBSTATUS;

enum DBSTATUSENUM
    {	DBSTATUS_S_OK	= 0,
	DBSTATUS_E_BADACCESSOR	= 1,
	DBSTATUS_E_CANTCONVERTVALUE	= 2,
	DBSTATUS_S_ISNULL	= 3,
	DBSTATUS_S_TRUNCATED	= 4,
	DBSTATUS_E_SIGNMISMATCH	= 5,
	DBSTATUS_E_DATAOVERFLOW	= 6,
	DBSTATUS_E_CANTCREATE	= 7,
	DBSTATUS_E_UNAVAILABLE	= 8,
	DBSTATUS_E_PERMISSIONDENIED	= 9,
	DBSTATUS_E_INTEGRITYVIOLATION	= 10,
	DBSTATUS_E_SCHEMAVIOLATION	= 11,
	DBSTATUS_E_BADSTATUS	= 12,
	DBSTATUS_S_DEFAULT	= 13
    };

enum DBSTATUSENUM20
    {	MDSTATUS_S_CELLEMPTY	= 14,
	DBSTATUS_S_IGNORE	= 15
    };

enum DBSTATUSENUM21
    {	DBSTATUS_E_DOESNOTEXIST	= 16,
	DBSTATUS_E_INVALIDURL	= 17,
	DBSTATUS_E_RESOURCELOCKED	= 18,
	DBSTATUS_E_RESOURCEEXISTS	= 19,
	DBSTATUS_E_CANNOTCOMPLETE	= 20,
	DBSTATUS_E_VOLUMENOTFOUND	= 21,
	DBSTATUS_E_OUTOFSPACE	= 22,
	DBSTATUS_S_CANNOTDELETESOURCE	= 23,
	DBSTATUS_E_READONLY	= 24,
	DBSTATUS_E_RESOURCEOUTOFSCOPE	= 25,
	DBSTATUS_S_ALREADYEXISTS	= 26
    };
typedef DWORD DBBINDURLFLAG;


enum DBBINDURLFLAGENUM
    {	DBBINDURLFLAG_READ	= 0x1L,
	DBBINDURLFLAG_WRITE	= 0x2L,
	DBBINDURLFLAG_READWRITE	= 0x3L,
	DBBINDURLFLAG_SHARE_DENY_READ	= 0x4L,
	DBBINDURLFLAG_SHARE_DENY_WRITE	= 0x8L,
	DBBINDURLFLAG_SHARE_EXCLUSIVE	= 0xcL,
	DBBINDURLFLAG_SHARE_DENY_NONE	= 0x10L,
	DBBINDURLFLAG_ASYNCHRONOUS	= 0x1000L,
	DBBINDURLFLAG_COLLECTION	= 0x2000L,
	DBBINDURLFLAG_DELAYFETCHSTREAM	= 0x4000L,
	DBBINDURLFLAG_DELAYFETCHCOLUMNS	= 0x8000L,
	DBBINDURLFLAG_RECURSIVE	= 0x400000L,
	DBBINDURLFLAG_OUTPUT	= 0x800000L,
	DBBINDURLFLAG_WAITFORINIT	= 0x1000000L,
	DBBINDURLFLAG_OPENIFEXISTS	= 0x2000000L,
	DBBINDURLFLAG_OVERWRITE	= 0x4000000L,
	DBBINDURLFLAG_ISSTRUCTUREDDOCUMENT	= 0x8000000L
    };
typedef DWORD DBBINDURLSTATUS;


enum DBBINDURLSTATUSENUM
    {	DBBINDURLSTATUS_S_DENYNOTSUPPORTED	= 0x1L,
	DBBINDURLSTATUS_S_DENYTYPENOTSUPPORTED	= 0x4L,
	DBBINDURLSTATUS_S_REDIRECTED	= 0x8L
    };

typedef struct  tagDBBINDEXT
    {
    /* [size_is] */ BYTE __RPC_FAR *pExtension;
    ULONG ulExtension;
    }	DBBINDEXT;

typedef struct  tagDBBINDING
    {
    ULONG iOrdinal;
    ULONG obValue;
    ULONG obLength;
    ULONG obStatus;
    ITypeInfo __RPC_FAR *pTypeInfo;
    DBOBJECT __RPC_FAR *pObject;
    DBBINDEXT __RPC_FAR *pBindExt;
    DBPART dwPart;
    DBMEMOWNER dwMemOwner;
    DBPARAMIO eParamIO;
    ULONG cbMaxLen;
    DWORD dwFlags;
    DBTYPE wType;
    BYTE bPrecision;
    BYTE bScale;
    }	DBBINDING;

typedef DWORD DBROWSTATUS;


enum DBROWSTATUSENUM
    {	DBROWSTATUS_S_OK	= 0,
	DBROWSTATUS_S_MULTIPLECHANGES	= 2,
	DBROWSTATUS_S_PENDINGCHANGES	= 3,
	DBROWSTATUS_E_CANCELED	= 4,
	DBROWSTATUS_E_CANTRELEASE	= 6,
	DBROWSTATUS_E_CONCURRENCYVIOLATION	= 7,
	DBROWSTATUS_E_DELETED	= 8,
	DBROWSTATUS_E_PENDINGINSERT	= 9,
	DBROWSTATUS_E_NEWLYINSERTED	= 10,
	DBROWSTATUS_E_INTEGRITYVIOLATION	= 11,
	DBROWSTATUS_E_INVALID	= 12,
	DBROWSTATUS_E_MAXPENDCHANGESEXCEEDED	= 13,
	DBROWSTATUS_E_OBJECTOPEN	= 14,
	DBROWSTATUS_E_OUTOFMEMORY	= 15,
	DBROWSTATUS_E_PERMISSIONDENIED	= 16,
	DBROWSTATUS_E_LIMITREACHED	= 17,
	DBROWSTATUS_E_SCHEMAVIOLATION	= 18,
	DBROWSTATUS_E_FAIL	= 19
    };

enum DBROWSTATUSENUM20
    {	DBROWSTATUS_S_NOCHANGE	= 20
    };

typedef ULONG HACCESSOR;

#define DB_NULL_HACCESSOR 0x00 // deprecated; use DB_INVALID_HACCESSOR instead
#define DB_INVALID_HACCESSOR 0x00
typedef ULONG HROW;

#define DB_NULL_HROW 0x00
typedef ULONG HWATCHREGION;

#define DBWATCHREGION_NULL NULL
typedef ULONG HCHAPTER;

#define DB_NULL_HCHAPTER 0x00
#define DB_INVALID_HCHAPTER 0x00	// deprecated; use DB_NULL_HCHAPTER instead
typedef struct  tagDBFAILUREINFO
    {
    HROW hRow;
    ULONG iColumn;
    HRESULT failure;
    }	DBFAILUREINFO;

typedef DWORD DBCOLUMNFLAGS;


enum DBCOLUMNFLAGSENUM
    {	DBCOLUMNFLAGS_ISBOOKMARK	= 0x1,
	DBCOLUMNFLAGS_MAYDEFER	= 0x2,
	DBCOLUMNFLAGS_WRITE	= 0x4,
	DBCOLUMNFLAGS_WRITEUNKNOWN	= 0x8,
	DBCOLUMNFLAGS_ISFIXEDLENGTH	= 0x10,
	DBCOLUMNFLAGS_ISNULLABLE	= 0x20,
	DBCOLUMNFLAGS_MAYBENULL	= 0x40,
	DBCOLUMNFLAGS_ISLONG	= 0x80,
	DBCOLUMNFLAGS_ISROWID	= 0x100,
	DBCOLUMNFLAGS_ISROWVER	= 0x200,
	DBCOLUMNFLAGS_CACHEDEFERRED	= 0x1000
    };

enum DBCOLUMNFLAGSENUM20
    {	DBCOLUMNFLAGS_SCALEISNEGATIVE	= 0x4000,
	DBCOLUMNFLAGS_KEYCOLUMN	= 0x8000
    };

enum DBCOLUMNFLAGS15ENUM
    {	DBCOLUMNFLAGS_ISCHAPTER	= 0x2000
    };

enum DBCOLUMNFLAGSENUM21
    {	DBCOLUMNFLAGS_ISROWURL	= 0x10000,
	DBCOLUMNFLAGS_ISDEFAULTSTREAM	= 0x20000,
	DBCOLUMNFLAGS_ISCOLLECTION	= 0x40000
    };

typedef struct  tagDBCOLUMNINFO
    {
    LPOLESTR pwszName;
    ITypeInfo __RPC_FAR *pTypeInfo;
    ULONG iOrdinal;
    DBCOLUMNFLAGS dwFlags;
    ULONG ulColumnSize;
    DBTYPE wType;
    BYTE bPrecision;
    BYTE bScale;
    DBID columnid;
    }	DBCOLUMNINFO;

typedef 
enum tagDBBOOKMARK
    {	DBBMK_INVALID	= 0,
	DBBMK_FIRST	= DBBMK_INVALID + 1,
	DBBMK_LAST	= DBBMK_FIRST + 1
    }	DBBOOKMARK;

#define STD_BOOKMARKLENGTH 1
#ifdef __cplusplus
inline BOOL IsEqualGUIDBase(const GUID &rguid1, const GUID &rguid2)
{ return !memcmp(&(rguid1.Data2), &(rguid2.Data2), sizeof(GUID) - sizeof(rguid1.Data1)); }
#else // !__cplusplus
#define IsEqualGuidBase(rguid1, rguid2) (!memcmp(&((rguid1).Data2), &((rguid2).Data2), sizeof(GUID) - sizeof((rguid1).Data1)))
#endif // __cplusplus
#define DB_INVALIDCOLUMN ULONG_MAX
#define DBCIDGUID   {0x0C733A81L,0x2A1C,0x11CE,{0xAD,0xE5,0x00,0xAA,0x00,0x44,0x77,0x3D}}
#define DB_NULLGUID {0x00000000L,0x0000,0x0000,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}

extern const OLEDBDECLSPEC DBID DB_NULLID                      = {DB_NULLGUID, 0, (LPOLESTR)0};
extern const OLEDBDECLSPEC DBID DBCOLUMN_IDNAME                = {DBCIDGUID, DBKIND_GUID_PROPID, (LPOLESTR)2};
extern const OLEDBDECLSPEC DBID DBCOLUMN_NAME                  = {DBCIDGUID, DBKIND_GUID_PROPID, (LPOLESTR)3};
extern const OLEDBDECLSPEC DBID DBCOLUMN_NUMBER                = {DBCIDGUID, DBKIND_GUID_PROPID, (LPOLESTR)4};
extern const OLEDBDECLSPEC DBID DBCOLUMN_TYPE                  = {DBCIDGUID, DBKIND_GUID_PROPID, (LPOLESTR)5};
extern const OLEDBDECLSPEC DBID DBCOLUMN_PRECISION             = {DBCIDGUID, DBKIND_GUID_PROPID, (LPOLESTR)7};
extern const OLEDBDECLSPEC DBID DBCOLUMN_SCALE                 = {DBCIDGUID, DBKIND_GUID_PROPID, (LPOLESTR)8};
extern const OLEDBDECLSPEC DBID DBCOLUMN_FLAGS                 = {DBCIDGUID, DBKIND_GUID_PROPID, (LPOLESTR)9};
extern const OLEDBDECLSPEC DBID DBCOLUMN_BASECOLUMNNAME        = {DBCIDGUID, DBKIND_GUID_PROPID, (LPOLESTR)10};
extern const OLEDBDECLSPEC DBID DBCOLUMN_BASETABLENAME         = {DBCIDGUID, DBKIND_GUID_PROPID, (LPOLESTR)11};
extern const OLEDBDECLSPEC DBID DBCOLUMN_COLLATINGSEQUENCE     = {DBCIDGUID, DBKIND_GUID_PROPID, (LPOLESTR)12};
extern const OLEDBDECLSPEC DBID DBCOLUMN_COMPUTEMODE           = {DBCIDGUID, DBKIND_GUID_PROPID, (LPOLESTR)13};
extern const OLEDBDECLSPEC DBID DBCOLUMN_DEFAULTVALUE          = {DBCIDGUID, DBKIND_GUID_PROPID, (LPOLESTR)14};
extern const OLEDBDECLSPEC DBID DBCOLUMN_DOMAINNAME            = {DBCIDGUID, DBKIND_GUID_PROPID, (LPOLESTR)15};
extern const OLEDBDECLSPEC DBID DBCOLUMN_HASDEFAULT            = {DBCIDGUID, DBKIND_GUID_PROPID, (LPOLESTR)16};
extern const OLEDBDECLSPEC DBID DBCOLUMN_ISAUTOINCREMENT       = {DBCIDGUID, DBKIND_GUID_PROPID, (LPOLESTR)17};
extern const OLEDBDECLSPEC DBID DBCOLUMN_ISCASESENSITIVE       = {DBCIDGUID, DBKIND_GUID_PROPID, (LPOLESTR)18};
extern const OLEDBDECLSPEC DBID DBCOLUMN_ISSEARCHABLE          = {DBCIDGUID, DBKIND_GUID_PROPID, (LPOLESTR)20};
extern const OLEDBDECLSPEC DBID DBCOLUMN_ISUNIQUE              = {DBCIDGUID, DBKIND_GUID_PROPID, (LPOLESTR)21};
extern const OLEDBDECLSPEC DBID DBCOLUMN_BASECATALOGNAME       = {DBCIDGUID, DBKIND_GUID_PROPID, (LPOLESTR)23};
extern const OLEDBDECLSPEC DBID DBCOLUMN_BASESCHEMANAME        = {DBCIDGUID, DBKIND_GUID_PROPID, (LPOLESTR)24};
extern const OLEDBDECLSPEC DBID DBCOLUMN_GUID                  = {DBCIDGUID, DBKIND_GUID_PROPID, (LPOLESTR)29};
extern const OLEDBDECLSPEC DBID DBCOLUMN_PROPID                = {DBCIDGUID, DBKIND_GUID_PROPID, (LPOLESTR)30};
extern const OLEDBDECLSPEC DBID DBCOLUMN_TYPEINFO              = {DBCIDGUID, DBKIND_GUID_PROPID, (LPOLESTR)31};
extern const OLEDBDECLSPEC DBID DBCOLUMN_DOMAINCATALOG         = {DBCIDGUID, DBKIND_GUID_PROPID, (LPOLESTR)32};
extern const OLEDBDECLSPEC DBID DBCOLUMN_DOMAINSCHEMA          = {DBCIDGUID, DBKIND_GUID_PROPID, (LPOLESTR)33};
extern const OLEDBDECLSPEC DBID DBCOLUMN_DATETIMEPRECISION     = {DBCIDGUID, DBKIND_GUID_PROPID, (LPOLESTR)34};
extern const OLEDBDECLSPEC DBID DBCOLUMN_NUMERICPRECISIONRADIX = {DBCIDGUID, DBKIND_GUID_PROPID, (LPOLESTR)35};
extern const OLEDBDECLSPEC DBID DBCOLUMN_OCTETLENGTH           = {DBCIDGUID, DBKIND_GUID_PROPID, (LPOLESTR)36};
extern const OLEDBDECLSPEC DBID DBCOLUMN_COLUMNSIZE            = {DBCIDGUID, DBKIND_GUID_PROPID, (LPOLESTR)37};
extern const OLEDBDECLSPEC DBID DBCOLUMN_CLSID                 = {DBCIDGUID, DBKIND_GUID_PROPID, (LPOLESTR)38};

extern const OLEDBDECLSPEC DBID DBCOLUMN_MAYSORT               = {DBCIDGUID, DBKIND_GUID_PROPID, (LPOLESTR)39};

extern const OLEDBDECLSPEC GUID DBSCHEMA_TABLES_INFO                   = {0xc8b522e0,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID MDGUID_MDX                             = {0xa07cccd0,0x8148,0x11d0,{0x87,0xbb,0x00,0xc0,0x4f,0xc3,0x39,0x42}};
extern const OLEDBDECLSPEC GUID DBGUID_MDX                             = {0xa07cccd0,0x8148,0x11d0,{0x87,0xbb,0x00,0xc0,0x4f,0xc3,0x39,0x42}};
extern const OLEDBDECLSPEC GUID MDSCHEMA_CUBES                         = {0xc8b522d8,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID MDSCHEMA_DIMENSIONS                    = {0xc8b522d9,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID MDSCHEMA_HIERARCHIES                   = {0xc8b522da,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID MDSCHEMA_LEVELS                        = {0xc8b522db,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID MDSCHEMA_MEASURES                      = {0xc8b522dc,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID MDSCHEMA_PROPERTIES                    = {0xc8b522dd,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID MDSCHEMA_MEMBERS                       = {0xc8b522de,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC DBID DBCOLUMN_BASETABLEVERSION				= {DBCIDGUID, DBKIND_GUID_PROPID, (LPOLESTR)40};
extern const OLEDBDECLSPEC DBID DBCOLUMN_KEYCOLUMN						= {DBCIDGUID, DBKIND_GUID_PROPID, (LPOLESTR)41};

#define DBGUID_ROWURL   {0x0C733AB6L,0x2A1C,0x11CE,{0xAD,0xE5,0x00,0xAA,0x00,0x44,0x77,0x3D}}
#define DBGUID_ROWDEFAULTSTREAM   {0x0C733AB7L,0x2A1C,0x11CE,{0xAD,0xE5,0x00,0xAA,0x00,0x44,0x77,0x3D}}
extern const OLEDBDECLSPEC GUID DBPROPSET_TRUSTEE					= {0xc8b522e1,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBOBJECT_TABLE 						= {0xc8b522e2,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBOBJECT_COLUMN 						= {0xc8b522e4,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBOBJECT_DATABASE					= {0xc8b522e5,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBOBJECT_PROCEDURE 					= {0xc8b522e6,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBOBJECT_VIEW	 					= {0xc8b522e7,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBOBJECT_SCHEMA						= {0xc8b522e8,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBOBJECT_DOMAIN	 					= {0xc8b522e9,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBOBJECT_COLLATION 					= {0xc8b522ea,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBOBJECT_TRUSTEE	 					= {0xc8b522eb,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBOBJECT_SCHEMAROWSET				= {0xc8b522ec,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBOBJECT_CHARACTERSET	 			= {0xc8b522ed,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBOBJECT_TRANSLATION 				= {0xc8b522ee,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBSCHEMA_TRUSTEE 					= {0xc8b522ef,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBPROPSET_COLUMNALL 					= {0xc8b522f0,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBPROPSET_INDEXALL 					= {0xc8b522f1,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBPROPSET_TABLEALL 					= {0xc8b522f2,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBPROPSET_TRUSTEEALL					= {0xc8b522f3,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBPROPSET_CONSTRAINTALL				= {0xc8b522fa,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBGUID_DSO							= {0xc8b522f4,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBGUID_SESSION						= {0xc8b522f5,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBGUID_ROWSET						= {0xc8b522f6,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBGUID_ROW							= {0xc8b522f7,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBGUID_COMMAND						= {0xc8b522f8,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBGUID_STREAM						= {0xc8b522f9,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC DBID DBROWCOL_ROWURL		         = {DBGUID_ROWURL, DBKIND_GUID_PROPID, (LPOLESTR)0};
extern const OLEDBDECLSPEC DBID DBROWCOL_PARSENAME            = {DBGUID_ROWURL, DBKIND_GUID_PROPID, (LPOLESTR)2};
extern const OLEDBDECLSPEC DBID DBROWCOL_PARENTNAME           = {DBGUID_ROWURL, DBKIND_GUID_PROPID, (LPOLESTR)3};
extern const OLEDBDECLSPEC DBID DBROWCOL_ABSOLUTEPARSENAME    = {DBGUID_ROWURL, DBKIND_GUID_PROPID, (LPOLESTR)4};
extern const OLEDBDECLSPEC DBID DBROWCOL_ISHIDDEN             = {DBGUID_ROWURL, DBKIND_GUID_PROPID, (LPOLESTR)5};
extern const OLEDBDECLSPEC DBID DBROWCOL_ISREADONLY           = {DBGUID_ROWURL, DBKIND_GUID_PROPID, (LPOLESTR)6};
extern const OLEDBDECLSPEC DBID DBROWCOL_CONTENTTYPE          = {DBGUID_ROWURL, DBKIND_GUID_PROPID, (LPOLESTR)7};
extern const OLEDBDECLSPEC DBID DBROWCOL_CONTENTCLASS         = {DBGUID_ROWURL, DBKIND_GUID_PROPID, (LPOLESTR)8};
extern const OLEDBDECLSPEC DBID DBROWCOL_CONTENTLANGUAGE      = {DBGUID_ROWURL, DBKIND_GUID_PROPID, (LPOLESTR)9};
extern const OLEDBDECLSPEC DBID DBROWCOL_CREATIONTIME         = {DBGUID_ROWURL, DBKIND_GUID_PROPID, (LPOLESTR)10};
extern const OLEDBDECLSPEC DBID DBROWCOL_LASTACCESSTIME       = {DBGUID_ROWURL, DBKIND_GUID_PROPID, (LPOLESTR)11};
extern const OLEDBDECLSPEC DBID DBROWCOL_LASTWRITETIME        = {DBGUID_ROWURL, DBKIND_GUID_PROPID, (LPOLESTR)12};
extern const OLEDBDECLSPEC DBID DBROWCOL_STREAMSIZE           = {DBGUID_ROWURL, DBKIND_GUID_PROPID, (LPOLESTR)13};
extern const OLEDBDECLSPEC DBID DBROWCOL_ISCOLLECTION         = {DBGUID_ROWURL, DBKIND_GUID_PROPID, (LPOLESTR)14};
extern const OLEDBDECLSPEC DBID DBROWCOL_ISSTRUCTUREDDOCUMENT = {DBGUID_ROWURL, DBKIND_GUID_PROPID, (LPOLESTR)15};
extern const OLEDBDECLSPEC DBID DBROWCOL_DEFAULTDOCUMENT      = {DBGUID_ROWURL, DBKIND_GUID_PROPID, (LPOLESTR)16};
extern const OLEDBDECLSPEC DBID DBROWCOL_DISPLAYNAME          = {DBGUID_ROWURL, DBKIND_GUID_PROPID, (LPOLESTR)17};
extern const OLEDBDECLSPEC DBID DBROWCOL_ISROOT               = {DBGUID_ROWURL, DBKIND_GUID_PROPID, (LPOLESTR)18};
extern const OLEDBDECLSPEC DBID DBROWCOL_DEFAULTSTREAM        = {DBGUID_ROWDEFAULTSTREAM, DBKIND_GUID_PROPID, (LPOLESTR)0};
extern const OLEDBDECLSPEC GUID DBGUID_CONTAINEROBJECT        = {0xc8b522fb,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};

extern const OLEDBDECLSPEC GUID DBSCHEMA_ASSERTIONS                    = {0xc8b52210,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBSCHEMA_CATALOGS                      = {0xc8b52211,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBSCHEMA_CHARACTER_SETS                = {0xc8b52212,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBSCHEMA_COLLATIONS                    = {0xc8b52213,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBSCHEMA_COLUMNS                       = {0xc8b52214,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBSCHEMA_CHECK_CONSTRAINTS             = {0xc8b52215,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBSCHEMA_CONSTRAINT_COLUMN_USAGE       = {0xc8b52216,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBSCHEMA_CONSTRAINT_TABLE_USAGE        = {0xc8b52217,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBSCHEMA_KEY_COLUMN_USAGE              = {0xc8b52218,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBSCHEMA_REFERENTIAL_CONSTRAINTS       = {0xc8b52219,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBSCHEMA_TABLE_CONSTRAINTS             = {0xc8b5221a,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBSCHEMA_COLUMN_DOMAIN_USAGE           = {0xc8b5221b,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBSCHEMA_INDEXES                       = {0xc8b5221e,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBSCHEMA_COLUMN_PRIVILEGES             = {0xc8b52221,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBSCHEMA_TABLE_PRIVILEGES              = {0xc8b52222,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBSCHEMA_USAGE_PRIVILEGES              = {0xc8b52223,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBSCHEMA_PROCEDURES                    = {0xc8b52224,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBSCHEMA_SCHEMATA                      = {0xc8b52225,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBSCHEMA_SQL_LANGUAGES                 = {0xc8b52226,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBSCHEMA_STATISTICS                    = {0xc8b52227,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBSCHEMA_TABLES                        = {0xc8b52229,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBSCHEMA_TRANSLATIONS                  = {0xc8b5222a,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBSCHEMA_PROVIDER_TYPES                = {0xc8b5222c,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBSCHEMA_VIEWS                         = {0xc8b5222d,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBSCHEMA_VIEW_COLUMN_USAGE             = {0xc8b5222e,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBSCHEMA_VIEW_TABLE_USAGE              = {0xc8b5222f,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBSCHEMA_PROCEDURE_PARAMETERS          = {0xc8b522b8,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBSCHEMA_FOREIGN_KEYS                  = {0xc8b522c4,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBSCHEMA_PRIMARY_KEYS                  = {0xc8b522c5,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBSCHEMA_PROCEDURE_COLUMNS             = {0xc8b522c9,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBCOL_SELFCOLUMNS                      = {0xc8b52231,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBCOL_SPECIALCOL                       = {0xc8b52232,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID PSGUID_QUERY                           = {0x49691c90,0x7e17,0x101a,{0xa9,0x1c,0x08,0x00,0x2b,0x2e,0xcd,0xa9}};
extern const OLEDBDECLSPEC GUID DBPROPSET_COLUMN                       = {0xc8b522b9,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBPROPSET_DATASOURCE                   = {0xc8b522ba,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBPROPSET_DATASOURCEINFO               = {0xc8b522bb,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBPROPSET_DBINIT                       = {0xc8b522bc,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBPROPSET_INDEX                        = {0xc8b522bd,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBPROPSET_ROWSET                       = {0xc8b522be,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBPROPSET_TABLE                        = {0xc8b522bf,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBPROPSET_DATASOURCEALL                = {0xc8b522c0,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBPROPSET_DATASOURCEINFOALL            = {0xc8b522c1,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBPROPSET_ROWSETALL                    = {0xc8b522c2,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBPROPSET_SESSION                      = {0xc8b522c6,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBPROPSET_SESSIONALL                   = {0xc8b522c7,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBPROPSET_DBINITALL                    = {0xc8b522ca,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBPROPSET_PROPERTIESINERROR            = {0xc8b522d4,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};

extern const OLEDBDECLSPEC GUID DBPROPSET_VIEW                         = {0xc8b522df,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};

// DBGUID_DBSQL is deprecated; use DBGUID_DEFAULT instead
extern const OLEDBDECLSPEC  GUID DBGUID_DBSQL                           = {0xc8b521fb,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBGUID_DEFAULT                         = {0xc8b521fb,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC GUID DBGUID_SQL                             = {0xc8b522d7,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};

enum DBPROPENUM
    {	DBPROP_ABORTPRESERVE	= 0x2L,
	DBPROP_ACTIVESESSIONS	= 0x3L,
	DBPROP_APPENDONLY	= 0xbbL,
	DBPROP_ASYNCTXNABORT	= 0xa8L,
	DBPROP_ASYNCTXNCOMMIT	= 0x4L,
	DBPROP_AUTH_CACHE_AUTHINFO	= 0x5L,
	DBPROP_AUTH_ENCRYPT_PASSWORD	= <PASSWORD>,
	DBPROP_AUTH_INTEGRATED	= 0x7L,
	DBPROP_AUTH_MASK_PASSWORD	= <PASSWORD>,
	DBPROP_AUTH_PASSWORD	= <PASSWORD>,
	DBPROP_AUTH_PERSIST_ENCRYPTED	= 0xaL,
	DBPROP_AUTH_PERSIST_SENSITIVE_AUTHINFO	= 0xbL,
	DBPROP_AUTH_USERID	= 0xcL,
	DBPROP_BLOCKINGSTORAGEOBJECTS	= 0xdL,
	DBPROP_BOOKMARKS	= 0xeL,
	DBPROP_BOOKMARKSKIPPED	= 0xfL,
	DBPROP_BOOKMARKTYPE	= 0x10L,
	DBPROP_BYREFACCESSORS	= 0x78L,
	DBPROP_CACHEDEFERRED	= 0x11L,
	DBPROP_CANFETCHBACKWARDS	= 0x12L,
	DBPROP_CANHOLDROWS	= 0x13L,
	DBPROP_CANSCROLLBACKWARDS	= 0x15L,
	DBPROP_CATALOGLOCATION	= 0x16L,
	DBPROP_CATALOGTERM	= 0x17L,
	DBPROP_CATALOGUSAGE	= 0x18L,
	DBPROP_CHANGEINSERTEDROWS	= 0xbcL,
	DBPROP_COL_AUTOINCREMENT	= 0x1aL,
	DBPROP_COL_DEFAULT	= 0x1bL,
	DBPROP_COL_DESCRIPTION	= 0x1cL,
	DBPROP_COL_FIXEDLENGTH	= 0xa7L,
	DBPROP_COL_NULLABLE	= 0x1dL,
	DBPROP_COL_PRIMARYKEY	= 0x1eL,
	DBPROP_COL_UNIQUE	= 0x1fL,
	DBPROP_COLUMNDEFINITION	= 0x20L,
	DBPROP_COLUMNRESTRICT	= 0x21L,
	DBPROP_COMMANDTIMEOUT	= 0x22L,
	DBPROP_COMMITPRESERVE	= 0x23L,
	DBPROP_CONCATNULLBEHAVIOR	= 0x24L,
	DBPROP_CURRENTCATALOG	= 0x25L,
	DBPROP_DATASOURCENAME	= 0x26L,
	DBPROP_DATASOURCEREADONLY	= 0x27L,
	DBPROP_DBMSNAME	= 0x28L,
	DBPROP_DBMSVER	= 0x29L,
	DBPROP_DEFERRED	= 0x2aL,
	DBPROP_DELAYSTORAGEOBJECTS	= 0x2bL,
	DBPROP_DSOTHREADMODEL	= 0xa9L,
	DBPROP_GROUPBY	= 0x2cL,
	DBPROP_HETEROGENEOUSTABLES	= 0x2dL,
	DBPROP_IAccessor	= 0x79L,
	DBPROP_IColumnsInfo	= 0x7aL,
	DBPROP_IColumnsRowset	= 0x7bL,
	DBPROP_IConnectionPointContainer	= 0x7cL,
	DBPROP_IConvertType	= 0xc2L,
	DBPROP_IRowset	= 0x7eL,
	DBPROP_IRowsetChange	= 0x7fL,
	DBPROP_IRowsetIdentity	= 0x80L,
	DBPROP_IRowsetIndex	= 0x9fL,
	DBPROP_IRowsetInfo	= 0x81L,
	DBPROP_IRowsetLocate	= 0x82L,
	DBPROP_IRowsetResynch	= 0x84L,
	DBPROP_IRowsetScroll	= 0x85L,
	DBPROP_IRowsetUpdate	= 0x86L,
	DBPROP_ISupportErrorInfo	= 0x87L,
	DBPROP_ILockBytes	= 0x88L,
	DBPROP_ISequentialStream	= 0x89L,
	DBPROP_IStorage	= 0x8aL,
	DBPROP_IStream	= 0x8bL,
	DBPROP_IDENTIFIERCASE	= 0x2eL,
	DBPROP_IMMOBILEROWS	= 0x2fL,
	DBPROP_INDEX_AUTOUPDATE	= 0x30L,
	DBPROP_INDEX_CLUSTERED	= 0x31L,
	DBPROP_INDEX_FILLFACTOR	= 0x32L,
	DBPROP_INDEX_INITIALSIZE	= 0x33L,
	DBPROP_INDEX_NULLCOLLATION	= 0x34L,
	DBPROP_INDEX_NULLS	= 0x35L,
	DBPROP_INDEX_PRIMARYKEY	= 0x36L,
	DBPROP_INDEX_SORTBOOKMARKS	= 0x37L,
	DBPROP_INDEX_TEMPINDEX	= 0xa3L,
	DBPROP_INDEX_TYPE	= 0x38L,
	DBPROP_INDEX_UNIQUE	= 0x39L,
	DBPROP_INIT_DATASOURCE	= 0x3bL,
	DBPROP_INIT_HWND	= 0x3cL,
	DBPROP_INIT_IMPERSONATION_LEVEL	= 0x3dL,
	DBPROP_INIT_LCID	= 0xbaL,
	DBPROP_INIT_LOCATION	= 0x3eL,
	DBPROP_INIT_MODE	= 0x3fL,
	DBPROP_INIT_PROMPT	= 0x40L,
	DBPROP_INIT_PROTECTION_LEVEL	= 0x41L,
	DBPROP_INIT_PROVIDERSTRING	= 0xa0L,
	DBPROP_INIT_TIMEOUT	= 0x42L,
	DBPROP_LITERALBOOKMARKS	= 0x43L,
	DBPROP_LITERALIDENTITY	= 0x44L,
	DBPROP_MARSHALLABLE	= 0xc5L,
	DBPROP_MAXINDEXSIZE	= 0x46L,
	DBPROP_MAXOPENROWS	= 0x47L,
	DBPROP_MAXPENDINGROWS	= 0x48L,
	DBPROP_MAXROWS	= 0x49L,
	DBPROP_MAXROWSIZE	= 0x4aL,
	DBPROP_MAXROWSIZEINCLUDESBLOB	= 0x4bL,
	DBPROP_MAXTABLESINSELECT	= 0x4cL,
	DBPROP_MAYWRITECOLUMN	= 0x4dL,
	DBPROP_MEMORYUSAGE	= 0x4eL,
	DBPROP_MULTIPLEPARAMSETS	= 0xbfL,
	DBPROP_MULTIPLERESULTS	= 0xc4L,
	DBPROP_MULTIPLESTORAGEOBJECTS	= 0x50L,
	DBPROP_MULTITABLEUPDATE	= 0x51L,
	DBPROP_NOTIFICATIONGRANULARITY	= 0xc6L,
	DBPROP_NOTIFICATIONPHASES	= 0x52L,
	DBPROP_NOTIFYCOLUMNSET	= 0xabL,
	DBPROP_NOTIFYROWDELETE	= 0xadL,
	DBPROP_NOTIFYROWFIRSTCHANGE	= 0xaeL,
	DBPROP_NOTIFYROWINSERT	= 0xafL,
	DBPROP_NOTIFYROWRESYNCH	= 0xb1L,
	DBPROP_NOTIFYROWSETCHANGED	= 0xd3L,
	DBPROP_NOTIFYROWSETRELEASE	= 0xb2L,
	DBPROP_NOTIFYROWSETFETCHPOSITIONCHANGE	= 0xb3L,
	DBPROP_NOTIFYROWUNDOCHANGE	= 0xb4L,
	DBPROP_NOTIFYROWUNDODELETE	= 0xb5L,
	DBPROP_NOTIFYROWUNDOINSERT	= 0xb6L,
	DBPROP_NOTIFYROWUPDATE	= 0xb7L,
	DBPROP_NULLCOLLATION	= 0x53L,
	DBPROP_OLEOBJECTS	= 0x54L,
	DBPROP_ORDERBYCOLUMNSINSELECT	= 0x55L,
	DBPROP_ORDEREDBOOKMARKS	= 0x56L,
	DBPROP_OTHERINSERT	= 0x57L,
	DBPROP_OTHERUPDATEDELETE	= 0x58L,
	DBPROP_OUTPUTPARAMETERAVAILABILITY	= 0xb8L,
	DBPROP_OWNINSERT	= 0x59L,
	DBPROP_OWNUPDATEDELETE	= 0x5aL,
	DBPROP_PERSISTENTIDTYPE	= 0xb9L,
	DBPROP_PREPAREABORTBEHAVIOR	= 0x5bL,
	DBPROP_PREPARECOMMITBEHAVIOR	= 0x5cL,
	DBPROP_PROCEDURETERM	= 0x5dL,
	DBPROP_PROVIDERNAME	= 0x60L,
	DBPROP_PROVIDEROLEDBVER	= 0x61L,
	DBPROP_PROVIDERVER	= 0x62L,
	DBPROP_QUICKRESTART	= 0x63L,
	DBPROP_QUOTEDIDENTIFIERCASE	= 0x64L,
	DBPROP_REENTRANTEVENTS	= 0x65L,
	DBPROP_REMOVEDELETED	= 0x66L,
	DBPROP_REPORTMULTIPLECHANGES	= 0x67L,
	DBPROP_RETURNPENDINGINSERTS	= 0xbdL,
	DBPROP_ROWRESTRICT	= 0x68L,
	DBPROP_ROWSETCONVERSIONSONCOMMAND	= 0xc0L,
	DBPROP_ROWTHREADMODEL	= 0x69L,
	DBPROP_SCHEMATERM	= 0x6aL,
	DBPROP_SCHEMAUSAGE	= 0x6bL,
	DBPROP_SERVERCURSOR	= 0x6cL,
	DBPROP_SESS_AUTOCOMMITISOLEVELS	= 0xbeL,
	DBPROP_SQLSUPPORT	= 0x6dL,
	DBPROP_STRONGIDENTITY	= 0x77L,
	DBPROP_STRUCTUREDSTORAGE	= 0x6fL,
	DBPROP_SUBQUERIES	= 0x70L,
	DBPROP_SUPPORTEDTXNDDL	= 0xa1L,
	DBPROP_SUPPORTEDTXNISOLEVELS	= 0x71L,
	DBPROP_SUPPORTEDTXNISORETAIN	= 0x72L,
	DBPROP_TABLETERM	= 0x73L,
	DBPROP_TBL_TEMPTABLE	= 0x8cL,
	DBPROP_TRANSACTEDOBJECT	= 0x74L,
	DBPROP_UPDATABILITY	= 0x75L,
	DBPROP_USERNAME	= 0x76L
    };

enum DBPROPENUM15
    {	DBPROP_FILTEROPS	= 0xd0L,
	DBPROP_FILTERCOMPAREOPS	= 0xd1L,
	DBPROP_FINDCOMPAREOPS	= 0xd2L,
	DBPROP_IChapteredRowset	= 0xcaL,
	DBPROP_IDBAsynchStatus	= 0xcbL,
	DBPROP_IRowsetFind	= 0xccL,
	DBPROP_IRowsetView	= 0xd4L,
	DBPROP_IViewChapter	= 0xd5L,
	DBPROP_IViewFilter	= 0xd6L,
	DBPROP_IViewRowset	= 0xd7L,
	DBPROP_IViewSort	= 0xd8L,
	DBPROP_INIT_ASYNCH	= 0xc8L,
	DBPROP_MAXOPENCHAPTERS	= 0xc7L,
	DBPROP_MAXORSINFILTER	= 0xcdL,
	DBPROP_MAXSORTCOLUMNS	= 0xceL,
	DBPROP_ROWSET_ASYNCH	= 0xc9L,
	DBPROP_SORTONINDEX	= 0xcfL
    };

#define DBPROP_PROVIDERFILENAME DBPROP_PROVIDERNAME
#define DBPROP_SERVER_NAME DBPROP_SERVERNAME

enum DBPROPENUM20
    {	DBPROP_IMultipleResults	= 0xd9L,
	DBPROP_DATASOURCE_TYPE	= 0xfbL,
	MDPROP_AXES	= 0xfcL,
	MDPROP_FLATTENING_SUPPORT	= 0xfdL,
	MDPROP_MDX_JOINCUBES	= 0xfeL,
	MDPROP_NAMED_LEVELS	= 0xffL,
	MDPROP_RANGEROWSET	= 0x100L,
	MDPROP_MDX_SLICER	= 0xdaL,
	MDPROP_MDX_CUBEQUALIFICATION	= 0xdbL,
	MDPROP_MDX_OUTERREFERENCE	= 0xdcL,
	MDPROP_MDX_QUERYBYPROPERTY	= 0xddL,
	MDPROP_MDX_CASESUPPORT	= 0xdeL,
	MDPROP_MDX_STRING_COMPOP	= 0xe0L,
	MDPROP_MDX_DESCFLAGS	= 0xe1L,
	MDPROP_MDX_SET_FUNCTIONS	= 0xe2L,
	MDPROP_MDX_MEMBER_FUNCTIONS	= 0xe3L,
	MDPROP_MDX_NUMERIC_FUNCTIONS	= 0xe4L,
	MDPROP_MDX_FORMULAS	= 0xe5L,
	MDPROP_MDX_AGGREGATECELL_UPDATE	= 0xe6L,
	MDPROP_MDX_OBJQUALIFICATION	= 0x105L,
	MDPROP_MDX_NONMEASURE_EXPRESSONS	= 0x106L,
	DBPROP_ACCESSORDER	= 0xe7L,
	DBPROP_BOOKMARKINFO	= 0xe8L,
	DBPROP_INIT_CATALOG	= 0xe9L,
	DBPROP_ROW_BULKOPS	= 0xeaL,
	DBPROP_PROVIDERFRIENDLYNAME	= 0xebL,
	DBPROP_LOCKMODE	= 0xecL,
	DBPROP_MULTIPLECONNECTIONS	= 0xedL,
	DBPROP_UNIQUEROWS	= 0xeeL,
	DBPROP_SERVERDATAONINSERT	= 0xefL,
	DBPROP_STORAGEFLAGS	= 0xf0L,
	DBPROP_CONNECTIONSTATUS	= 0xf4L,
	DBPROP_ALTERCOLUMN	= 0xf5L,
	DBPROP_COLUMNLCID	= 0xf6L,
	DBPROP_RESETDATASOURCE	= 0xf7L,
	DBPROP_INIT_OLEDBSERVICES	= 0xf8L,
	DBPROP_IRowsetRefresh	= 0xf9L,
	DBPROP_SERVERNAME	= 0xfaL,
	DBPROP_IParentRowset	= 0x101L,
	DBPROP_HIDDENCOLUMNS	= 0x102L,
	DBPROP_PROVIDERMEMORY	= 0x103L,
	DBPROP_CLIENTCURSOR	= 0x104L
    };

enum DBPROPENUM21
    {	DBPROP_TRUSTEE_USERNAME	= 0xf1L,
	DBPROP_TRUSTEE_AUTHENTICATION	= 0xf2L,
	DBPROP_TRUSTEE_NEWAUTHENTICATION	= 0xf3L,
	DBPROP_IRow	= 0x107L,
	DBPROP_IRowChange	= 0x108L,
	DBPROP_IRowSchemaChange	= 0x109L,
	DBPROP_IGetRow	= 0x10aL,
	DBPROP_IScopedOperations	= 0x10bL,
	DBPROP_IBindResource	= 0x10cL,
	DBPROP_ICreateRow	= 0x10dL,
	DBPROP_INIT_BINDFLAGS	= 0x10eL,
	DBPROP_INIT_LOCKOWNER	= 0x10fL,
	DBPROP_GENERATEURL	= 0x111L,
	DBPROP_IDBBinderProperties	= 0x112L,
	DBPROP_IColumnsInfo2	= 0x113L,
	DBPROP_IRegisterProvider	= 0x114L,
	DBPROP_IGetSession	= 0x115L,
	DBPROP_IGetSourceRow	= 0x116L,
	DBPROP_IRowsetCurrentIndex	= 0x117L,
	DBPROP_OPENROWSETSUPPORT	= 0x118L,
	DBPROP_COL_ISLONG	= 0x119L
    };

//@@@+ deprecated
#ifdef deprecated

enum DBPROPENUMDEPRECATED
    {	DBPROP_IRowsetExactScroll	= 0x9aL
    };
#endif // deprecated
//@@@- deprecated
#define DBPROPVAL_BMK_NUMERIC							 0x00000001L
#define DBPROPVAL_BMK_KEY								 0x00000002L
#define DBPROPVAL_CL_START                                0x00000001L
#define DBPROPVAL_CL_END                                  0x00000002L
#define DBPROPVAL_CU_DML_STATEMENTS						 0x00000001L
#define DBPROPVAL_CU_TABLE_DEFINITION					 0x00000002L
#define DBPROPVAL_CU_INDEX_DEFINITION					 0x00000004L
#define DBPROPVAL_CU_PRIVILEGE_DEFINITION				 0x00000008L
#define DBPROPVAL_CD_NOTNULL								 0x00000001L
#define DBPROPVAL_CB_NULL								 0x00000001L
#define DBPROPVAL_CB_NON_NULL							 0x00000002L
#define DBPROPVAL_FU_NOT_SUPPORTED						 0x00000001L
#define DBPROPVAL_FU_COLUMN								 0x00000002L
#define DBPROPVAL_FU_TABLE								 0x00000004L
#define DBPROPVAL_FU_CATALOG								 0x00000008L
#define DBPROPVAL_GB_NOT_SUPPORTED						 0x00000001L
#define DBPROPVAL_GB_EQUALS_SELECT						 0x00000002L
#define DBPROPVAL_GB_CONTAINS_SELECT						 0x00000004L
#define DBPROPVAL_GB_NO_RELATION							 0x00000008L
#define DBPROPVAL_HT_DIFFERENT_CATALOGS					 0x00000001L
#define DBPROPVAL_HT_DIFFERENT_PROVIDERS					 0x00000002L
#define DBPROPVAL_IC_UPPER								 0x00000001L
#define DBPROPVAL_IC_LOWER								 0x00000002L
#define DBPROPVAL_IC_SENSITIVE							 0x00000004L
#define DBPROPVAL_IC_MIXED								 0x00000008L
//@@@+ deprecated
#ifdef deprecated
#define DBPROPVAL_LM_NONE								 0x00000001L
#define DBPROPVAL_LM_READ								 0x00000002L
#define DBPROPVAL_LM_INTENT								 0x00000004L
#define DBPROPVAL_LM_RITE								 0x00000008L
#endif // deprecated
//@@@- deprecated
#define DBPROPVAL_NP_OKTODO								 0x00000001L
#define DBPROPVAL_NP_ABOUTTODO							 0x00000002L
#define DBPROPVAL_NP_SYNCHAFTER							 0x00000004L
#define DBPROPVAL_NP_FAILEDTODO							 0x00000008L
#define DBPROPVAL_NP_DIDEVENT							 0x00000010L
#define DBPROPVAL_NC_END									 0x00000001L
#define DBPROPVAL_NC_HIGH								 0x00000002L
#define DBPROPVAL_NC_LOW									 0x00000004L
#define DBPROPVAL_NC_START								 0x00000008L
#define DBPROPVAL_OO_BLOB								 0x00000001L
#define DBPROPVAL_OO_IPERSIST							 0x00000002L
#define DBPROPVAL_CB_DELETE								 0x00000001L
#define DBPROPVAL_CB_PRESERVE							 0x00000002L
#define DBPROPVAL_SU_DML_STATEMENTS						 0x00000001L
#define DBPROPVAL_SU_TABLE_DEFINITION					 0x00000002L
#define DBPROPVAL_SU_INDEX_DEFINITION					 0x00000004L
#define DBPROPVAL_SU_PRIVILEGE_DEFINITION				 0x00000008L
#define DBPROPVAL_SQ_CORRELATEDSUBQUERIES				 0x00000001L
#define DBPROPVAL_SQ_COMPARISON							 0x00000002L
#define DBPROPVAL_SQ_EXISTS								 0x00000004L
#define DBPROPVAL_SQ_IN									 0x00000008L
#define DBPROPVAL_SQ_QUANTIFIED							 0x00000010L
#define DBPROPVAL_SQ_TABLE								 0x00000020L
#define DBPROPVAL_SS_ISEQUENTIALSTREAM					 0x00000001L
#define DBPROPVAL_SS_ISTREAM								 0x00000002L
#define DBPROPVAL_SS_ISTORAGE							 0x00000004L
#define DBPROPVAL_SS_ILOCKBYTES							 0x00000008L
#define DBPROPVAL_TI_CHAOS								 0x00000010L
#define DBPROPVAL_TI_READUNCOMMITTED						 0x00000100L
#define DBPROPVAL_TI_BROWSE								 0x00000100L
#define DBPROPVAL_TI_CURSORSTABILITY						 0x00001000L
#define DBPROPVAL_TI_READCOMMITTED						 0x00001000L
#define DBPROPVAL_TI_REPEATABLEREAD						 0x00010000L
#define DBPROPVAL_TI_SERIALIZABLE						 0x00100000L
#define DBPROPVAL_TI_ISOLATED							 0x00100000L
#define DBPROPVAL_TR_COMMIT_DC							 0x00000001L
#define DBPROPVAL_TR_COMMIT								 0x00000002L
#define DBPROPVAL_TR_COMMIT_NO							 0x00000004L
#define DBPROPVAL_TR_ABORT_DC							 0x00000008L
#define DBPROPVAL_TR_ABORT								 0x00000010L
#define DBPROPVAL_TR_ABORT_NO							 0x00000020L
#define DBPROPVAL_TR_DONTCARE							 0x00000040L
#define DBPROPVAL_TR_BOTH								 0x00000080L
#define DBPROPVAL_TR_NONE								 0x00000100L
#define DBPROPVAL_TR_OPTIMISTIC							 0x00000200L
#define DBPROPVAL_RT_FREETHREAD							 0x00000001L
#define DBPROPVAL_RT_APTMTTHREAD							 0x00000002L
#define DBPROPVAL_RT_SINGLETHREAD						 0x00000004L
#define DBPROPVAL_UP_CHANGE								 0x00000001L
#define DBPROPVAL_UP_DELETE								 0x00000002L
#define DBPROPVAL_UP_INSERT								 0x00000004L
#define DBPROPVAL_SQL_NONE								 0x00000000L
#define DBPROPVAL_SQL_ODBC_MINIMUM						 0x00000001L
#define DBPROPVAL_SQL_ODBC_CORE							 0x00000002L
#define DBPROPVAL_SQL_ODBC_EXTENDED						 0x00000004L
#define DBPROPVAL_SQL_ANSI89_IEF							 0x00000008L
#define DBPROPVAL_SQL_ANSI92_ENTRY						 0x00000010L
#define DBPROPVAL_SQL_FIPS_TRANSITIONAL					 0x00000020L
#define DBPROPVAL_SQL_ANSI92_INTERMEDIATE				 0x00000040L
#define DBPROPVAL_SQL_ANSI92_FULL						 0x00000080L
#define DBPROPVAL_SQL_ESCAPECLAUSES						 0x00000100L
#define DBPROPVAL_IT_BTREE                                0x00000001L
#define DBPROPVAL_IT_HASH                                 0x00000002L
#define DBPROPVAL_IT_CONTENT                              0x00000003L
#define DBPROPVAL_IT_OTHER                                0x00000004L
#define DBPROPVAL_IN_DISALLOWNULL                         0x00000001L
#define DBPROPVAL_IN_IGNORENULL                           0x00000002L
#define DBPROPVAL_IN_IGNOREANYNULL                        0x00000004L
#define DBPROPVAL_TC_NONE                                 0x00000000L
#define DBPROPVAL_TC_DML                                  0x00000001L
#define DBPROPVAL_TC_DDL_COMMIT                           0x00000002L
#define DBPROPVAL_TC_DDL_IGNORE                           0x00000004L
#define DBPROPVAL_TC_ALL                                  0x00000008L
#define DBPROPVAL_NP_OKTODO                               0x00000001L
#define DBPROPVAL_NP_ABOUTTODO                            0x00000002L
#define DBPROPVAL_NP_SYNCHAFTER                           0x00000004L
#define DBPROPVAL_OA_NOTSUPPORTED                         0x00000001L
#define DBPROPVAL_OA_ATEXECUTE                            0x00000002L
#define DBPROPVAL_OA_ATROWRELEASE                         0x00000004L
#define DBPROPVAL_MR_NOTSUPPORTED                         0x00000000L
#define DBPROPVAL_MR_SUPPORTED                            0x00000001L
#define DBPROPVAL_MR_CONCURRENT                           0x00000002L
#define DBPROPVAL_PT_GUID_NAME                            0x00000001L
#define DBPROPVAL_PT_GUID_PROPID                          0x00000002L
#define DBPROPVAL_PT_NAME                                 0x00000004L
#define DBPROPVAL_PT_GUID                                 0x00000008L
#define DBPROPVAL_PT_PROPID								 0x00000010L
#define DBPROPVAL_PT_PGUID_NAME                           0x00000020L
#define DBPROPVAL_PT_PGUID_PROPID						 0x00000040L
#define DBPROPVAL_NT_SINGLEROW                            0x00000001L
#define DBPROPVAL_NT_MULTIPLEROWS                         0x00000002L

#define DBPROPVAL_ASYNCH_INITIALIZE                       0x00000001L
#define DBPROPVAL_ASYNCH_SEQUENTIALPOPULATION             0x00000002L
#define DBPROPVAL_ASYNCH_RANDOMPOPULATION                 0x00000004L
#define DBPROPVAL_OP_EQUAL                                0x00000001L
#define DBPROPVAL_OP_RELATIVE                             0x00000002L
#define DBPROPVAL_OP_STRING                               0x00000004L
#define DBPROPVAL_CO_EQUALITY                             0x00000001L
#define DBPROPVAL_CO_STRING                               0x00000002L
#define DBPROPVAL_CO_CASESENSITIVE                        0x00000004L
#define DBPROPVAL_CO_CASEINSENSITIVE                      0x00000008L

#define DBPROPVAL_CO_CONTAINS		                     0x00000010L
#define DBPROPVAL_CO_BEGINSWITH		                     0x00000020L
#define DBPROPVAL_ASYNCH_BACKGROUNDPOPULATION			0x00000008L
#define DBPROPVAL_ASYNCH_PREPOPULATE						0x00000010L
#define DBPROPVAL_ASYNCH_POPULATEONDEMAND				0x00000020L
#define DBPROPVAL_LM_NONE								 0x00000001L
#define DBPROPVAL_LM_SINGLEROW							 0x00000002L
#define DBPROPVAL_SQL_SUBMINIMUM 						 0x00000200L
#define DBPROPVAL_DST_TDP                                 0x00000001L
#define DBPROPVAL_DST_MDP                                 0x00000002L
#define DBPROPVAL_DST_TDPANDMDP                           0x00000003L
#define MDPROPVAL_AU_UNSUPPORTED                          0x00000000L
#define MDPROPVAL_AU_UNCHANGED                            0x00000001L
#define MDPROPVAL_AU_UNKNOWN                              0x00000002L
#define MDPROPVAL_MF_WITH_CALCMEMBERS                     0x00000001L
#define MDPROPVAL_MF_WITH_NAMEDSETS                       0x00000002L
#define MDPROPVAL_MF_CREATE_CALCMEMBERS                   0x00000004L
#define MDPROPVAL_MF_CREATE_NAMEDSETS                     0x00000008L
#define MDPROPVAL_MF_SCOPE_SESSION						 0x00000010L
#define MDPROPVAL_MF_SCOPE_GLOBAL                         0x00000020L
#define MDPROPVAL_MMF_COUSIN                              0x00000001L
#define MDPROPVAL_MMF_PARALLELPERIOD                      0x00000002L
#define MDPROPVAL_MMF_OPENINGPERIOD                       0x00000004L
#define MDPROPVAL_MMF_CLOSINGPERIOD                       0x00000008L
#define MDPROPVAL_MNF_MEDIAN								0x00000001L
#define MDPROPVAL_MNF_VAR								0x00000002L
#define MDPROPVAL_MNF_STDDEV								0x00000004L
#define MDPROPVAL_MNF_RANK								0x00000008L
#define MDPROPVAL_MNF_AGGREGATE							0x00000010L
#define MDPROPVAL_MNF_COVARIANCE							0x00000020L
#define MDPROPVAL_MNF_CORRELATION						0x00000040L
#define MDPROPVAL_MNF_LINREGSLOPE						0x00000080L
#define MDPROPVAL_MNF_LINREGVARIANCE						0x00000100L
#define MDPROPVAL_MNF_LINREG2							0x00000200L
#define MDPROPVAL_MNF_LINREGPOINT						0x00000400L
#define MDPROPVAL_MNF_DRILLDOWNLEVEL						0x00000800L
#define MDPROPVAL_MNF_DRILLDOWNMEMBERTOP					0x00001000L
#define MDPROPVAL_MNF_DRILLDOWNMEMBERBOTTOM				0x00002000L
#define MDPROPVAL_MNF_DRILLDOWNLEVELTOP					0x00004000L
#define MDPROPVAL_MNF_DRILLDOWNLEVELBOTTOM				0x00008000L
#define MDPROPVAL_MNF_DRILLUPMEMBER						0x00010000L
#define MDPROPVAL_MNF_DRILLUPLEVEL						0x00020000L
#define MDPROPVAL_MMF_COUSIN								0x00000001L
#define MDPROPVAL_MMF_PARALLELPERIOD						0x00000002L
#define MDPROPVAL_MMF_OPENINGPERIOD						0x00000004L
#define MDPROPVAL_MMF_CLOSINGPERIOD						0x00000008L
#define MDPROPVAL_MSF_TOPPERCENT							0x00000001L
#define MDPROPVAL_MSF_BOTTOMPERCENT						0x00000002L
#define MDPROPVAL_MSF_TOPSUM								0x00000004L
#define MDPROPVAL_MSF_BOTTOMSUM							0x00000008L
#define MDPROPVAL_MSF_PERIODSTODATE						0x00000010L
#define MDPROPVAL_MSF_LASTPERIODS						0x00000020L
#define MDPROPVAL_MSF_YTD								0x00000040L
#define MDPROPVAL_MSF_QTD								0x00000080L
#define MDPROPVAL_MSF_MTD								0x00000100L
#define MDPROPVAL_MSF_WTD								0x00000200L
#define MDPROPVAL_MSF_DRILLDOWNMEMBBER					0x00000400L
#define MDPROPVAL_MSF_DRILLDOWNLEVEL						0x00000800L
#define MDPROPVAL_MSF_DRILLDOWNMEMBERTOP					0x00001000L
#define MDPROPVAL_MSF_DRILLDOWNMEMBERBOTTOM				0x00002000L
#define MDPROPVAL_MSF_DRILLDOWNLEVELTOP					0x00004000L
#define MDPROPVAL_MSF_DRILLDOWNLEVELBOTTOM				0x00008000L
#define MDPROPVAL_MSF_DRILLUPMEMBER						0x00010000L
#define MDPROPVAL_MSF_DRILLUPLEVEL						0x00020000L
#define MDPROPVAL_MSF_TOGGLEDRILLSTATE					0x00040000L
// values for MDPROP_MDX_DESCFLAGS
#define MDPROPVAL_MD_SELF								0x00000001L
#define MDPROPVAL_MD_BEFORE								0x00000002L
#define MDPROPVAL_MD_AFTER								0x00000004L
// values for MDPROP_MDX_STRING_COMPOP
#define MDPROPVAL_MSC_LESSTHAN							0x00000001L
#define MDPROPVAL_MSC_GREATERTHAN						0x00000002L
#define MDPROPVAL_MSC_LESSTHANEQUAL						0x00000004L
#define MDPROPVAL_MSC_GREATERTHANEQUAL					0x00000008L
#define MDPROPVAL_MC_SINGLECASE							0x00000001L
#define MDPROPVAL_MC_SEARCHEDCASE						0x00000002L
#define MDPROPVAL_MOQ_OUTERREFERENCE						0x00000001L
#define MDPROPVAL_MOQ_DATASOURCE_CUBE					0x00000001L
#define MDPROPVAL_MOQ_CATALOG_CUBE						0x00000002L
#define MDPROPVAL_MOQ_SCHEMA_CUBE						0x00000004L
#define MDPROPVAL_MOQ_CUBE_DIM							0x00000008L
#define MDPROPVAL_MOQ_DIM_HIER							0x00000010L
#define MDPROPVAL_MOQ_DIMHIER_LEVEL						0x00000020L
#define MDPROPVAL_MOQ_LEVEL_MEMBER						0x00000040L
#define MDPROPVAL_MOQ_MEMBER_MEMBER						0x00000080L
#define MDPROPVAL_FS_FULL_SUPPORT						0x00000001L
#define MDPROPVAL_FS_GENERATED_COLUMN					0x00000002L
#define MDPROPVAL_FS_GENERATED_DIMENSION					0x00000003L
#define MDPROPVAL_FS_NO_SUPPORT							0x00000004L
#define MDPROPVAL_NL_NAMEDLEVELS							0x00000001L
#define MDPROPVAL_NL_NUMBEREDLEVELS						0x00000002L
#define MDPROPVAL_MJC_SINGLECUBE							0x00000001L
#define MDPROPVAL_MJC_MULTICUBES							0x00000002L
#define MDPROPVAL_MJC_IMPLICITCUBE						0x00000004L
#define MDPROPVAL_RR_NORANGEROWSET						0x00000001L
#define MDPROPVAL_RR_READONLY							0x00000002L
#define MDPROPVAL_RR_UPDATE								0x00000004L
#define MDPROPVAL_MS_MULTIPLETUPLES						0x00000001L
#define MDPROPVAL_MS_SINGLETUPLE						0x00000002L
#define DBPROPVAL_AO_SEQUENTIAL							0x00000000L
#define DBPROPVAL_AO_SEQUENTIALSTORAGEOBJECTS			0x00000001L
#define DBPROPVAL_AO_RANDOM								0x00000002L
#define DBPROPVAL_BD_ROWSET								0x00000000L
#define DBPROPVAL_BD_INTRANSACTION						0x00000001L
#define DBPROPVAL_BD_XTRANSACTION						0x00000002L
#define DBPROPVAL_BD_REORGANIZATION						0x00000003L
#define BMK_DURABILITY_ROWSET							DBPROPVAL_BD_ROWSET
#define BMK_DURABILITY_INTRANSACTION						DBPROPVAL_BD_INTRANSACTION
#define BMK_DURABILITY_XTRANSACTION						DBPROPVAL_BD_XTRANSACTION
#define BMK_DURABILITY_REORGANIZATION					DBPROPVAL_BD_REORGANIZATION
#define DBPROPVAL_BO_NOLOG								0x00000000L
#define DBPROPVAL_BO_NOINDEXUPDATE						0x00000001L
#define DBPROPVAL_BO_REFINTEGRITY						0x00000002L
#if !defined(_WINBASE_)
#define OF_READ             0x00000000
#define OF_WRITE            0x00000001
#define OF_READWRITE        0x00000002
#define OF_SHARE_COMPAT     0x00000000
#define OF_SHARE_EXCLUSIVE  0x00000010
#define OF_SHARE_DENY_WRITE 0x00000020
#define OF_SHARE_DENY_READ  0x00000030
#define OF_SHARE_DENY_NONE  0x00000040
#define OF_PARSE            0x00000100
#define OF_DELETE           0x00000200
#define OF_VERIFY           0x00000400
#define OF_CANCEL           0x00000800
#define OF_CREATE           0x00001000
#define OF_PROMPT           0x00002000
#define OF_EXIST            0x00004000
#define OF_REOPEN           0x00008000
#endif // !_WINBASE_
#define DBPROPVAL_STGM_READ					OF_READ
#define DBPROPVAL_STGM_WRITE					OF_WRITE
#define DBPROPVAL_STGM_READWRITE				OF_READWRITE
#define DBPROPVAL_STGM_SHARE_DENY_NONE		OF_SHARE_DENY_NONE
#define DBPROPVAL_STGM_SHARE_DENY_READ		OF_SHARE_DENY_READ
#define DBPROPVAL_STGM_SHARE_DENY_WRITE		OF_SHARE_DENY_WRITE
#define DBPROPVAL_STGM_SHARE_EXCLUSIVE		OF_SHARE_EXCLUSIVE
#define DBPROPVAL_STGM_DIRECT				0x00010000
#define DBPROPVAL_STGM_TRANSACTED			0x00020000
#define DBPROPVAL_STGM_CREATE				OF_CREATE
#define DBPROPVAL_STGM_CONVERT				0x00040000
#define DBPROPVAL_STGM_FAILIFTHERE			0x00080000
#define DBPROPVAL_STGM_PRIORITY				0x00100000
#define DBPROPVAL_STGM_DELETEONRELEASE		0x00200000
#define DBPROPVAL_GB_COLLATE 				0x00000010L
#define DBPROPVAL_CS_UNINITIALIZED			0x00000000L
#define DBPROPVAL_CS_INITIALIZED				0x00000001L
#define DBPROPVAL_CS_COMMUNICATIONFAILURE	0x00000002L
#define DBPROPVAL_RD_RESETALL		0xffffffffL
#define DBPROPVAL_OS_RESOURCEPOOLING	0x00000001L
#define DBPROPVAL_OS_TXNENLISTMENT	0x00000002L
#define DBPROPVAL_OS_CLIENTCURSOR    0x00000004L
#define DBPROPVAL_OS_ENABLEALL		0xffffffffL
#define DBPROPVAL_BI_CROSSROWSET		0x00000001L

#define MDPROPVAL_NL_SCHEMAONLY                          0x00000004L
#define DBPROPVAL_OS_DISABLEALL	0x00000000L
#define DBPROPVAL_OO_ROWOBJECT							0x00000004L
#define DBPROPVAL_OO_SCOPED								0x00000008L
#define DBPROPVAL_OO_DIRECTBIND							0x00000010L
#define DBPROPVAL_DST_DOCSOURCE                          0x00000004L
#define DBPROPVAL_GU_NOTSUPPORTED                         0x00000001L
#define DBPROPVAL_GU_SUFFIX		                         0x00000002L
#define DB_BINDFLAGS_DELAYFETCHCOLUMNS                    0x00000001L
#define DB_BINDFLAGS_DELAYFETCHSTREAM                     0x00000002L
#define DB_BINDFLAGS_RECURSIVE		                     0x00000004L
#define DB_BINDFLAGS_OUTPUT								 0x00000008L
#define DB_BINDFLAGS_COLLECTION							 0x00000010L
#define DB_BINDFLAGS_OPENIFEXISTS						 0x00000020L
#define DB_BINDFLAGS_OVERWRITE							 0x00000040L
#define DB_BINDFLAGS_ISSTRUCTUREDDOCUMENT				 0x00000080L
#define DBPROPVAL_ORS_TABLE								 0x00000000L
#define DBPROPVAL_ORS_INDEX                               0x00000001L
#define DBPROPVAL_ORS_INTEGRATEDINDEX		             0x00000002L
#define DBPROPVAL_TC_DDL_LOCK							 0x00000010L
#define DBPROPVAL_ORS_STOREDPROC							 0x00000004L
#define DBPROPVAL_IN_ALLOWNULL	                         0x00000000L

#define DB_IMP_LEVEL_ANONYMOUS       0x00
#define DB_IMP_LEVEL_IDENTIFY        0x01
#define DB_IMP_LEVEL_IMPERSONATE     0x02
#define DB_IMP_LEVEL_DELEGATE        0x03
#define DBPROMPT_PROMPT              0x01
#define DBPROMPT_COMPLETE            0x02
#define DBPROMPT_COMPLETEREQUIRED    0x03
#define DBPROMPT_NOPROMPT            0x04
#define DB_PROT_LEVEL_NONE           0x00
#define DB_PROT_LEVEL_CONNECT        0x01
#define DB_PROT_LEVEL_CALL           0x02
#define DB_PROT_LEVEL_PKT            0x03
#define DB_PROT_LEVEL_PKT_INTEGRITY  0x04
#define DB_PROT_LEVEL_PKT_PRIVACY    0x05
#define DB_MODE_READ                 0x01
#define DB_MODE_WRITE                0x02
#define DB_MODE_READWRITE            0x03
#define DB_MODE_SHARE_DENY_READ      0x04
#define DB_MODE_SHARE_DENY_WRITE     0x08
#define DB_MODE_SHARE_EXCLUSIVE		0x0c
#define DB_MODE_SHARE_DENY_NONE		0x10
#define DBCOMPUTEMODE_COMPUTED       0x01
#define DBCOMPUTEMODE_DYNAMIC        0x02
#define DBCOMPUTEMODE_NOTCOMPUTED    0x03
#define DBPROPVAL_DF_INITIALLY_DEFERRED      0x01
#define DBPROPVAL_DF_INITIALLY_IMMEDIATE     0x02
#define DBPROPVAL_DF_NOT_DEFERRABLE		    0x03

typedef struct  tagDBPARAMS
    {
    void __RPC_FAR *pData;
    ULONG cParamSets;
    HACCESSOR hAccessor;
    }	DBPARAMS;

typedef DWORD DBPARAMFLAGS;


enum DBPARAMFLAGSENUM
    {	DBPARAMFLAGS_ISINPUT	= 0x1,
	DBPARAMFLAGS_ISOUTPUT	= 0x2,
	DBPARAMFLAGS_ISSIGNED	= 0x10,
	DBPARAMFLAGS_ISNULLABLE	= 0x40,
	DBPARAMFLAGS_ISLONG	= 0x80
    };

enum DBPARAMFLAGSENUM20
    {	DBPARAMFLAGS_SCALEISNEGATIVE	= 0x100
    };

typedef struct  tagDBPARAMINFO
    {
    DBPARAMFLAGS dwFlags;
    ULONG iOrdinal;
    LPOLESTR pwszName;
    ITypeInfo __RPC_FAR *pTypeInfo;
    ULONG ulParamSize;
    DBTYPE wType;
    BYTE bPrecision;
    BYTE bScale;
    }	DBPARAMINFO;

typedef DWORD DBPROPID;

typedef struct  tagDBPROPIDSET
    {
    /* [size_is] */ DBPROPID __RPC_FAR *rgPropertyIDs;
    ULONG cPropertyIDs;
    GUID guidPropertySet;
    }	DBPROPIDSET;

typedef DWORD DBPROPFLAGS;


enum DBPROPFLAGSENUM
    {	DBPROPFLAGS_NOTSUPPORTED	= 0,
	DBPROPFLAGS_COLUMN	= 0x1,
	DBPROPFLAGS_DATASOURCE	= 0x2,
	DBPROPFLAGS_DATASOURCECREATE	= 0x4,
	DBPROPFLAGS_DATASOURCEINFO	= 0x8,
	DBPROPFLAGS_DBINIT	= 0x10,
	DBPROPFLAGS_INDEX	= 0x20,
	DBPROPFLAGS_ROWSET	= 0x40,
	DBPROPFLAGS_TABLE	= 0x80,
	DBPROPFLAGS_COLUMNOK	= 0x100,
	DBPROPFLAGS_READ	= 0x200,
	DBPROPFLAGS_WRITE	= 0x400,
	DBPROPFLAGS_REQUIRED	= 0x800,
	DBPROPFLAGS_SESSION	= 0x1000
    };

enum DBPROPFLAGSENUM21
    {	DBPROPFLAGS_TRUSTEE	= 0x2000
    };

#if defined(MIPSII_FP) || defined(MIPSIV) || defined(MIPSIV_FP)
#pragma pack(push,8)
#endif
typedef struct  tagDBPROPINFO
    {
    LPOLESTR pwszDescription;
    DBPROPID dwPropertyID;
    DBPROPFLAGS dwFlags;
    VARTYPE vtType;
    VARIANT vValues;
    }	DBPROPINFO;
#if defined(MIPSII_FP) || defined(MIPSIV) || defined(MIPSIV_FP)
#pragma pack(pop)
#endif

#if 0 
//DBPROPINFO is an unaligned structure. MIDL workaround. 42212352
typedef DBPROPINFO __RPC_FAR *PDBPROPINFO;

#else
typedef DBPROPINFO UNALIGNED __RPC_FAR * PDBPROPINFO;
#endif
typedef struct  tagDBPROPINFOSET
    {
    /* [size_is] */ PDBPROPINFO rgPropertyInfos;
    ULONG cPropertyInfos;
    GUID guidPropertySet;
    }	DBPROPINFOSET;

typedef DWORD DBPROPOPTIONS;

// DBPROPOPTIONS_SETIFCHEAP is deprecated; use DBPROPOPTIONS_OPTIONAL instead.

enum DBPROPOPTIONSENUM
    {	DBPROPOPTIONS_REQUIRED	= 0,
	DBPROPOPTIONS_SETIFCHEAP	= 0x1,
	DBPROPOPTIONS_OPTIONAL	= 0x1
    };
typedef DWORD DBPROPSTATUS;


enum DBPROPSTATUSENUM
    {	DBPROPSTATUS_OK	= 0,
	DBPROPSTATUS_NOTSUPPORTED	= 1,
	DBPROPSTATUS_BADVALUE	= 2,
	DBPROPSTATUS_BADOPTION	= 3,
	DBPROPSTATUS_BADCOLUMN	= 4,
	DBPROPSTATUS_NOTALLSETTABLE	= 5,
	DBPROPSTATUS_NOTSETTABLE	= 6,
	DBPROPSTATUS_NOTSET	= 7,
	DBPROPSTATUS_CONFLICTING	= 8
    };

enum DBPROPSTATUSENUM21
    {	DBPROPSTATUS_NOTAVAILABLE	= 9
    };

#if defined(MIPSII_FP) || defined(MIPSIV) || defined(MIPSIV_FP)
#pragma pack(push,8)
#endif
typedef struct  tagDBPROP
    {
    DBPROPID dwPropertyID;
    DBPROPOPTIONS dwOptions;
    DBPROPSTATUS dwStatus;
    DBID colid;
    VARIANT vValue;
    }	DBPROP;
#if defined(MIPSII_FP) || defined(MIPSIV) || defined(MIPSIV_FP)
#pragma pack(pop)
#endif

typedef struct  tagDBPROPSET
    {
    /* [size_is] */ DBPROP __RPC_FAR *rgProperties;
    ULONG cProperties;
    GUID guidPropertySet;
    }	DBPROPSET;

#define DBPARAMTYPE_INPUT			0x01
#define DBPARAMTYPE_INPUTOUTPUT		0x02
#define DBPARAMTYPE_OUTPUT			0x03
#define DBPARAMTYPE_RETURNVALUE		0x04
#define DB_PT_UNKNOWN				0x01
#define DB_PT_PROCEDURE				0x02
#define DB_PT_FUNCTION				0x03
#define DB_REMOTE					0x01
#define DB_LOCAL_SHARED				0x02
#define DB_LOCAL_EXCLUSIVE			0x03
#define DB_COLLATION_ASC				0x01
#define DB_COLLATION_DESC			0x02
#define DB_UNSEARCHABLE				0x01
#define DB_LIKE_ONLY					0x02
#define DB_ALL_EXCEPT_LIKE			0x03
#define DB_SEARCHABLE				0x04

#define MDTREEOP_CHILDREN            0x01
#define MDTREEOP_SIBLINGS            0x02
#define MDTREEOP_PARENT              0x04
#define MDTREEOP_SELF                0x08
#define MDTREEOP_DESCENDANTS         0x10
#define MDTREEOP_ANCESTORS			0x20
#define MD_DIMTYPE_UNKNOWN           0x00
#define MD_DIMTYPE_TIME              0x01
#define MD_DIMTYPE_MEASURE           0x02
#define MD_DIMTYPE_OTHER             0x03
#define MDLEVEL_TYPE_UNKNOWN         0x0000
#define MDLEVEL_TYPE_REGULAR         0x0000
#define MDLEVEL_TYPE_ALL             0x0001
#define MDLEVEL_TYPE_CALCULATED      0x0002
#define MDLEVEL_TYPE_TIME            0x0004
#define MDLEVEL_TYPE_RESERVED1       0x0008
#define MDLEVEL_TYPE_TIME_YEARS      0x0014
#define MDLEVEL_TYPE_TIME_HALF_YEAR  0x0024
#define MDLEVEL_TYPE_TIME_QUARTERS   0x0044
#define MDLEVEL_TYPE_TIME_MONTHS     0x0084
#define MDLEVEL_TYPE_TIME_WEEKS      0x0104
#define MDLEVEL_TYPE_TIME_DAYS       0x0204
#define MDLEVEL_TYPE_TIME_HOURS      0x0304
#define MDLEVEL_TYPE_TIME_MINUTES    0x0404
#define MDLEVEL_TYPE_TIME_SECONDS    0x0804
#define MDLEVEL_TYPE_TIME_UNDEFINED  0x1004
#define MDMEASURE_AGGR_UNKNOWN       0x00
#define MDMEASURE_AGGR_SUM           0x01
#define MDMEASURE_AGGR_COUNT         0x02
#define MDMEASURE_AGGR_MIN           0x03
#define MDMEASURE_AGGR_MAX           0x04
#define MDMEASURE_AGGR_AVG           0x05
#define MDMEASURE_AGGR_VAR           0x06
#define MDMEASURE_AGGR_STD           0x07
#define MDMEASURE_AGGR_CALCULATED    0x7f
#define MDPROP_MEMBER                0x01
#define MDPROP_CELL                  0x02
#define MDMEMBER_TYPE_UNKNOWN        0x00
#define MDMEMBER_TYPE_REGULAR        0x01
#define MDMEMBER_TYPE_ALL            0x02
#define MDMEMBER_TYPE_MEASURE        0x03
#define MDMEMBER_TYPE_FORMULA        0x04
#define MDMEMBER_TYPE_RESERVE1       0x05
#define MDMEMBER_TYPE_RESERVE2       0x06
#define MDMEMBER_TYPE_RESERVE3       0x07
#define MDMEMBER_TYPE_RESERVE4       0x08
#define MDDISPINFO_DRILLED_DOWN				0x00010000
#define MDDISPINFO_PARENT_SAME_AS_PREV		0x00020000

typedef DWORD DBINDEX_COL_ORDER;


enum DBINDEX_COL_ORDERENUM
    {	DBINDEX_COL_ORDER_ASC	= 0,
	DBINDEX_COL_ORDER_DESC	= DBINDEX_COL_ORDER_ASC + 1
    };

typedef struct  tagDBINDEXCOLUMNDESC
    {
    DBID __RPC_FAR *pColumnID;
    DBINDEX_COL_ORDER eIndexColOrder;
    }	DBINDEXCOLUMNDESC;

typedef struct  tagDBCOLUMNDESC
    {
    LPOLESTR pwszTypeName;
    ITypeInfo __RPC_FAR *pTypeInfo;
    /* [size_is] */ DBPROPSET __RPC_FAR *rgPropertySets;
    CLSID __RPC_FAR *pclsid;
    ULONG cPropertySets;
    ULONG ulColumnSize;
    DBID dbcid;
    DBTYPE wType;
    BYTE bPrecision;
    BYTE bScale;
    }	DBCOLUMNDESC;

typedef struct  tagDBCOLUMNACCESS
    {
    void __RPC_FAR *pData;
    DBID columnid;
    ULONG cbDataLen;
    DBSTATUS dwStatus;
    ULONG cbMaxLen;
    DWORD dwReserved;
    DBTYPE wType;
    BYTE bPrecision;
    BYTE bScale;
    }	DBCOLUMNACCESS;

typedef DWORD DBCOLUMNDESCFLAGS;


enum DBCOLUMNDESCFLAGSENUM
    {	DBCOLUMNDESCFLAGS_TYPENAME	= 0x1,
	DBCOLUMNDESCFLAGS_ITYPEINFO	= 0x2,
	DBCOLUMNDESCFLAGS_PROPERTIES	= 0x4,
	DBCOLUMNDESCFLAGS_CLSID	= 0x8,
	DBCOLUMNDESCFLAGS_COLSIZE	= 0x10,
	DBCOLUMNDESCFLAGS_DBCID	= 0x20,
	DBCOLUMNDESCFLAGS_WTYPE	= 0x40,
	DBCOLUMNDESCFLAGS_PRECISION	= 0x80,
	DBCOLUMNDESCFLAGS_SCALE	= 0x100
    };

typedef DWORD DBEVENTPHASE;


enum DBEVENTPHASEENUM
    {	DBEVENTPHASE_OKTODO	= 0,
	DBEVENTPHASE_ABOUTTODO	= DBEVENTPHASE_OKTODO + 1,
	DBEVENTPHASE_SYNCHAFTER	= DBEVENTPHASE_ABOUTTODO + 1,
	DBEVENTPHASE_FAILEDTODO	= DBEVENTPHASE_SYNCHAFTER + 1,
	DBEVENTPHASE_DIDEVENT	= DBEVENTPHASE_FAILEDTODO + 1
    };
typedef DWORD DBREASON;


enum DBREASONENUM
    {	DBREASON_ROWSET_FETCHPOSITIONCHANGE	= 0,
	DBREASON_ROWSET_RELEASE	= DBREASON_ROWSET_FETCHPOSITIONCHANGE + 1,
	DBREASON_COLUMN_SET	= DBREASON_ROWSET_RELEASE + 1,
	DBREASON_COLUMN_RECALCULATED	= DBREASON_COLUMN_SET + 1,
	DBREASON_ROW_ACTIVATE	= DBREASON_COLUMN_RECALCULATED + 1,
	DBREASON_ROW_RELEASE	= DBREASON_ROW_ACTIVATE + 1,
	DBREASON_ROW_DELETE	= DBREASON_ROW_RELEASE + 1,
	DBREASON_ROW_FIRSTCHANGE	= DBREASON_ROW_DELETE + 1,
	DBREASON_ROW_INSERT	= DBREASON_ROW_FIRSTCHANGE + 1,
	DBREASON_ROW_RESYNCH	= DBREASON_ROW_INSERT + 1,
	DBREASON_ROW_UNDOCHANGE	= DBREASON_ROW_RESYNCH + 1,
	DBREASON_ROW_UNDOINSERT	= DBREASON_ROW_UNDOCHANGE + 1,
	DBREASON_ROW_UNDODELETE	= DBREASON_ROW_UNDOINSERT + 1,
	DBREASON_ROW_UPDATE	= DBREASON_ROW_UNDODELETE + 1,
	DBREASON_ROWSET_CHANGED	= DBREASON_ROW_UPDATE + 1
    };

enum DBREASONENUM15
    {	DBREASON_ROWPOSITION_CHANGED	= DBREASON_ROWSET_CHANGED + 1,
	DBREASON_ROWPOSITION_CHAPTERCHANGED	= DBREASON_ROWPOSITION_CHANGED + 1,
	DBREASON_ROWPOSITION_CLEARED	= DBREASON_ROWPOSITION_CHAPTERCHANGED + 1,
	DBREASON_ROW_ASYNCHINSERT	= DBREASON_ROWPOSITION_CLEARED + 1
    };

typedef DWORD DBCOMPAREOP;


enum DBCOMPAREOPSENUM
    {	DBCOMPAREOPS_LT	= 0,
	DBCOMPAREOPS_LE	= 1,
	DBCOMPAREOPS_EQ	= 2,
	DBCOMPAREOPS_GE	= 3,
	DBCOMPAREOPS_GT	= 4,
	DBCOMPAREOPS_BEGINSWITH	= 5,
	DBCOMPAREOPS_CONTAINS	= 6,
	DBCOMPAREOPS_NE	= 7,
	DBCOMPAREOPS_IGNORE	= 8,
	DBCOMPAREOPS_CASESENSITIVE	= 0x1000,
	DBCOMPAREOPS_CASEINSENSITIVE	= 0x2000
    };

enum DBCOMPAREOPSENUM20
    {	DBCOMPAREOPS_NOTBEGINSWITH	= 9,
	DBCOMPAREOPS_NOTCONTAINS	= 10
    };

typedef DWORD DBASYNCHOP;


enum DBASYNCHOPENUM
    {	DBASYNCHOP_OPEN	= 0
    };
typedef DWORD DBASYNCHPHASE;


enum DBASYNCHPHASEENUM
    {	DBASYNCHPHASE_INITIALIZATION	= 0,
	DBASYNCHPHASE_POPULATION	= DBASYNCHPHASE_INITIALIZATION + 1,
	DBASYNCHPHASE_COMPLETE	= DBASYNCHPHASE_POPULATION + 1,
	DBASYNCHPHASE_CANCELED	= DBASYNCHPHASE_COMPLETE + 1
    };
#define DB_COUNTUNAVAILABLE -1

typedef DWORD DBSORT;


enum DBSORTENUM
    {	DBSORT_ASCENDING	= 0,
	DBSORT_DESCENDING	= DBSORT_ASCENDING + 1
    };

typedef DWORD DBCOMMANDPERSISTFLAG;


enum DBCOMMANDPERSISTFLAGENUM
    {	DBCOMMANDPERSISTFLAG_NOSAVE	= 0x1
    };

enum DBCOMMANDPERSISTFLAGENUM21
    {	DBCOMMANDPERSISTFLAG_DEFAULT	= 0,
	DBCOMMANDPERSISTFLAG_PERSISTVIEW	= 0x2,
	DBCOMMANDPERSISTFLAG_PERSISTPROCEDURE	= 0x4
    };
typedef DWORD DBCONSTRAINTTYPE;


enum DBCONSTRAINTTYPEENUM
    {	DBCONSTRAINTTYPE_UNIQUE	= 0,
	DBCONSTRAINTTYPE_FOREIGNKEY	= 0x1,
	DBCONSTRAINTTYPE_PRIMARYKEY	= 0x2,
	DBCONSTRAINTTYPE_CHECK	= 0x3,
	DBCONSTRAINTTYPE_SSCE_DEFAULT = 0x4
    };
typedef DWORD DBUPDELRULE;


enum DBUPDELRULEENUM
    {	DBUPDELRULE_NOACTION	= 0,
	DBUPDELRULE_CASCADE	= 0x1,
	DBUPDELRULE_SETNULL	= 0x2,
	DBUPDELRULE_SETDEFAULT	= 0x3
    };
typedef DWORD DBMATCHTYPE;


enum DBMATCHTYPEENUM
    {	DBMATCHTYPE_FULL	= 0,
	DBMATCHTYPE_NONE	= 0x1,
	DBMATCHTYPE_PARTIAL	= 0x2
    };
typedef DWORD DBDEFERRABILITY;


enum DBDEFERRABILITYENUM
    {	DBDEFERRABILITY_DEFERRED	= 0x1,
	DBDEFERRABILITY_DEFERRABLE	= 0x2
    };
typedef struct  tagDBCONSTRAINTDESC
    {
    DBID __RPC_FAR *pConstraintID;
    DBCONSTRAINTTYPE ConstraintType;
    ULONG cColumns;
    /* [size_is] */ DBID __RPC_FAR *rgColumnList;
    DBID __RPC_FAR *pReferencedTableID;
    ULONG cForeignKeyColumns;
    /* [size_is] */ DBID __RPC_FAR *rgForeignKeyColumnList;
    OLECHAR __RPC_FAR *pwszConstraintText;
    DBUPDELRULE UpdateRule;
    DBUPDELRULE DeleteRule;
    DBMATCHTYPE MatchType;
    DBDEFERRABILITY Deferrability;
    ULONG cReserved;
    /* [size_is] */ DBPROPSET __RPC_FAR *rgReserved;
    }	DBCONSTRAINTDESC;

#define MDFF_BOLD                    0x01
#define MDFF_ITALIC                  0x02
#define MDFF_UNDERLINE               0x04
#define MDFF_STRIKEOUT               0x08
typedef struct  tagMDAXISINFO
    {
    ULONG cbSize;
    ULONG iAxis;
    ULONG cDimensions;
    ULONG cCoordinates;
    ULONG __RPC_FAR *rgcColumns;
    LPOLESTR __RPC_FAR *rgpwszDimensionNames;
    }	MDAXISINFO;

#define PMDAXISINFO_GETAT(rgAxisInfo, iAxis) ((MDAXISINFO *)(((BYTE *)(rgAxisInfo)) +((iAxis) * (rgAxisInfo)[0].cbSize)))
#define MDAXISINFO_GETAT(rgAxisInfo, iAxis) (*PMDAXISINFO_GETAT((rgAxisInfo), (iAxis)))
#define MDAXIS_COLUMNS               0x00000000
#define MDAXIS_ROWS                  0x00000001
#define MDAXIS_PAGES                 0x00000002
#define MDAXIS_SECTIONS              0x00000003
#define MDAXIS_CHAPTERS              0x00000004
#define MDAXIS_SLICERS               0xffffffff

extern RPC_IF_HANDLE DBStructureDefinitions_v0_0_c_ifspec;
extern RPC_IF_HANDLE DBStructureDefinitions_v0_0_s_ifspec;
#endif /* __DBStructureDefinitions_INTERFACE_DEFINED__ */

#ifndef __IAccessor_INTERFACE_DEFINED__
#define __IAccessor_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: IAccessor
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object] */ 


typedef DWORD DBACCESSORFLAGS;


enum DBACCESSORFLAGSENUM
    {	DBACCESSOR_INVALID	= 0,
	DBACCESSOR_PASSBYREF	= 0x1,
	DBACCESSOR_ROWDATA	= 0x2,
	DBACCESSOR_PARAMETERDATA	= 0x4,
	DBACCESSOR_OPTIMIZED	= 0x8,
	DBACCESSOR_INHERITED	= 0x10
    };
typedef DWORD DBBINDSTATUS;


enum DBBINDSTATUSENUM
    {	DBBINDSTATUS_OK	= 0,
	DBBINDSTATUS_BADORDINAL	= 1,
	DBBINDSTATUS_UNSUPPORTEDCONVERSION	= 2,
	DBBINDSTATUS_BADBINDINFO	= 3,
	DBBINDSTATUS_BADSTORAGEFLAGS	= 4,
	DBBINDSTATUS_NOINTERFACE	= 5,
	DBBINDSTATUS_MULTIPLESTORAGE	= 6
    };

EXTERN_C const IID IID_IAccessor;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733a8c-2a1c-11ce-ade5-00aa0044773d")
    IAccessor : public IUnknown
    {
    public:
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE AddRefAccessor( 
            /* [in] */ HACCESSOR hAccessor,
            /* [unique][out][in] */ ULONG __RPC_FAR *pcRefCount) = 0;
        
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE CreateAccessor( 
            /* [in] */ DBACCESSORFLAGS dwAccessorFlags,
            /* [in] */ ULONG cBindings,
            /* [size_is][in] */ const DBBINDING __RPC_FAR rgBindings[  ],
            /* [in] */ ULONG cbRowSize,
            /* [out] */ HACCESSOR __RPC_FAR *phAccessor,
            /* [size_is][out] */ DBBINDSTATUS __RPC_FAR rgStatus[  ]) = 0;
        
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetBindings( 
            /* [in] */ HACCESSOR hAccessor,
            /* [out] */ DBACCESSORFLAGS __RPC_FAR *pdwAccessorFlags,
            /* [out][in] */ ULONG __RPC_FAR *pcBindings,
            /* [size_is][size_is][out] */ DBBINDING __RPC_FAR *__RPC_FAR *prgBindings) = 0;
        
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE ReleaseAccessor( 
            /* [in] */ HACCESSOR hAccessor,
            /* [unique][out][in] */ ULONG __RPC_FAR *pcRefCount) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct IAccessorVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            IAccessor __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            IAccessor __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            IAccessor __RPC_FAR * This);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *AddRefAccessor )( 
            IAccessor __RPC_FAR * This,
            /* [in] */ HACCESSOR hAccessor,
            /* [unique][out][in] */ ULONG __RPC_FAR *pcRefCount);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *CreateAccessor )( 
            IAccessor __RPC_FAR * This,
            /* [in] */ DBACCESSORFLAGS dwAccessorFlags,
            /* [in] */ ULONG cBindings,
            /* [size_is][in] */ const DBBINDING __RPC_FAR rgBindings[  ],
            /* [in] */ ULONG cbRowSize,
            /* [out] */ HACCESSOR __RPC_FAR *phAccessor,
            /* [size_is][out] */ DBBINDSTATUS __RPC_FAR rgStatus[  ]);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetBindings )( 
            IAccessor __RPC_FAR * This,
            /* [in] */ HACCESSOR hAccessor,
            /* [out] */ DBACCESSORFLAGS __RPC_FAR *pdwAccessorFlags,
            /* [out][in] */ ULONG __RPC_FAR *pcBindings,
            /* [size_is][size_is][out] */ DBBINDING __RPC_FAR *__RPC_FAR *prgBindings);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *ReleaseAccessor )( 
            IAccessor __RPC_FAR * This,
            /* [in] */ HACCESSOR hAccessor,
            /* [unique][out][in] */ ULONG __RPC_FAR *pcRefCount);
        
        END_INTERFACE
    } IAccessorVtbl;

    interface IAccessor
    {
        CONST_VTBL struct IAccessorVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define IAccessor_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define IAccessor_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define IAccessor_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define IAccessor_AddRefAccessor(This,hAccessor,pcRefCount)	\
    (This)->lpVtbl -> AddRefAccessor(This,hAccessor,pcRefCount)

#define IAccessor_CreateAccessor(This,dwAccessorFlags,cBindings,rgBindings,cbRowSize,phAccessor,rgStatus)	\
    (This)->lpVtbl -> CreateAccessor(This,dwAccessorFlags,cBindings,rgBindings,cbRowSize,phAccessor,rgStatus)

#define IAccessor_GetBindings(This,hAccessor,pdwAccessorFlags,pcBindings,prgBindings)	\
    (This)->lpVtbl -> GetBindings(This,hAccessor,pdwAccessorFlags,pcBindings,prgBindings)

#define IAccessor_ReleaseAccessor(This,hAccessor,pcRefCount)	\
    (This)->lpVtbl -> ReleaseAccessor(This,hAccessor,pcRefCount)

#endif /* COBJMACROS */


#endif 	/* C style interface */



/* [call_as] */ HRESULT STDMETHODCALLTYPE IAccessor_RemoteAddRefAccessor_Proxy( 
    IAccessor __RPC_FAR * This,
    /* [in] */ HACCESSOR hAccessor,
    /* [unique][out][in] */ ULONG __RPC_FAR *pcRefCount,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IAccessor_RemoteAddRefAccessor_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IAccessor_RemoteCreateAccessor_Proxy( 
    IAccessor __RPC_FAR * This,
    /* [in] */ DBACCESSORFLAGS dwAccessorFlags,
    /* [in] */ ULONG cBindings,
    /* [size_is][unique][in] */ DBBINDING __RPC_FAR *rgBindings,
    /* [in] */ ULONG cbRowSize,
    /* [out] */ HACCESSOR __RPC_FAR *phAccessor,
    /* [size_is][unique][out][in] */ DBBINDSTATUS __RPC_FAR *rgStatus,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IAccessor_RemoteCreateAccessor_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IAccessor_RemoteGetBindings_Proxy( 
    IAccessor __RPC_FAR * This,
    /* [in] */ HACCESSOR hAccessor,
    /* [out] */ DBACCESSORFLAGS __RPC_FAR *pdwAccessorFlags,
    /* [out][in] */ ULONG __RPC_FAR *pcBindings,
    /* [size_is][size_is][out] */ DBBINDING __RPC_FAR *__RPC_FAR *prgBindings,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IAccessor_RemoteGetBindings_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IAccessor_RemoteReleaseAccessor_Proxy( 
    IAccessor __RPC_FAR * This,
    /* [in] */ HACCESSOR hAccessor,
    /* [unique][out][in] */ ULONG __RPC_FAR *pcRefCount,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IAccessor_RemoteReleaseAccessor_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __IAccessor_INTERFACE_DEFINED__ */


#ifndef __IRowset_INTERFACE_DEFINED__
#define __IRowset_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: IRowset
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object][local] */ 


typedef DWORD DBROWOPTIONS;


EXTERN_C const IID IID_IRowset;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733a7c-2a1c-11ce-ade5-00aa0044773d")
    IRowset : public IUnknown
    {
    public:
        virtual HRESULT STDMETHODCALLTYPE AddRefRows( 
            /* [in] */ ULONG cRows,
            /* [size_is][in] */ const HROW __RPC_FAR rghRows[  ],
            /* [size_is][out] */ ULONG __RPC_FAR rgRefCounts[  ],
            /* [size_is][out] */ DBROWSTATUS __RPC_FAR rgRowStatus[  ]) = 0;
        
        virtual HRESULT STDMETHODCALLTYPE GetData( 
            /* [in] */ HROW hRow,
            /* [in] */ HACCESSOR hAccessor,
            /* [out] */ void __RPC_FAR *pData) = 0;
        
        virtual HRESULT STDMETHODCALLTYPE GetNextRows( 
            /* [in] */ HCHAPTER hReserved,
            /* [in] */ LONG lRowsOffset,
            /* [in] */ LONG cRows,
            /* [out] */ ULONG __RPC_FAR *pcRowsObtained,
            /* [size_is][size_is][out] */ HROW __RPC_FAR *__RPC_FAR *prghRows) = 0;
        
        virtual HRESULT STDMETHODCALLTYPE ReleaseRows( 
            /* [in] */ ULONG cRows,
            /* [size_is][in] */ const HROW __RPC_FAR rghRows[  ],
            /* [size_is][in] */ DBROWOPTIONS __RPC_FAR rgRowOptions[  ],
            /* [size_is][out] */ ULONG __RPC_FAR rgRefCounts[  ],
            /* [size_is][out] */ DBROWSTATUS __RPC_FAR rgRowStatus[  ]) = 0;
        
        virtual HRESULT STDMETHODCALLTYPE RestartPosition( 
            /* [in] */ HCHAPTER hReserved) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct IRowsetVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            IRowset __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            IRowset __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            IRowset __RPC_FAR * This);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *AddRefRows )( 
            IRowset __RPC_FAR * This,
            /* [in] */ ULONG cRows,
            /* [size_is][in] */ const HROW __RPC_FAR rghRows[  ],
            /* [size_is][out] */ ULONG __RPC_FAR rgRefCounts[  ],
            /* [size_is][out] */ DBROWSTATUS __RPC_FAR rgRowStatus[  ]);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetData )( 
            IRowset __RPC_FAR * This,
            /* [in] */ HROW hRow,
            /* [in] */ HACCESSOR hAccessor,
            /* [out] */ void __RPC_FAR *pData);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetNextRows )( 
            IRowset __RPC_FAR * This,
            /* [in] */ HCHAPTER hReserved,
            /* [in] */ LONG lRowsOffset,
            /* [in] */ LONG cRows,
            /* [out] */ ULONG __RPC_FAR *pcRowsObtained,
            /* [size_is][size_is][out] */ HROW __RPC_FAR *__RPC_FAR *prghRows);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *ReleaseRows )( 
            IRowset __RPC_FAR * This,
            /* [in] */ ULONG cRows,
            /* [size_is][in] */ const HROW __RPC_FAR rghRows[  ],
            /* [size_is][in] */ DBROWOPTIONS __RPC_FAR rgRowOptions[  ],
            /* [size_is][out] */ ULONG __RPC_FAR rgRefCounts[  ],
            /* [size_is][out] */ DBROWSTATUS __RPC_FAR rgRowStatus[  ]);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *RestartPosition )( 
            IRowset __RPC_FAR * This,
            /* [in] */ HCHAPTER hReserved);
        
        END_INTERFACE
    } IRowsetVtbl;

    interface IRowset
    {
        CONST_VTBL struct IRowsetVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define IRowset_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define IRowset_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define IRowset_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define IRowset_AddRefRows(This,cRows,rghRows,rgRefCounts,rgRowStatus)	\
    (This)->lpVtbl -> AddRefRows(This,cRows,rghRows,rgRefCounts,rgRowStatus)

#define IRowset_GetData(This,hRow,hAccessor,pData)	\
    (This)->lpVtbl -> GetData(This,hRow,hAccessor,pData)

#define IRowset_GetNextRows(This,hReserved,lRowsOffset,cRows,pcRowsObtained,prghRows)	\
    (This)->lpVtbl -> GetNextRows(This,hReserved,lRowsOffset,cRows,pcRowsObtained,prghRows)

#define IRowset_ReleaseRows(This,cRows,rghRows,rgRowOptions,rgRefCounts,rgRowStatus)	\
    (This)->lpVtbl -> ReleaseRows(This,cRows,rghRows,rgRowOptions,rgRefCounts,rgRowStatus)

#define IRowset_RestartPosition(This,hReserved)	\
    (This)->lpVtbl -> RestartPosition(This,hReserved)

#endif /* COBJMACROS */


#endif 	/* C style interface */



HRESULT STDMETHODCALLTYPE IRowset_AddRefRows_Proxy( 
    IRowset __RPC_FAR * This,
    /* [in] */ ULONG cRows,
    /* [size_is][in] */ const HROW __RPC_FAR rghRows[  ],
    /* [size_is][out] */ ULONG __RPC_FAR rgRefCounts[  ],
    /* [size_is][out] */ DBROWSTATUS __RPC_FAR rgRowStatus[  ]);


void __RPC_STUB IRowset_AddRefRows_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


HRESULT STDMETHODCALLTYPE IRowset_GetData_Proxy( 
    IRowset __RPC_FAR * This,
    /* [in] */ HROW hRow,
    /* [in] */ HACCESSOR hAccessor,
    /* [out] */ void __RPC_FAR *pData);


void __RPC_STUB IRowset_GetData_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


HRESULT STDMETHODCALLTYPE IRowset_GetNextRows_Proxy( 
    IRowset __RPC_FAR * This,
    /* [in] */ HCHAPTER hReserved,
    /* [in] */ LONG lRowsOffset,
    /* [in] */ LONG cRows,
    /* [out] */ ULONG __RPC_FAR *pcRowsObtained,
    /* [size_is][size_is][out] */ HROW __RPC_FAR *__RPC_FAR *prghRows);


void __RPC_STUB IRowset_GetNextRows_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


HRESULT STDMETHODCALLTYPE IRowset_ReleaseRows_Proxy( 
    IRowset __RPC_FAR * This,
    /* [in] */ ULONG cRows,
    /* [size_is][in] */ const HROW __RPC_FAR rghRows[  ],
    /* [size_is][in] */ DBROWOPTIONS __RPC_FAR rgRowOptions[  ],
    /* [size_is][out] */ ULONG __RPC_FAR rgRefCounts[  ],
    /* [size_is][out] */ DBROWSTATUS __RPC_FAR rgRowStatus[  ]);


void __RPC_STUB IRowset_ReleaseRows_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


HRESULT STDMETHODCALLTYPE IRowset_RestartPosition_Proxy( 
    IRowset __RPC_FAR * This,
    /* [in] */ HCHAPTER hReserved);


void __RPC_STUB IRowset_RestartPosition_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __IRowset_INTERFACE_DEFINED__ */


#ifndef __IRowsetInfo_INTERFACE_DEFINED__
#define __IRowsetInfo_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: IRowsetInfo
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object] */ 



EXTERN_C const IID IID_IRowsetInfo;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733a55-2a1c-11ce-ade5-00aa0044773d")
    IRowsetInfo : public IUnknown
    {
    public:
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetProperties( 
            /* [in] */ const ULONG cPropertyIDSets,
            /* [size_is][in] */ const DBPROPIDSET __RPC_FAR rgPropertyIDSets[  ],
            /* [out][in] */ ULONG __RPC_FAR *pcPropertySets,
            /* [size_is][size_is][out] */ DBPROPSET __RPC_FAR *__RPC_FAR *prgPropertySets) = 0;
        
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetReferencedRowset( 
            /* [in] */ ULONG iOrdinal,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppReferencedRowset) = 0;
        
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetSpecification( 
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppSpecification) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct IRowsetInfoVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            IRowsetInfo __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            IRowsetInfo __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            IRowsetInfo __RPC_FAR * This);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetProperties )( 
            IRowsetInfo __RPC_FAR * This,
            /* [in] */ const ULONG cPropertyIDSets,
            /* [size_is][in] */ const DBPROPIDSET __RPC_FAR rgPropertyIDSets[  ],
            /* [out][in] */ ULONG __RPC_FAR *pcPropertySets,
            /* [size_is][size_is][out] */ DBPROPSET __RPC_FAR *__RPC_FAR *prgPropertySets);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetReferencedRowset )( 
            IRowsetInfo __RPC_FAR * This,
            /* [in] */ ULONG iOrdinal,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppReferencedRowset);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetSpecification )( 
            IRowsetInfo __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppSpecification);
        
        END_INTERFACE
    } IRowsetInfoVtbl;

    interface IRowsetInfo
    {
        CONST_VTBL struct IRowsetInfoVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define IRowsetInfo_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define IRowsetInfo_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define IRowsetInfo_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define IRowsetInfo_GetProperties(This,cPropertyIDSets,rgPropertyIDSets,pcPropertySets,prgPropertySets)	\
    (This)->lpVtbl -> GetProperties(This,cPropertyIDSets,rgPropertyIDSets,pcPropertySets,prgPropertySets)

#define IRowsetInfo_GetReferencedRowset(This,iOrdinal,riid,ppReferencedRowset)	\
    (This)->lpVtbl -> GetReferencedRowset(This,iOrdinal,riid,ppReferencedRowset)

#define IRowsetInfo_GetSpecification(This,riid,ppSpecification)	\
    (This)->lpVtbl -> GetSpecification(This,riid,ppSpecification)

#endif /* COBJMACROS */


#endif 	/* C style interface */



/* [call_as] */ HRESULT STDMETHODCALLTYPE IRowsetInfo_RemoteGetProperties_Proxy( 
    IRowsetInfo __RPC_FAR * This,
    /* [in] */ ULONG cPropertyIDSets,
    /* [size_is][unique][in] */ const DBPROPIDSET __RPC_FAR *rgPropertyIDSets,
    /* [out][in] */ ULONG __RPC_FAR *pcPropertySets,
    /* [size_is][size_is][out] */ DBPROPSET __RPC_FAR *__RPC_FAR *prgPropertySets,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IRowsetInfo_RemoteGetProperties_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IRowsetInfo_RemoteGetReferencedRowset_Proxy( 
    IRowsetInfo __RPC_FAR * This,
    /* [in] */ ULONG iOrdinal,
    /* [in] */ REFIID riid,
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppReferencedRowset,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IRowsetInfo_RemoteGetReferencedRowset_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IRowsetInfo_RemoteGetSpecification_Proxy( 
    IRowsetInfo __RPC_FAR * This,
    /* [in] */ REFIID riid,
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppSpecification,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IRowsetInfo_RemoteGetSpecification_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __IRowsetInfo_INTERFACE_DEFINED__ */


#ifndef __IRowsetLocate_INTERFACE_DEFINED__
#define __IRowsetLocate_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: IRowsetLocate
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object][local] */ 


typedef DWORD DBCOMPARE;


enum DBCOMPAREENUM
    {	DBCOMPARE_LT	= 0,
	DBCOMPARE_EQ	= DBCOMPARE_LT + 1,
	DBCOMPARE_GT	= DBCOMPARE_EQ + 1,
	DBCOMPARE_NE	= DBCOMPARE_GT + 1,
	DBCOMPARE_NOTCOMPARABLE	= DBCOMPARE_NE + 1
    };

EXTERN_C const IID IID_IRowsetLocate;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733a7d-2a1c-11ce-ade5-00aa0044773d")
    IRowsetLocate : public IRowset
    {
    public:
        virtual HRESULT STDMETHODCALLTYPE Compare( 
            /* [in] */ HCHAPTER hReserved,
            /* [in] */ ULONG cbBookmark1,
            /* [size_is][in] */ const BYTE __RPC_FAR *pBookmark1,
            /* [in] */ ULONG cbBookmark2,
            /* [size_is][in] */ const BYTE __RPC_FAR *pBookmark2,
            /* [out] */ DBCOMPARE __RPC_FAR *pComparison) = 0;
        
        virtual HRESULT STDMETHODCALLTYPE GetRowsAt( 
            /* [in] */ HWATCHREGION hReserved1,
            /* [in] */ HCHAPTER hReserved2,
            /* [in] */ ULONG cbBookmark,
            /* [size_is][in] */ const BYTE __RPC_FAR *pBookmark,
            /* [in] */ LONG lRowsOffset,
            /* [in] */ LONG cRows,
            /* [out] */ ULONG __RPC_FAR *pcRowsObtained,
            /* [size_is][size_is][out] */ HROW __RPC_FAR *__RPC_FAR *prghRows) = 0;
        
        virtual HRESULT STDMETHODCALLTYPE GetRowsByBookmark( 
            /* [in] */ HCHAPTER hReserved,
            /* [in] */ ULONG cRows,
            /* [size_is][in] */ const ULONG __RPC_FAR rgcbBookmarks[  ],
            /* [size_is][in] */ const BYTE __RPC_FAR *__RPC_FAR rgpBookmarks[  ],
            /* [size_is][out] */ HROW __RPC_FAR rghRows[  ],
            /* [size_is][out] */ DBROWSTATUS __RPC_FAR rgRowStatus[  ]) = 0;
        
        virtual HRESULT STDMETHODCALLTYPE Hash( 
            /* [in] */ HCHAPTER hReserved,
            /* [in] */ ULONG cBookmarks,
            /* [size_is][in] */ const ULONG __RPC_FAR rgcbBookmarks[  ],
            /* [size_is][in] */ const BYTE __RPC_FAR *__RPC_FAR rgpBookmarks[  ],
            /* [size_is][out] */ DWORD __RPC_FAR rgHashedValues[  ],
            /* [size_is][out] */ DBROWSTATUS __RPC_FAR rgBookmarkStatus[  ]) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct IRowsetLocateVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            IRowsetLocate __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            IRowsetLocate __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            IRowsetLocate __RPC_FAR * This);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *AddRefRows )( 
            IRowsetLocate __RPC_FAR * This,
            /* [in] */ ULONG cRows,
            /* [size_is][in] */ const HROW __RPC_FAR rghRows[  ],
            /* [size_is][out] */ ULONG __RPC_FAR rgRefCounts[  ],
            /* [size_is][out] */ DBROWSTATUS __RPC_FAR rgRowStatus[  ]);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetData )( 
            IRowsetLocate __RPC_FAR * This,
            /* [in] */ HROW hRow,
            /* [in] */ HACCESSOR hAccessor,
            /* [out] */ void __RPC_FAR *pData);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetNextRows )( 
            IRowsetLocate __RPC_FAR * This,
            /* [in] */ HCHAPTER hReserved,
            /* [in] */ LONG lRowsOffset,
            /* [in] */ LONG cRows,
            /* [out] */ ULONG __RPC_FAR *pcRowsObtained,
            /* [size_is][size_is][out] */ HROW __RPC_FAR *__RPC_FAR *prghRows);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *ReleaseRows )( 
            IRowsetLocate __RPC_FAR * This,
            /* [in] */ ULONG cRows,
            /* [size_is][in] */ const HROW __RPC_FAR rghRows[  ],
            /* [size_is][in] */ DBROWOPTIONS __RPC_FAR rgRowOptions[  ],
            /* [size_is][out] */ ULONG __RPC_FAR rgRefCounts[  ],
            /* [size_is][out] */ DBROWSTATUS __RPC_FAR rgRowStatus[  ]);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *RestartPosition )( 
            IRowsetLocate __RPC_FAR * This,
            /* [in] */ HCHAPTER hReserved);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Compare )( 
            IRowsetLocate __RPC_FAR * This,
            /* [in] */ HCHAPTER hReserved,
            /* [in] */ ULONG cbBookmark1,
            /* [size_is][in] */ const BYTE __RPC_FAR *pBookmark1,
            /* [in] */ ULONG cbBookmark2,
            /* [size_is][in] */ const BYTE __RPC_FAR *pBookmark2,
            /* [out] */ DBCOMPARE __RPC_FAR *pComparison);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetRowsAt )( 
            IRowsetLocate __RPC_FAR * This,
            /* [in] */ HWATCHREGION hReserved1,
            /* [in] */ HCHAPTER hReserved2,
            /* [in] */ ULONG cbBookmark,
            /* [size_is][in] */ const BYTE __RPC_FAR *pBookmark,
            /* [in] */ LONG lRowsOffset,
            /* [in] */ LONG cRows,
            /* [out] */ ULONG __RPC_FAR *pcRowsObtained,
            /* [size_is][size_is][out] */ HROW __RPC_FAR *__RPC_FAR *prghRows);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetRowsByBookmark )( 
            IRowsetLocate __RPC_FAR * This,
            /* [in] */ HCHAPTER hReserved,
            /* [in] */ ULONG cRows,
            /* [size_is][in] */ const ULONG __RPC_FAR rgcbBookmarks[  ],
            /* [size_is][in] */ const BYTE __RPC_FAR *__RPC_FAR rgpBookmarks[  ],
            /* [size_is][out] */ HROW __RPC_FAR rghRows[  ],
            /* [size_is][out] */ DBROWSTATUS __RPC_FAR rgRowStatus[  ]);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Hash )( 
            IRowsetLocate __RPC_FAR * This,
            /* [in] */ HCHAPTER hReserved,
            /* [in] */ ULONG cBookmarks,
            /* [size_is][in] */ const ULONG __RPC_FAR rgcbBookmarks[  ],
            /* [size_is][in] */ const BYTE __RPC_FAR *__RPC_FAR rgpBookmarks[  ],
            /* [size_is][out] */ DWORD __RPC_FAR rgHashedValues[  ],
            /* [size_is][out] */ DBROWSTATUS __RPC_FAR rgBookmarkStatus[  ]);
        
        END_INTERFACE
    } IRowsetLocateVtbl;

    interface IRowsetLocate
    {
        CONST_VTBL struct IRowsetLocateVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define IRowsetLocate_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define IRowsetLocate_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define IRowsetLocate_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define IRowsetLocate_AddRefRows(This,cRows,rghRows,rgRefCounts,rgRowStatus)	\
    (This)->lpVtbl -> AddRefRows(This,cRows,rghRows,rgRefCounts,rgRowStatus)

#define IRowsetLocate_GetData(This,hRow,hAccessor,pData)	\
    (This)->lpVtbl -> GetData(This,hRow,hAccessor,pData)

#define IRowsetLocate_GetNextRows(This,hReserved,lRowsOffset,cRows,pcRowsObtained,prghRows)	\
    (This)->lpVtbl -> GetNextRows(This,hReserved,lRowsOffset,cRows,pcRowsObtained,prghRows)

#define IRowsetLocate_ReleaseRows(This,cRows,rghRows,rgRowOptions,rgRefCounts,rgRowStatus)	\
    (This)->lpVtbl -> ReleaseRows(This,cRows,rghRows,rgRowOptions,rgRefCounts,rgRowStatus)

#define IRowsetLocate_RestartPosition(This,hReserved)	\
    (This)->lpVtbl -> RestartPosition(This,hReserved)


#define IRowsetLocate_Compare(This,hReserved,cbBookmark1,pBookmark1,cbBookmark2,pBookmark2,pComparison)	\
    (This)->lpVtbl -> Compare(This,hReserved,cbBookmark1,pBookmark1,cbBookmark2,pBookmark2,pComparison)

#define IRowsetLocate_GetRowsAt(This,hReserved1,hReserved2,cbBookmark,pBookmark,lRowsOffset,cRows,pcRowsObtained,prghRows)	\
    (This)->lpVtbl -> GetRowsAt(This,hReserved1,hReserved2,cbBookmark,pBookmark,lRowsOffset,cRows,pcRowsObtained,prghRows)

#define IRowsetLocate_GetRowsByBookmark(This,hReserved,cRows,rgcbBookmarks,rgpBookmarks,rghRows,rgRowStatus)	\
    (This)->lpVtbl -> GetRowsByBookmark(This,hReserved,cRows,rgcbBookmarks,rgpBookmarks,rghRows,rgRowStatus)

#define IRowsetLocate_Hash(This,hReserved,cBookmarks,rgcbBookmarks,rgpBookmarks,rgHashedValues,rgBookmarkStatus)	\
    (This)->lpVtbl -> Hash(This,hReserved,cBookmarks,rgcbBookmarks,rgpBookmarks,rgHashedValues,rgBookmarkStatus)

#endif /* COBJMACROS */


#endif 	/* C style interface */



HRESULT STDMETHODCALLTYPE IRowsetLocate_Compare_Proxy( 
    IRowsetLocate __RPC_FAR * This,
    /* [in] */ HCHAPTER hReserved,
    /* [in] */ ULONG cbBookmark1,
    /* [size_is][in] */ const BYTE __RPC_FAR *pBookmark1,
    /* [in] */ ULONG cbBookmark2,
    /* [size_is][in] */ const BYTE __RPC_FAR *pBookmark2,
    /* [out] */ DBCOMPARE __RPC_FAR *pComparison);


void __RPC_STUB IRowsetLocate_Compare_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


HRESULT STDMETHODCALLTYPE IRowsetLocate_GetRowsAt_Proxy( 
    IRowsetLocate __RPC_FAR * This,
    /* [in] */ HWATCHREGION hReserved1,
    /* [in] */ HCHAPTER hReserved2,
    /* [in] */ ULONG cbBookmark,
    /* [size_is][in] */ const BYTE __RPC_FAR *pBookmark,
    /* [in] */ LONG lRowsOffset,
    /* [in] */ LONG cRows,
    /* [out] */ ULONG __RPC_FAR *pcRowsObtained,
    /* [size_is][size_is][out] */ HROW __RPC_FAR *__RPC_FAR *prghRows);


void __RPC_STUB IRowsetLocate_GetRowsAt_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


HRESULT STDMETHODCALLTYPE IRowsetLocate_GetRowsByBookmark_Proxy( 
    IRowsetLocate __RPC_FAR * This,
    /* [in] */ HCHAPTER hReserved,
    /* [in] */ ULONG cRows,
    /* [size_is][in] */ const ULONG __RPC_FAR rgcbBookmarks[  ],
    /* [size_is][in] */ const BYTE __RPC_FAR *__RPC_FAR rgpBookmarks[  ],
    /* [size_is][out] */ HROW __RPC_FAR rghRows[  ],
    /* [size_is][out] */ DBROWSTATUS __RPC_FAR rgRowStatus[  ]);


void __RPC_STUB IRowsetLocate_GetRowsByBookmark_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


HRESULT STDMETHODCALLTYPE IRowsetLocate_Hash_Proxy( 
    IRowsetLocate __RPC_FAR * This,
    /* [in] */ HCHAPTER hReserved,
    /* [in] */ ULONG cBookmarks,
    /* [size_is][in] */ const ULONG __RPC_FAR rgcbBookmarks[  ],
    /* [size_is][in] */ const BYTE __RPC_FAR *__RPC_FAR rgpBookmarks[  ],
    /* [size_is][out] */ DWORD __RPC_FAR rgHashedValues[  ],
    /* [size_is][out] */ DBROWSTATUS __RPC_FAR rgBookmarkStatus[  ]);


void __RPC_STUB IRowsetLocate_Hash_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __IRowsetLocate_INTERFACE_DEFINED__ */


#ifndef __IRowsetResynch_INTERFACE_DEFINED__
#define __IRowsetResynch_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: IRowsetResynch
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object][local] */ 



EXTERN_C const IID IID_IRowsetResynch;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733a84-2a1c-11ce-ade5-00aa0044773d")
    IRowsetResynch : public IUnknown
    {
    public:
        virtual HRESULT STDMETHODCALLTYPE GetVisibleData( 
            /* [in] */ HROW hRow,
            /* [in] */ HACCESSOR hAccessor,
            /* [out] */ void __RPC_FAR *pData) = 0;
        
        virtual HRESULT STDMETHODCALLTYPE ResynchRows( 
            /* [in] */ ULONG cRows,
            /* [size_is][in] */ const HROW __RPC_FAR rghRows[  ],
            /* [out] */ ULONG __RPC_FAR *pcRowsResynched,
            /* [size_is][size_is][out] */ HROW __RPC_FAR *__RPC_FAR *prghRowsResynched,
            /* [size_is][size_is][out] */ DBROWSTATUS __RPC_FAR *__RPC_FAR *prgRowStatus) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct IRowsetResynchVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            IRowsetResynch __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            IRowsetResynch __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            IRowsetResynch __RPC_FAR * This);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetVisibleData )( 
            IRowsetResynch __RPC_FAR * This,
            /* [in] */ HROW hRow,
            /* [in] */ HACCESSOR hAccessor,
            /* [out] */ void __RPC_FAR *pData);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *ResynchRows )( 
            IRowsetResynch __RPC_FAR * This,
            /* [in] */ ULONG cRows,
            /* [size_is][in] */ const HROW __RPC_FAR rghRows[  ],
            /* [out] */ ULONG __RPC_FAR *pcRowsResynched,
            /* [size_is][size_is][out] */ HROW __RPC_FAR *__RPC_FAR *prghRowsResynched,
            /* [size_is][size_is][out] */ DBROWSTATUS __RPC_FAR *__RPC_FAR *prgRowStatus);
        
        END_INTERFACE
    } IRowsetResynchVtbl;

    interface IRowsetResynch
    {
        CONST_VTBL struct IRowsetResynchVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define IRowsetResynch_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define IRowsetResynch_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define IRowsetResynch_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define IRowsetResynch_GetVisibleData(This,hRow,hAccessor,pData)	\
    (This)->lpVtbl -> GetVisibleData(This,hRow,hAccessor,pData)

#define IRowsetResynch_ResynchRows(This,cRows,rghRows,pcRowsResynched,prghRowsResynched,prgRowStatus)	\
    (This)->lpVtbl -> ResynchRows(This,cRows,rghRows,pcRowsResynched,prghRowsResynched,prgRowStatus)

#endif /* COBJMACROS */


#endif 	/* C style interface */



HRESULT STDMETHODCALLTYPE IRowsetResynch_GetVisibleData_Proxy( 
    IRowsetResynch __RPC_FAR * This,
    /* [in] */ HROW hRow,
    /* [in] */ HACCESSOR hAccessor,
    /* [out] */ void __RPC_FAR *pData);


void __RPC_STUB IRowsetResynch_GetVisibleData_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


HRESULT STDMETHODCALLTYPE IRowsetResynch_ResynchRows_Proxy( 
    IRowsetResynch __RPC_FAR * This,
    /* [in] */ ULONG cRows,
    /* [size_is][in] */ const HROW __RPC_FAR rghRows[  ],
    /* [out] */ ULONG __RPC_FAR *pcRowsResynched,
    /* [size_is][size_is][out] */ HROW __RPC_FAR *__RPC_FAR *prghRowsResynched,
    /* [size_is][size_is][out] */ DBROWSTATUS __RPC_FAR *__RPC_FAR *prgRowStatus);


void __RPC_STUB IRowsetResynch_ResynchRows_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __IRowsetResynch_INTERFACE_DEFINED__ */


#ifndef __IRowsetScroll_INTERFACE_DEFINED__
#define __IRowsetScroll_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: IRowsetScroll
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object][local] */ 



EXTERN_C const IID IID_IRowsetScroll;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733a7e-2a1c-11ce-ade5-00aa0044773d")
    IRowsetScroll : public IRowsetLocate
    {
    public:
        virtual HRESULT STDMETHODCALLTYPE GetApproximatePosition( 
            /* [in] */ HCHAPTER hReserved,
            /* [in] */ ULONG cbBookmark,
            /* [size_is][in] */ const BYTE __RPC_FAR *pBookmark,
            /* [out] */ ULONG __RPC_FAR *pulPosition,
            /* [out] */ ULONG __RPC_FAR *pcRows) = 0;
        
        virtual HRESULT STDMETHODCALLTYPE GetRowsAtRatio( 
            /* [in] */ HWATCHREGION hReserved1,
            /* [in] */ HCHAPTER hReserved2,
            /* [in] */ ULONG ulNumerator,
            /* [in] */ ULONG ulDenominator,
            /* [in] */ LONG cRows,
            /* [out] */ ULONG __RPC_FAR *pcRowsObtained,
            /* [size_is][size_is][out] */ HROW __RPC_FAR *__RPC_FAR *prghRows) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct IRowsetScrollVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            IRowsetScroll __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            IRowsetScroll __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            IRowsetScroll __RPC_FAR * This);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *AddRefRows )( 
            IRowsetScroll __RPC_FAR * This,
            /* [in] */ ULONG cRows,
            /* [size_is][in] */ const HROW __RPC_FAR rghRows[  ],
            /* [size_is][out] */ ULONG __RPC_FAR rgRefCounts[  ],
            /* [size_is][out] */ DBROWSTATUS __RPC_FAR rgRowStatus[  ]);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetData )( 
            IRowsetScroll __RPC_FAR * This,
            /* [in] */ HROW hRow,
            /* [in] */ HACCESSOR hAccessor,
            /* [out] */ void __RPC_FAR *pData);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetNextRows )( 
            IRowsetScroll __RPC_FAR * This,
            /* [in] */ HCHAPTER hReserved,
            /* [in] */ LONG lRowsOffset,
            /* [in] */ LONG cRows,
            /* [out] */ ULONG __RPC_FAR *pcRowsObtained,
            /* [size_is][size_is][out] */ HROW __RPC_FAR *__RPC_FAR *prghRows);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *ReleaseRows )( 
            IRowsetScroll __RPC_FAR * This,
            /* [in] */ ULONG cRows,
            /* [size_is][in] */ const HROW __RPC_FAR rghRows[  ],
            /* [size_is][in] */ DBROWOPTIONS __RPC_FAR rgRowOptions[  ],
            /* [size_is][out] */ ULONG __RPC_FAR rgRefCounts[  ],
            /* [size_is][out] */ DBROWSTATUS __RPC_FAR rgRowStatus[  ]);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *RestartPosition )( 
            IRowsetScroll __RPC_FAR * This,
            /* [in] */ HCHAPTER hReserved);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Compare )( 
            IRowsetScroll __RPC_FAR * This,
            /* [in] */ HCHAPTER hReserved,
            /* [in] */ ULONG cbBookmark1,
            /* [size_is][in] */ const BYTE __RPC_FAR *pBookmark1,
            /* [in] */ ULONG cbBookmark2,
            /* [size_is][in] */ const BYTE __RPC_FAR *pBookmark2,
            /* [out] */ DBCOMPARE __RPC_FAR *pComparison);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetRowsAt )( 
            IRowsetScroll __RPC_FAR * This,
            /* [in] */ HWATCHREGION hReserved1,
            /* [in] */ HCHAPTER hReserved2,
            /* [in] */ ULONG cbBookmark,
            /* [size_is][in] */ const BYTE __RPC_FAR *pBookmark,
            /* [in] */ LONG lRowsOffset,
            /* [in] */ LONG cRows,
            /* [out] */ ULONG __RPC_FAR *pcRowsObtained,
            /* [size_is][size_is][out] */ HROW __RPC_FAR *__RPC_FAR *prghRows);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetRowsByBookmark )( 
            IRowsetScroll __RPC_FAR * This,
            /* [in] */ HCHAPTER hReserved,
            /* [in] */ ULONG cRows,
            /* [size_is][in] */ const ULONG __RPC_FAR rgcbBookmarks[  ],
            /* [size_is][in] */ const BYTE __RPC_FAR *__RPC_FAR rgpBookmarks[  ],
            /* [size_is][out] */ HROW __RPC_FAR rghRows[  ],
            /* [size_is][out] */ DBROWSTATUS __RPC_FAR rgRowStatus[  ]);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Hash )( 
            IRowsetScroll __RPC_FAR * This,
            /* [in] */ HCHAPTER hReserved,
            /* [in] */ ULONG cBookmarks,
            /* [size_is][in] */ const ULONG __RPC_FAR rgcbBookmarks[  ],
            /* [size_is][in] */ const BYTE __RPC_FAR *__RPC_FAR rgpBookmarks[  ],
            /* [size_is][out] */ DWORD __RPC_FAR rgHashedValues[  ],
            /* [size_is][out] */ DBROWSTATUS __RPC_FAR rgBookmarkStatus[  ]);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetApproximatePosition )( 
            IRowsetScroll __RPC_FAR * This,
            /* [in] */ HCHAPTER hReserved,
            /* [in] */ ULONG cbBookmark,
            /* [size_is][in] */ const BYTE __RPC_FAR *pBookmark,
            /* [out] */ ULONG __RPC_FAR *pulPosition,
            /* [out] */ ULONG __RPC_FAR *pcRows);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetRowsAtRatio )( 
            IRowsetScroll __RPC_FAR * This,
            /* [in] */ HWATCHREGION hReserved1,
            /* [in] */ HCHAPTER hReserved2,
            /* [in] */ ULONG ulNumerator,
            /* [in] */ ULONG ulDenominator,
            /* [in] */ LONG cRows,
            /* [out] */ ULONG __RPC_FAR *pcRowsObtained,
            /* [size_is][size_is][out] */ HROW __RPC_FAR *__RPC_FAR *prghRows);
        
        END_INTERFACE
    } IRowsetScrollVtbl;

    interface IRowsetScroll
    {
        CONST_VTBL struct IRowsetScrollVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define IRowsetScroll_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define IRowsetScroll_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define IRowsetScroll_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define IRowsetScroll_AddRefRows(This,cRows,rghRows,rgRefCounts,rgRowStatus)	\
    (This)->lpVtbl -> AddRefRows(This,cRows,rghRows,rgRefCounts,rgRowStatus)

#define IRowsetScroll_GetData(This,hRow,hAccessor,pData)	\
    (This)->lpVtbl -> GetData(This,hRow,hAccessor,pData)

#define IRowsetScroll_GetNextRows(This,hReserved,lRowsOffset,cRows,pcRowsObtained,prghRows)	\
    (This)->lpVtbl -> GetNextRows(This,hReserved,lRowsOffset,cRows,pcRowsObtained,prghRows)

#define IRowsetScroll_ReleaseRows(This,cRows,rghRows,rgRowOptions,rgRefCounts,rgRowStatus)	\
    (This)->lpVtbl -> ReleaseRows(This,cRows,rghRows,rgRowOptions,rgRefCounts,rgRowStatus)

#define IRowsetScroll_RestartPosition(This,hReserved)	\
    (This)->lpVtbl -> RestartPosition(This,hReserved)


#define IRowsetScroll_Compare(This,hReserved,cbBookmark1,pBookmark1,cbBookmark2,pBookmark2,pComparison)	\
    (This)->lpVtbl -> Compare(This,hReserved,cbBookmark1,pBookmark1,cbBookmark2,pBookmark2,pComparison)

#define IRowsetScroll_GetRowsAt(This,hReserved1,hReserved2,cbBookmark,pBookmark,lRowsOffset,cRows,pcRowsObtained,prghRows)	\
    (This)->lpVtbl -> GetRowsAt(This,hReserved1,hReserved2,cbBookmark,pBookmark,lRowsOffset,cRows,pcRowsObtained,prghRows)

#define IRowsetScroll_GetRowsByBookmark(This,hReserved,cRows,rgcbBookmarks,rgpBookmarks,rghRows,rgRowStatus)	\
    (This)->lpVtbl -> GetRowsByBookmark(This,hReserved,cRows,rgcbBookmarks,rgpBookmarks,rghRows,rgRowStatus)

#define IRowsetScroll_Hash(This,hReserved,cBookmarks,rgcbBookmarks,rgpBookmarks,rgHashedValues,rgBookmarkStatus)	\
    (This)->lpVtbl -> Hash(This,hReserved,cBookmarks,rgcbBookmarks,rgpBookmarks,rgHashedValues,rgBookmarkStatus)


#define IRowsetScroll_GetApproximatePosition(This,hReserved,cbBookmark,pBookmark,pulPosition,pcRows)	\
    (This)->lpVtbl -> GetApproximatePosition(This,hReserved,cbBookmark,pBookmark,pulPosition,pcRows)

#define IRowsetScroll_GetRowsAtRatio(This,hReserved1,hReserved2,ulNumerator,ulDenominator,cRows,pcRowsObtained,prghRows)	\
    (This)->lpVtbl -> GetRowsAtRatio(This,hReserved1,hReserved2,ulNumerator,ulDenominator,cRows,pcRowsObtained,prghRows)

#endif /* COBJMACROS */


#endif 	/* C style interface */



HRESULT STDMETHODCALLTYPE IRowsetScroll_GetApproximatePosition_Proxy( 
    IRowsetScroll __RPC_FAR * This,
    /* [in] */ HCHAPTER hReserved,
    /* [in] */ ULONG cbBookmark,
    /* [size_is][in] */ const BYTE __RPC_FAR *pBookmark,
    /* [out] */ ULONG __RPC_FAR *pulPosition,
    /* [out] */ ULONG __RPC_FAR *pcRows);


void __RPC_STUB IRowsetScroll_GetApproximatePosition_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


HRESULT STDMETHODCALLTYPE IRowsetScroll_GetRowsAtRatio_Proxy( 
    IRowsetScroll __RPC_FAR * This,
    /* [in] */ HWATCHREGION hReserved1,
    /* [in] */ HCHAPTER hReserved2,
    /* [in] */ ULONG ulNumerator,
    /* [in] */ ULONG ulDenominator,
    /* [in] */ LONG cRows,
    /* [out] */ ULONG __RPC_FAR *pcRowsObtained,
    /* [size_is][size_is][out] */ HROW __RPC_FAR *__RPC_FAR *prghRows);


void __RPC_STUB IRowsetScroll_GetRowsAtRatio_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __IRowsetScroll_INTERFACE_DEFINED__ */


/****************************************
 * Generated header for interface: __MIDL_itf_oledb_0161
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [local] */ 



extern RPC_IF_HANDLE __MIDL_itf_oledb_0161_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_oledb_0161_v0_0_s_ifspec;

#ifndef __IChapteredRowset_INTERFACE_DEFINED__
#define __IChapteredRowset_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: IChapteredRowset
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object] */ 



EXTERN_C const IID IID_IChapteredRowset;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733a93-2a1c-11ce-ade5-00aa0044773d")
    IChapteredRowset : public IUnknown
    {
    public:
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE AddRefChapter( 
            /* [in] */ HCHAPTER hChapter,
            /* [out] */ ULONG __RPC_FAR *pcRefCount) = 0;
        
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE ReleaseChapter( 
            /* [in] */ HCHAPTER hChapter,
            /* [out] */ ULONG __RPC_FAR *pcRefCount) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct IChapteredRowsetVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            IChapteredRowset __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            IChapteredRowset __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            IChapteredRowset __RPC_FAR * This);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *AddRefChapter )( 
            IChapteredRowset __RPC_FAR * This,
            /* [in] */ HCHAPTER hChapter,
            /* [out] */ ULONG __RPC_FAR *pcRefCount);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *ReleaseChapter )( 
            IChapteredRowset __RPC_FAR * This,
            /* [in] */ HCHAPTER hChapter,
            /* [out] */ ULONG __RPC_FAR *pcRefCount);
        
        END_INTERFACE
    } IChapteredRowsetVtbl;

    interface IChapteredRowset
    {
        CONST_VTBL struct IChapteredRowsetVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define IChapteredRowset_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define IChapteredRowset_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define IChapteredRowset_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define IChapteredRowset_AddRefChapter(This,hChapter,pcRefCount)	\
    (This)->lpVtbl -> AddRefChapter(This,hChapter,pcRefCount)

#define IChapteredRowset_ReleaseChapter(This,hChapter,pcRefCount)	\
    (This)->lpVtbl -> ReleaseChapter(This,hChapter,pcRefCount)

#endif /* COBJMACROS */


#endif 	/* C style interface */



/* [call_as] */ HRESULT STDMETHODCALLTYPE IChapteredRowset_RemoteAddRefChapter_Proxy( 
    IChapteredRowset __RPC_FAR * This,
    /* [in] */ HCHAPTER hChapter,
    /* [out] */ ULONG __RPC_FAR *pcRefCount,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IChapteredRowset_RemoteAddRefChapter_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IChapteredRowset_RemoteReleaseChapter_Proxy( 
    IChapteredRowset __RPC_FAR * This,
    /* [in] */ HCHAPTER hChapter,
    /* [out] */ ULONG __RPC_FAR *pcRefCount,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IChapteredRowset_RemoteReleaseChapter_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __IChapteredRowset_INTERFACE_DEFINED__ */


#ifndef __IRowsetFind_INTERFACE_DEFINED__
#define __IRowsetFind_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: IRowsetFind
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object][local] */ 



EXTERN_C const IID IID_IRowsetFind;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733a9d-2a1c-11ce-ade5-00aa0044773d")
    IRowsetFind : public IUnknown
    {
    public:
        virtual HRESULT STDMETHODCALLTYPE FindNextRow( 
            /* [in] */ HCHAPTER hChapter,
            /* [in] */ HACCESSOR hAccessor,
            /* [in] */ void __RPC_FAR *pFindValue,
            /* [in] */ DBCOMPAREOP CompareOp,
            /* [in] */ ULONG cbBookmark,
            /* [size_is][in] */ const BYTE __RPC_FAR *pBookmark,
            /* [in] */ LONG lRowsOffset,
            /* [in] */ LONG cRows,
            /* [out][in] */ ULONG __RPC_FAR *pcRowsObtained,
            /* [size_is][size_is][out] */ HROW __RPC_FAR *__RPC_FAR *prghRows) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct IRowsetFindVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            IRowsetFind __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            IRowsetFind __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            IRowsetFind __RPC_FAR * This);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *FindNextRow )( 
            IRowsetFind __RPC_FAR * This,
            /* [in] */ HCHAPTER hChapter,
            /* [in] */ HACCESSOR hAccessor,
            /* [in] */ void __RPC_FAR *pFindValue,
            /* [in] */ DBCOMPAREOP CompareOp,
            /* [in] */ ULONG cbBookmark,
            /* [size_is][in] */ const BYTE __RPC_FAR *pBookmark,
            /* [in] */ LONG lRowsOffset,
            /* [in] */ LONG cRows,
            /* [out][in] */ ULONG __RPC_FAR *pcRowsObtained,
            /* [size_is][size_is][out] */ HROW __RPC_FAR *__RPC_FAR *prghRows);
        
        END_INTERFACE
    } IRowsetFindVtbl;

    interface IRowsetFind
    {
        CONST_VTBL struct IRowsetFindVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define IRowsetFind_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define IRowsetFind_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define IRowsetFind_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define IRowsetFind_FindNextRow(This,hChapter,hAccessor,pFindValue,CompareOp,cbBookmark,pBookmark,lRowsOffset,cRows,pcRowsObtained,prghRows)	\
    (This)->lpVtbl -> FindNextRow(This,hChapter,hAccessor,pFindValue,CompareOp,cbBookmark,pBookmark,lRowsOffset,cRows,pcRowsObtained,prghRows)

#endif /* COBJMACROS */


#endif 	/* C style interface */



HRESULT STDMETHODCALLTYPE IRowsetFind_FindNextRow_Proxy( 
    IRowsetFind __RPC_FAR * This,
    /* [in] */ HCHAPTER hChapter,
    /* [in] */ HACCESSOR hAccessor,
    /* [in] */ void __RPC_FAR *pFindValue,
    /* [in] */ DBCOMPAREOP CompareOp,
    /* [in] */ ULONG cbBookmark,
    /* [size_is][in] */ const BYTE __RPC_FAR *pBookmark,
    /* [in] */ LONG lRowsOffset,
    /* [in] */ LONG cRows,
    /* [out][in] */ ULONG __RPC_FAR *pcRowsObtained,
    /* [size_is][size_is][out] */ HROW __RPC_FAR *__RPC_FAR *prghRows);


void __RPC_STUB IRowsetFind_FindNextRow_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __IRowsetFind_INTERFACE_DEFINED__ */


#ifndef __IRowPosition_INTERFACE_DEFINED__
#define __IRowPosition_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: IRowPosition
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object] */ 


typedef DWORD DBPOSITIONFLAGS;


enum DBPOSITIONFLAGSENUM
    {	DBPOSITION_OK	= 0,
	DBPOSITION_NOROW	= DBPOSITION_OK + 1,
	DBPOSITION_BOF	= DBPOSITION_NOROW + 1,
	DBPOSITION_EOF	= DBPOSITION_BOF + 1
    };

EXTERN_C const IID IID_IRowPosition;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733a94-2a1c-11ce-ade5-00aa0044773d")
    IRowPosition : public IUnknown
    {
    public:
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE ClearRowPosition( void) = 0;
        
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetRowPosition( 
            /* [out] */ HCHAPTER __RPC_FAR *phChapter,
            /* [out] */ HROW __RPC_FAR *phRow,
            /* [out] */ DBPOSITIONFLAGS __RPC_FAR *pdwPositionFlags) = 0;
        
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetRowset( 
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset) = 0;
        
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE Initialize( 
            /* [in] */ IUnknown __RPC_FAR *pRowset) = 0;
        
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE SetRowPosition( 
            /* [in] */ HCHAPTER hChapter,
            /* [in] */ HROW hRow,
            /* [in] */ DBPOSITIONFLAGS dwPositionFlags) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct IRowPositionVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            IRowPosition __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            IRowPosition __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            IRowPosition __RPC_FAR * This);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *ClearRowPosition )( 
            IRowPosition __RPC_FAR * This);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetRowPosition )( 
            IRowPosition __RPC_FAR * This,
            /* [out] */ HCHAPTER __RPC_FAR *phChapter,
            /* [out] */ HROW __RPC_FAR *phRow,
            /* [out] */ DBPOSITIONFLAGS __RPC_FAR *pdwPositionFlags);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetRowset )( 
            IRowPosition __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Initialize )( 
            IRowPosition __RPC_FAR * This,
            /* [in] */ IUnknown __RPC_FAR *pRowset);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *SetRowPosition )( 
            IRowPosition __RPC_FAR * This,
            /* [in] */ HCHAPTER hChapter,
            /* [in] */ HROW hRow,
            /* [in] */ DBPOSITIONFLAGS dwPositionFlags);
        
        END_INTERFACE
    } IRowPositionVtbl;

    interface IRowPosition
    {
        CONST_VTBL struct IRowPositionVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define IRowPosition_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define IRowPosition_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define IRowPosition_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define IRowPosition_ClearRowPosition(This)	\
    (This)->lpVtbl -> ClearRowPosition(This)

#define IRowPosition_GetRowPosition(This,phChapter,phRow,pdwPositionFlags)	\
    (This)->lpVtbl -> GetRowPosition(This,phChapter,phRow,pdwPositionFlags)

#define IRowPosition_GetRowset(This,riid,ppRowset)	\
    (This)->lpVtbl -> GetRowset(This,riid,ppRowset)

#define IRowPosition_Initialize(This,pRowset)	\
    (This)->lpVtbl -> Initialize(This,pRowset)

#define IRowPosition_SetRowPosition(This,hChapter,hRow,dwPositionFlags)	\
    (This)->lpVtbl -> SetRowPosition(This,hChapter,hRow,dwPositionFlags)

#endif /* COBJMACROS */


#endif 	/* C style interface */



/* [call_as] */ HRESULT STDMETHODCALLTYPE IRowPosition_RemoteClearRowPosition_Proxy( 
    IRowPosition __RPC_FAR * This,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IRowPosition_RemoteClearRowPosition_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IRowPosition_RemoteGetRowPosition_Proxy( 
    IRowPosition __RPC_FAR * This,
    /* [out] */ HCHAPTER __RPC_FAR *phChapter,
    /* [out] */ HROW __RPC_FAR *phRow,
    /* [out] */ DBPOSITIONFLAGS __RPC_FAR *pdwPositionFlags,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IRowPosition_RemoteGetRowPosition_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IRowPosition_RemoteGetRowset_Proxy( 
    IRowPosition __RPC_FAR * This,
    /* [in] */ REFIID riid,
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IRowPosition_RemoteGetRowset_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IRowPosition_RemoteInitialize_Proxy( 
    IRowPosition __RPC_FAR * This,
    /* [in] */ IUnknown __RPC_FAR *pRowset,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IRowPosition_RemoteInitialize_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IRowPosition_RemoteSetRowPosition_Proxy( 
    IRowPosition __RPC_FAR * This,
    /* [in] */ HCHAPTER hChapter,
    /* [in] */ HROW hRow,
    /* [in] */ DBPOSITIONFLAGS dwPositionFlags,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IRowPosition_RemoteSetRowPosition_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __IRowPosition_INTERFACE_DEFINED__ */


#ifndef __IRowPositionChange_INTERFACE_DEFINED__
#define __IRowPositionChange_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: IRowPositionChange
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object] */ 



EXTERN_C const IID IID_IRowPositionChange;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0997a571-126e-11d0-9f8a-00a0c9a0631e")
    IRowPositionChange : public IUnknown
    {
    public:
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE OnRowPositionChange( 
            /* [in] */ DBREASON eReason,
            /* [in] */ DBEVENTPHASE ePhase,
            /* [in] */ BOOL fCantDeny) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct IRowPositionChangeVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            IRowPositionChange __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            IRowPositionChange __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            IRowPositionChange __RPC_FAR * This);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *OnRowPositionChange )( 
            IRowPositionChange __RPC_FAR * This,
            /* [in] */ DBREASON eReason,
            /* [in] */ DBEVENTPHASE ePhase,
            /* [in] */ BOOL fCantDeny);
        
        END_INTERFACE
    } IRowPositionChangeVtbl;

    interface IRowPositionChange
    {
        CONST_VTBL struct IRowPositionChangeVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define IRowPositionChange_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define IRowPositionChange_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define IRowPositionChange_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define IRowPositionChange_OnRowPositionChange(This,eReason,ePhase,fCantDeny)	\
    (This)->lpVtbl -> OnRowPositionChange(This,eReason,ePhase,fCantDeny)

#endif /* COBJMACROS */


#endif 	/* C style interface */



/* [call_as] */ HRESULT STDMETHODCALLTYPE IRowPositionChange_RemoteOnRowPositionChange_Proxy( 
    IRowPositionChange __RPC_FAR * This,
    /* [in] */ DBREASON eReason,
    /* [in] */ DBEVENTPHASE ePhase,
    /* [in] */ BOOL fCantDeny,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IRowPositionChange_RemoteOnRowPositionChange_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __IRowPositionChange_INTERFACE_DEFINED__ */


#ifndef __IViewRowset_INTERFACE_DEFINED__
#define __IViewRowset_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: IViewRowset
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object] */ 



EXTERN_C const IID IID_IViewRowset;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733a97-2a1c-11ce-ade5-00aa0044773d")
    IViewRowset : public IUnknown
    {
    public:
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetSpecification( 
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppObject) = 0;
        
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE OpenViewRowset( 
            /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct IViewRowsetVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            IViewRowset __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            IViewRowset __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            IViewRowset __RPC_FAR * This);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetSpecification )( 
            IViewRowset __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppObject);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *OpenViewRowset )( 
            IViewRowset __RPC_FAR * This,
            /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset);
        
        END_INTERFACE
    } IViewRowsetVtbl;

    interface IViewRowset
    {
        CONST_VTBL struct IViewRowsetVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define IViewRowset_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define IViewRowset_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define IViewRowset_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define IViewRowset_GetSpecification(This,riid,ppObject)	\
    (This)->lpVtbl -> GetSpecification(This,riid,ppObject)

#define IViewRowset_OpenViewRowset(This,pUnkOuter,riid,ppRowset)	\
    (This)->lpVtbl -> OpenViewRowset(This,pUnkOuter,riid,ppRowset)

#endif /* COBJMACROS */


#endif 	/* C style interface */



/* [call_as] */ HRESULT STDMETHODCALLTYPE IViewRowset_RemoteGetSpecification_Proxy( 
    IViewRowset __RPC_FAR * This,
    /* [in] */ REFIID riid,
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppObject,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IViewRowset_RemoteGetSpecification_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IViewRowset_RemoteOpenViewRowset_Proxy( 
    IViewRowset __RPC_FAR * This,
    /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
    /* [in] */ REFIID riid,
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IViewRowset_RemoteOpenViewRowset_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __IViewRowset_INTERFACE_DEFINED__ */


#ifndef __IViewChapter_INTERFACE_DEFINED__
#define __IViewChapter_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: IViewChapter
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object] */ 



EXTERN_C const IID IID_IViewChapter;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733a98-2a1c-11ce-ade5-00aa0044773d")
    IViewChapter : public IUnknown
    {
    public:
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetSpecification( 
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset) = 0;
        
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE OpenViewChapter( 
            /* [in] */ HCHAPTER hSource,
            /* [out] */ HCHAPTER __RPC_FAR *phViewChapter) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct IViewChapterVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            IViewChapter __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            IViewChapter __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            IViewChapter __RPC_FAR * This);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetSpecification )( 
            IViewChapter __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *OpenViewChapter )( 
            IViewChapter __RPC_FAR * This,
            /* [in] */ HCHAPTER hSource,
            /* [out] */ HCHAPTER __RPC_FAR *phViewChapter);
        
        END_INTERFACE
    } IViewChapterVtbl;

    interface IViewChapter
    {
        CONST_VTBL struct IViewChapterVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define IViewChapter_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define IViewChapter_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define IViewChapter_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define IViewChapter_GetSpecification(This,riid,ppRowset)	\
    (This)->lpVtbl -> GetSpecification(This,riid,ppRowset)

#define IViewChapter_OpenViewChapter(This,hSource,phViewChapter)	\
    (This)->lpVtbl -> OpenViewChapter(This,hSource,phViewChapter)

#endif /* COBJMACROS */


#endif 	/* C style interface */



/* [call_as] */ HRESULT STDMETHODCALLTYPE IViewChapter_RemoteGetSpecification_Proxy( 
    IViewChapter __RPC_FAR * This,
    /* [in] */ REFIID riid,
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IViewChapter_RemoteGetSpecification_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IViewChapter_RemoteOpenViewChapter_Proxy( 
    IViewChapter __RPC_FAR * This,
    /* [in] */ HCHAPTER hSource,
    /* [out] */ HCHAPTER __RPC_FAR *phViewChapter,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IViewChapter_RemoteOpenViewChapter_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __IViewChapter_INTERFACE_DEFINED__ */


#ifndef __IViewSort_INTERFACE_DEFINED__
#define __IViewSort_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: IViewSort
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object] */ 



EXTERN_C const IID IID_IViewSort;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733a9a-2a1c-11ce-ade5-00aa0044773d")
    IViewSort : public IUnknown
    {
    public:
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetSortOrder( 
            /* [out] */ ULONG __RPC_FAR *pcValues,
            /* [out] */ ULONG __RPC_FAR *__RPC_FAR prgColumns[  ],
            /* [out] */ DBSORT __RPC_FAR *__RPC_FAR prgOrders[  ]) = 0;
        
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE SetSortOrder( 
            /* [in] */ ULONG cValues,
            /* [size_is][in] */ const ULONG __RPC_FAR rgColumns[  ],
            /* [size_is][in] */ const DBSORT __RPC_FAR rgOrders[  ]) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct IViewSortVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            IViewSort __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            IViewSort __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            IViewSort __RPC_FAR * This);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetSortOrder )( 
            IViewSort __RPC_FAR * This,
            /* [out] */ ULONG __RPC_FAR *pcValues,
            /* [out] */ ULONG __RPC_FAR *__RPC_FAR prgColumns[  ],
            /* [out] */ DBSORT __RPC_FAR *__RPC_FAR prgOrders[  ]);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *SetSortOrder )( 
            IViewSort __RPC_FAR * This,
            /* [in] */ ULONG cValues,
            /* [size_is][in] */ const ULONG __RPC_FAR rgColumns[  ],
            /* [size_is][in] */ const DBSORT __RPC_FAR rgOrders[  ]);
        
        END_INTERFACE
    } IViewSortVtbl;

    interface IViewSort
    {
        CONST_VTBL struct IViewSortVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define IViewSort_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define IViewSort_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define IViewSort_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define IViewSort_GetSortOrder(This,pcValues,prgColumns,prgOrders)	\
    (This)->lpVtbl -> GetSortOrder(This,pcValues,prgColumns,prgOrders)

#define IViewSort_SetSortOrder(This,cValues,rgColumns,rgOrders)	\
    (This)->lpVtbl -> SetSortOrder(This,cValues,rgColumns,rgOrders)

#endif /* COBJMACROS */


#endif 	/* C style interface */



/* [call_as] */ HRESULT STDMETHODCALLTYPE IViewSort_RemoteGetSortOrder_Proxy( 
    IViewSort __RPC_FAR * This,
    /* [out][in] */ ULONG __RPC_FAR *pcValues,
    /* [size_is][size_is][out] */ ULONG __RPC_FAR *__RPC_FAR *prgColumns,
    /* [size_is][size_is][out] */ ULONG __RPC_FAR *__RPC_FAR *prgOrders,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IViewSort_RemoteGetSortOrder_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IViewSort_RemoteSetSortOrder_Proxy( 
    IViewSort __RPC_FAR * This,
    /* [in] */ ULONG cValues,
    /* [size_is][in] */ const ULONG __RPC_FAR *rgColumns,
    /* [size_is][in] */ const DBSORT __RPC_FAR *rgOrders,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IViewSort_RemoteSetSortOrder_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __IViewSort_INTERFACE_DEFINED__ */


#ifndef __IViewFilter_INTERFACE_DEFINED__
#define __IViewFilter_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: IViewFilter
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object] */ 



EXTERN_C const IID IID_IViewFilter;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733a9b-2a1c-11ce-ade5-00aa0044773d")
    IViewFilter : public IUnknown
    {
    public:
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetFilter( 
            /* [in] */ HACCESSOR hAccessor,
            /* [out] */ ULONG __RPC_FAR *pcRows,
            /* [out] */ DBCOMPAREOP __RPC_FAR *__RPC_FAR pCompareOps[  ],
            /* [out] */ void __RPC_FAR *pCriteriaData) = 0;
        
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetFilterBindings( 
            /* [out] */ ULONG __RPC_FAR *pcBindings,
            /* [out] */ DBBINDING __RPC_FAR *__RPC_FAR *prgBindings) = 0;
        
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE SetFilter( 
            /* [in] */ HACCESSOR hAccessor,
            /* [in] */ ULONG cRows,
            /* [in] */ DBCOMPAREOP __RPC_FAR CompareOps[  ],
            /* [in] */ void __RPC_FAR *pCriteriaData) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct IViewFilterVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            IViewFilter __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            IViewFilter __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            IViewFilter __RPC_FAR * This);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetFilter )( 
            IViewFilter __RPC_FAR * This,
            /* [in] */ HACCESSOR hAccessor,
            /* [out] */ ULONG __RPC_FAR *pcRows,
            /* [out] */ DBCOMPAREOP __RPC_FAR *__RPC_FAR pCompareOps[  ],
            /* [out] */ void __RPC_FAR *pCriteriaData);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetFilterBindings )( 
            IViewFilter __RPC_FAR * This,
            /* [out] */ ULONG __RPC_FAR *pcBindings,
            /* [out] */ DBBINDING __RPC_FAR *__RPC_FAR *prgBindings);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *SetFilter )( 
            IViewFilter __RPC_FAR * This,
            /* [in] */ HACCESSOR hAccessor,
            /* [in] */ ULONG cRows,
            /* [in] */ DBCOMPAREOP __RPC_FAR CompareOps[  ],
            /* [in] */ void __RPC_FAR *pCriteriaData);
        
        END_INTERFACE
    } IViewFilterVtbl;

    interface IViewFilter
    {
        CONST_VTBL struct IViewFilterVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define IViewFilter_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define IViewFilter_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define IViewFilter_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define IViewFilter_GetFilter(This,hAccessor,pcRows,pCompareOps,pCriteriaData)	\
    (This)->lpVtbl -> GetFilter(This,hAccessor,pcRows,pCompareOps,pCriteriaData)

#define IViewFilter_GetFilterBindings(This,pcBindings,prgBindings)	\
    (This)->lpVtbl -> GetFilterBindings(This,pcBindings,prgBindings)

#define IViewFilter_SetFilter(This,hAccessor,cRows,CompareOps,pCriteriaData)	\
    (This)->lpVtbl -> SetFilter(This,hAccessor,cRows,CompareOps,pCriteriaData)

#endif /* COBJMACROS */


#endif 	/* C style interface */



/* [local] */ HRESULT STDMETHODCALLTYPE IViewFilter_GetFilter_Proxy( 
    IViewFilter __RPC_FAR * This,
    /* [in] */ HACCESSOR hAccessor,
    /* [out] */ ULONG __RPC_FAR *pcRows,
    /* [out] */ DBCOMPAREOP __RPC_FAR *__RPC_FAR pCompareOps[  ],
    /* [out] */ void __RPC_FAR *pCriteriaData);


void __RPC_STUB IViewFilter_GetFilter_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IViewFilter_RemoteGetFilterBindings_Proxy( 
    IViewFilter __RPC_FAR * This,
    /* [out][in] */ ULONG __RPC_FAR *pcBindings,
    /* [size_is][size_is][out] */ DBBINDING __RPC_FAR *__RPC_FAR *prgBindings,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IViewFilter_RemoteGetFilterBindings_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


/* [local] */ HRESULT STDMETHODCALLTYPE IViewFilter_SetFilter_Proxy( 
    IViewFilter __RPC_FAR * This,
    /* [in] */ HACCESSOR hAccessor,
    /* [in] */ ULONG cRows,
    /* [in] */ DBCOMPAREOP __RPC_FAR CompareOps[  ],
    /* [in] */ void __RPC_FAR *pCriteriaData);


void __RPC_STUB IViewFilter_SetFilter_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __IViewFilter_INTERFACE_DEFINED__ */


#ifndef __IRowsetView_INTERFACE_DEFINED__
#define __IRowsetView_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: IRowsetView
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object] */ 



EXTERN_C const IID IID_IRowsetView;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733a99-2a1c-11ce-ade5-00aa0044773d")
    IRowsetView : public IUnknown
    {
    public:
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE CreateView( 
            /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppView) = 0;
        
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetView( 
            /* [in] */ HCHAPTER hChapter,
            /* [in] */ REFIID riid,
            /* [out] */ HCHAPTER __RPC_FAR *phChapterSource,
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppView) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct IRowsetViewVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            IRowsetView __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            IRowsetView __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            IRowsetView __RPC_FAR * This);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *CreateView )( 
            IRowsetView __RPC_FAR * This,
            /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppView);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetView )( 
            IRowsetView __RPC_FAR * This,
            /* [in] */ HCHAPTER hChapter,
            /* [in] */ REFIID riid,
            /* [out] */ HCHAPTER __RPC_FAR *phChapterSource,
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppView);
        
        END_INTERFACE
    } IRowsetViewVtbl;

    interface IRowsetView
    {
        CONST_VTBL struct IRowsetViewVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define IRowsetView_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define IRowsetView_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define IRowsetView_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define IRowsetView_CreateView(This,pUnkOuter,riid,ppView)	\
    (This)->lpVtbl -> CreateView(This,pUnkOuter,riid,ppView)

#define IRowsetView_GetView(This,hChapter,riid,phChapterSource,ppView)	\
    (This)->lpVtbl -> GetView(This,hChapter,riid,phChapterSource,ppView)

#endif /* COBJMACROS */


#endif 	/* C style interface */



/* [call_as] */ HRESULT STDMETHODCALLTYPE IRowsetView_RemoteCreateView_Proxy( 
    IRowsetView __RPC_FAR * This,
    /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
    /* [in] */ REFIID riid,
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppView,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IRowsetView_RemoteCreateView_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IRowsetView_RemoteGetView_Proxy( 
    IRowsetView __RPC_FAR * This,
    /* [in] */ HCHAPTER hChapter,
    /* [in] */ REFIID riid,
    /* [out] */ HCHAPTER __RPC_FAR *phChapterSource,
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppView,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IRowsetView_RemoteGetView_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __IRowsetView_INTERFACE_DEFINED__ */


/****************************************
 * Generated header for interface: __MIDL_itf_oledb_0170
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [local] */ 


//@@@+ deprecated
#ifdef deprecated


extern RPC_IF_HANDLE __MIDL_itf_oledb_0170_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_oledb_0170_v0_0_s_ifspec;

#ifndef __IRowsetExactScroll_INTERFACE_DEFINED__
#define __IRowsetExactScroll_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: IRowsetExactScroll
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object][local] */ 



EXTERN_C const IID IID_IRowsetExactScroll;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733a7f-2a1c-11ce-ade5-00aa0044773d")
    IRowsetExactScroll : public IRowsetScroll
    {
    public:
        virtual HRESULT STDMETHODCALLTYPE GetExactPosition( 
            /* [in] */ HCHAPTER hChapter,
            /* [in] */ ULONG cbBookmark,
            /* [size_is][in] */ const BYTE __RPC_FAR *pBookmark,
            /* [out] */ ULONG __RPC_FAR *pulPosition,
            /* [out] */ ULONG __RPC_FAR *pcRows) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct IRowsetExactScrollVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            IRowsetExactScroll __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            IRowsetExactScroll __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            IRowsetExactScroll __RPC_FAR * This);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *AddRefRows )( 
            IRowsetExactScroll __RPC_FAR * This,
            /* [in] */ ULONG cRows,
            /* [size_is][in] */ const HROW __RPC_FAR rghRows[  ],
            /* [size_is][out] */ ULONG __RPC_FAR rgRefCounts[  ],
            /* [size_is][out] */ DBROWSTATUS __RPC_FAR rgRowStatus[  ]);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetData )( 
            IRowsetExactScroll __RPC_FAR * This,
            /* [in] */ HROW hRow,
            /* [in] */ HACCESSOR hAccessor,
            /* [out] */ void __RPC_FAR *pData);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetNextRows )( 
            IRowsetExactScroll __RPC_FAR * This,
            /* [in] */ HCHAPTER hReserved,
            /* [in] */ LONG lRowsOffset,
            /* [in] */ LONG cRows,
            /* [out] */ ULONG __RPC_FAR *pcRowsObtained,
            /* [size_is][size_is][out] */ HROW __RPC_FAR *__RPC_FAR *prghRows);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *ReleaseRows )( 
            IRowsetExactScroll __RPC_FAR * This,
            /* [in] */ ULONG cRows,
            /* [size_is][in] */ const HROW __RPC_FAR rghRows[  ],
            /* [size_is][in] */ DBROWOPTIONS __RPC_FAR rgRowOptions[  ],
            /* [size_is][out] */ ULONG __RPC_FAR rgRefCounts[  ],
            /* [size_is][out] */ DBROWSTATUS __RPC_FAR rgRowStatus[  ]);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *RestartPosition )( 
            IRowsetExactScroll __RPC_FAR * This,
            /* [in] */ HCHAPTER hReserved);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Compare )( 
            IRowsetExactScroll __RPC_FAR * This,
            /* [in] */ HCHAPTER hReserved,
            /* [in] */ ULONG cbBookmark1,
            /* [size_is][in] */ const BYTE __RPC_FAR *pBookmark1,
            /* [in] */ ULONG cbBookmark2,
            /* [size_is][in] */ const BYTE __RPC_FAR *pBookmark2,
            /* [out] */ DBCOMPARE __RPC_FAR *pComparison);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetRowsAt )( 
            IRowsetExactScroll __RPC_FAR * This,
            /* [in] */ HWATCHREGION hReserved1,
            /* [in] */ HCHAPTER hReserved2,
            /* [in] */ ULONG cbBookmark,
            /* [size_is][in] */ const BYTE __RPC_FAR *pBookmark,
            /* [in] */ LONG lRowsOffset,
            /* [in] */ LONG cRows,
            /* [out] */ ULONG __RPC_FAR *pcRowsObtained,
            /* [size_is][size_is][out] */ HROW __RPC_FAR *__RPC_FAR *prghRows);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetRowsByBookmark )( 
            IRowsetExactScroll __RPC_FAR * This,
            /* [in] */ HCHAPTER hReserved,
            /* [in] */ ULONG cRows,
            /* [size_is][in] */ const ULONG __RPC_FAR rgcbBookmarks[  ],
            /* [size_is][in] */ const BYTE __RPC_FAR *__RPC_FAR rgpBookmarks[  ],
            /* [size_is][out] */ HROW __RPC_FAR rghRows[  ],
            /* [size_is][out] */ DBROWSTATUS __RPC_FAR rgRowStatus[  ]);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Hash )( 
            IRowsetExactScroll __RPC_FAR * This,
            /* [in] */ HCHAPTER hReserved,
            /* [in] */ ULONG cBookmarks,
            /* [size_is][in] */ const ULONG __RPC_FAR rgcbBookmarks[  ],
            /* [size_is][in] */ const BYTE __RPC_FAR *__RPC_FAR rgpBookmarks[  ],
            /* [size_is][out] */ DWORD __RPC_FAR rgHashedValues[  ],
            /* [size_is][out] */ DBROWSTATUS __RPC_FAR rgBookmarkStatus[  ]);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetApproximatePosition )( 
            IRowsetExactScroll __RPC_FAR * This,
            /* [in] */ HCHAPTER hReserved,
            /* [in] */ ULONG cbBookmark,
            /* [size_is][in] */ const BYTE __RPC_FAR *pBookmark,
            /* [out] */ ULONG __RPC_FAR *pulPosition,
            /* [out] */ ULONG __RPC_FAR *pcRows);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetRowsAtRatio )( 
            IRowsetExactScroll __RPC_FAR * This,
            /* [in] */ HWATCHREGION hReserved1,
            /* [in] */ HCHAPTER hReserved2,
            /* [in] */ ULONG ulNumerator,
            /* [in] */ ULONG ulDenominator,
            /* [in] */ LONG cRows,
            /* [out] */ ULONG __RPC_FAR *pcRowsObtained,
            /* [size_is][size_is][out] */ HROW __RPC_FAR *__RPC_FAR *prghRows);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetExactPosition )( 
            IRowsetExactScroll __RPC_FAR * This,
            /* [in] */ HCHAPTER hChapter,
            /* [in] */ ULONG cbBookmark,
            /* [size_is][in] */ const BYTE __RPC_FAR *pBookmark,
            /* [out] */ ULONG __RPC_FAR *pulPosition,
            /* [out] */ ULONG __RPC_FAR *pcRows);
        
        END_INTERFACE
    } IRowsetExactScrollVtbl;

    interface IRowsetExactScroll
    {
        CONST_VTBL struct IRowsetExactScrollVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define IRowsetExactScroll_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define IRowsetExactScroll_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define IRowsetExactScroll_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define IRowsetExactScroll_AddRefRows(This,cRows,rghRows,rgRefCounts,rgRowStatus)	\
    (This)->lpVtbl -> AddRefRows(This,cRows,rghRows,rgRefCounts,rgRowStatus)

#define IRowsetExactScroll_GetData(This,hRow,hAccessor,pData)	\
    (This)->lpVtbl -> GetData(This,hRow,hAccessor,pData)

#define IRowsetExactScroll_GetNextRows(This,hReserved,lRowsOffset,cRows,pcRowsObtained,prghRows)	\
    (This)->lpVtbl -> GetNextRows(This,hReserved,lRowsOffset,cRows,pcRowsObtained,prghRows)

#define IRowsetExactScroll_ReleaseRows(This,cRows,rghRows,rgRowOptions,rgRefCounts,rgRowStatus)	\
    (This)->lpVtbl -> ReleaseRows(This,cRows,rghRows,rgRowOptions,rgRefCounts,rgRowStatus)

#define IRowsetExactScroll_RestartPosition(This,hReserved)	\
    (This)->lpVtbl -> RestartPosition(This,hReserved)


#define IRowsetExactScroll_Compare(This,hReserved,cbBookmark1,pBookmark1,cbBookmark2,pBookmark2,pComparison)	\
    (This)->lpVtbl -> Compare(This,hReserved,cbBookmark1,pBookmark1,cbBookmark2,pBookmark2,pComparison)

#define IRowsetExactScroll_GetRowsAt(This,hReserved1,hReserved2,cbBookmark,pBookmark,lRowsOffset,cRows,pcRowsObtained,prghRows)	\
    (This)->lpVtbl -> GetRowsAt(This,hReserved1,hReserved2,cbBookmark,pBookmark,lRowsOffset,cRows,pcRowsObtained,prghRows)

#define IRowsetExactScroll_GetRowsByBookmark(This,hReserved,cRows,rgcbBookmarks,rgpBookmarks,rghRows,rgRowStatus)	\
    (This)->lpVtbl -> GetRowsByBookmark(This,hReserved,cRows,rgcbBookmarks,rgpBookmarks,rghRows,rgRowStatus)

#define IRowsetExactScroll_Hash(This,hReserved,cBookmarks,rgcbBookmarks,rgpBookmarks,rgHashedValues,rgBookmarkStatus)	\
    (This)->lpVtbl -> Hash(This,hReserved,cBookmarks,rgcbBookmarks,rgpBookmarks,rgHashedValues,rgBookmarkStatus)


#define IRowsetExactScroll_GetApproximatePosition(This,hReserved,cbBookmark,pBookmark,pulPosition,pcRows)	\
    (This)->lpVtbl -> GetApproximatePosition(This,hReserved,cbBookmark,pBookmark,pulPosition,pcRows)

#define IRowsetExactScroll_GetRowsAtRatio(This,hReserved1,hReserved2,ulNumerator,ulDenominator,cRows,pcRowsObtained,prghRows)	\
    (This)->lpVtbl -> GetRowsAtRatio(This,hReserved1,hReserved2,ulNumerator,ulDenominator,cRows,pcRowsObtained,prghRows)


#define IRowsetExactScroll_GetExactPosition(This,hChapter,cbBookmark,pBookmark,pulPosition,pcRows)	\
    (This)->lpVtbl -> GetExactPosition(This,hChapter,cbBookmark,pBookmark,pulPosition,pcRows)

#endif /* COBJMACROS */


#endif 	/* C style interface */



HRESULT STDMETHODCALLTYPE IRowsetExactScroll_GetExactPosition_Proxy( 
    IRowsetExactScroll __RPC_FAR * This,
    /* [in] */ HCHAPTER hChapter,
    /* [in] */ ULONG cbBookmark,
    /* [size_is][in] */ const BYTE __RPC_FAR *pBookmark,
    /* [out] */ ULONG __RPC_FAR *pulPosition,
    /* [out] */ ULONG __RPC_FAR *pcRows);


void __RPC_STUB IRowsetExactScroll_GetExactPosition_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __IRowsetExactScroll_INTERFACE_DEFINED__ */


/****************************************
 * Generated header for interface: __MIDL_itf_oledb_0171
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [local] */ 


#endif // deprecated
//@@@- deprecated


extern RPC_IF_HANDLE __MIDL_itf_oledb_0171_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_oledb_0171_v0_0_s_ifspec;

#ifndef __IRowsetChange_INTERFACE_DEFINED__
#define __IRowsetChange_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: IRowsetChange
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object][local] */ 



EXTERN_C const IID IID_IRowsetChange;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733a05-2a1c-11ce-ade5-00aa0044773d")
    IRowsetChange : public IUnknown
    {
    public:
        virtual HRESULT STDMETHODCALLTYPE DeleteRows( 
            /* [in] */ HCHAPTER hReserved,
            /* [in] */ ULONG cRows,
            /* [size_is][in] */ const HROW __RPC_FAR rghRows[  ],
            /* [size_is][out] */ DBROWSTATUS __RPC_FAR rgRowStatus[  ]) = 0;
        
        virtual HRESULT STDMETHODCALLTYPE SetData( 
            /* [in] */ HROW hRow,
            /* [in] */ HACCESSOR hAccessor,
            /* [in] */ void __RPC_FAR *pData) = 0;
        
        virtual HRESULT STDMETHODCALLTYPE InsertRow( 
            /* [in] */ HCHAPTER hReserved,
            /* [in] */ HACCESSOR hAccessor,
            /* [in] */ void __RPC_FAR *pData,
            /* [out] */ HROW __RPC_FAR *phRow) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct IRowsetChangeVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            IRowsetChange __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            IRowsetChange __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            IRowsetChange __RPC_FAR * This);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *DeleteRows )( 
            IRowsetChange __RPC_FAR * This,
            /* [in] */ HCHAPTER hReserved,
            /* [in] */ ULONG cRows,
            /* [size_is][in] */ const HROW __RPC_FAR rghRows[  ],
            /* [size_is][out] */ DBROWSTATUS __RPC_FAR rgRowStatus[  ]);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *SetData )( 
            IRowsetChange __RPC_FAR * This,
            /* [in] */ HROW hRow,
            /* [in] */ HACCESSOR hAccessor,
            /* [in] */ void __RPC_FAR *pData);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *InsertRow )( 
            IRowsetChange __RPC_FAR * This,
            /* [in] */ HCHAPTER hReserved,
            /* [in] */ HACCESSOR hAccessor,
            /* [in] */ void __RPC_FAR *pData,
            /* [out] */ HROW __RPC_FAR *phRow);
        
        END_INTERFACE
    } IRowsetChangeVtbl;

    interface IRowsetChange
    {
        CONST_VTBL struct IRowsetChangeVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define IRowsetChange_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define IRowsetChange_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define IRowsetChange_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define IRowsetChange_DeleteRows(This,hReserved,cRows,rghRows,rgRowStatus)	\
    (This)->lpVtbl -> DeleteRows(This,hReserved,cRows,rghRows,rgRowStatus)

#define IRowsetChange_SetData(This,hRow,hAccessor,pData)	\
    (This)->lpVtbl -> SetData(This,hRow,hAccessor,pData)

#define IRowsetChange_InsertRow(This,hReserved,hAccessor,pData,phRow)	\
    (This)->lpVtbl -> InsertRow(This,hReserved,hAccessor,pData,phRow)

#endif /* COBJMACROS */


#endif 	/* C style interface */



HRESULT STDMETHODCALLTYPE IRowsetChange_DeleteRows_Proxy( 
    IRowsetChange __RPC_FAR * This,
    /* [in] */ HCHAPTER hReserved,
    /* [in] */ ULONG cRows,
    /* [size_is][in] */ const HROW __RPC_FAR rghRows[  ],
    /* [size_is][out] */ DBROWSTATUS __RPC_FAR rgRowStatus[  ]);


void __RPC_STUB IRowsetChange_DeleteRows_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


HRESULT STDMETHODCALLTYPE IRowsetChange_SetData_Proxy( 
    IRowsetChange __RPC_FAR * This,
    /* [in] */ HROW hRow,
    /* [in] */ HACCESSOR hAccessor,
    /* [in] */ void __RPC_FAR *pData);


void __RPC_STUB IRowsetChange_SetData_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


HRESULT STDMETHODCALLTYPE IRowsetChange_InsertRow_Proxy( 
    IRowsetChange __RPC_FAR * This,
    /* [in] */ HCHAPTER hReserved,
    /* [in] */ HACCESSOR hAccessor,
    /* [in] */ void __RPC_FAR *pData,
    /* [out] */ HROW __RPC_FAR *phRow);


void __RPC_STUB IRowsetChange_InsertRow_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __IRowsetChange_INTERFACE_DEFINED__ */


#ifndef __IRowsetUpdate_INTERFACE_DEFINED__
#define __IRowsetUpdate_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: IRowsetUpdate
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object][local] */ 


typedef DWORD DBPENDINGSTATUS;


enum DBPENDINGSTATUSENUM
    {	DBPENDINGSTATUS_NEW	= 0x1,
	DBPENDINGSTATUS_CHANGED	= 0x2,
	DBPENDINGSTATUS_DELETED	= 0x4,
	DBPENDINGSTATUS_UNCHANGED	= 0x8,
	DBPENDINGSTATUS_INVALIDROW	= 0x10
    };

EXTERN_C const IID IID_IRowsetUpdate;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733a6d-2a1c-11ce-ade5-00aa0044773d")
    IRowsetUpdate : public IRowsetChange
    {
    public:
        virtual HRESULT STDMETHODCALLTYPE GetOriginalData( 
            /* [in] */ HROW hRow,
            /* [in] */ HACCESSOR hAccessor,
            /* [out] */ void __RPC_FAR *pData) = 0;
        
        virtual HRESULT STDMETHODCALLTYPE GetPendingRows( 
            /* [in] */ HCHAPTER hReserved,
            /* [in] */ DBPENDINGSTATUS dwRowStatus,
            /* [out][in] */ ULONG __RPC_FAR *pcPendingRows,
            /* [size_is][size_is][out] */ HROW __RPC_FAR *__RPC_FAR *prgPendingRows,
            /* [size_is][size_is][out] */ DBPENDINGSTATUS __RPC_FAR *__RPC_FAR *prgPendingStatus) = 0;
        
        virtual HRESULT STDMETHODCALLTYPE GetRowStatus( 
            /* [in] */ HCHAPTER hReserved,
            /* [in] */ ULONG cRows,
            /* [size_is][in] */ const HROW __RPC_FAR rghRows[  ],
            /* [size_is][out] */ DBPENDINGSTATUS __RPC_FAR rgPendingStatus[  ]) = 0;
        
        virtual HRESULT STDMETHODCALLTYPE Undo( 
            /* [in] */ HCHAPTER hReserved,
            /* [in] */ ULONG cRows,
            /* [size_is][in] */ const HROW __RPC_FAR rghRows[  ],
            /* [out][in] */ ULONG __RPC_FAR *pcRowsUndone,
            /* [size_is][size_is][out] */ HROW __RPC_FAR *__RPC_FAR *prgRowsUndone,
            /* [size_is][size_is][out] */ DBROWSTATUS __RPC_FAR *__RPC_FAR *prgRowStatus) = 0;
        
        virtual HRESULT STDMETHODCALLTYPE Update( 
            /* [in] */ HCHAPTER hReserved,
            /* [in] */ ULONG cRows,
            /* [size_is][in] */ const HROW __RPC_FAR rghRows[  ],
            /* [out][in] */ ULONG __RPC_FAR *pcRows,
            /* [size_is][size_is][out] */ HROW __RPC_FAR *__RPC_FAR *prgRows,
            /* [size_is][size_is][out] */ DBROWSTATUS __RPC_FAR *__RPC_FAR *prgRowStatus) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct IRowsetUpdateVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            IRowsetUpdate __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            IRowsetUpdate __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            IRowsetUpdate __RPC_FAR * This);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *DeleteRows )( 
            IRowsetUpdate __RPC_FAR * This,
            /* [in] */ HCHAPTER hReserved,
            /* [in] */ ULONG cRows,
            /* [size_is][in] */ const HROW __RPC_FAR rghRows[  ],
            /* [size_is][out] */ DBROWSTATUS __RPC_FAR rgRowStatus[  ]);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *SetData )( 
            IRowsetUpdate __RPC_FAR * This,
            /* [in] */ HROW hRow,
            /* [in] */ HACCESSOR hAccessor,
            /* [in] */ void __RPC_FAR *pData);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *InsertRow )( 
            IRowsetUpdate __RPC_FAR * This,
            /* [in] */ HCHAPTER hReserved,
            /* [in] */ HACCESSOR hAccessor,
            /* [in] */ void __RPC_FAR *pData,
            /* [out] */ HROW __RPC_FAR *phRow);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetOriginalData )( 
            IRowsetUpdate __RPC_FAR * This,
            /* [in] */ HROW hRow,
            /* [in] */ HACCESSOR hAccessor,
            /* [out] */ void __RPC_FAR *pData);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetPendingRows )( 
            IRowsetUpdate __RPC_FAR * This,
            /* [in] */ HCHAPTER hReserved,
            /* [in] */ DBPENDINGSTATUS dwRowStatus,
            /* [out][in] */ ULONG __RPC_FAR *pcPendingRows,
            /* [size_is][size_is][out] */ HROW __RPC_FAR *__RPC_FAR *prgPendingRows,
            /* [size_is][size_is][out] */ DBPENDINGSTATUS __RPC_FAR *__RPC_FAR *prgPendingStatus);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetRowStatus )( 
            IRowsetUpdate __RPC_FAR * This,
            /* [in] */ HCHAPTER hReserved,
            /* [in] */ ULONG cRows,
            /* [size_is][in] */ const HROW __RPC_FAR rghRows[  ],
            /* [size_is][out] */ DBPENDINGSTATUS __RPC_FAR rgPendingStatus[  ]);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Undo )( 
            IRowsetUpdate __RPC_FAR * This,
            /* [in] */ HCHAPTER hReserved,
            /* [in] */ ULONG cRows,
            /* [size_is][in] */ const HROW __RPC_FAR rghRows[  ],
            /* [out][in] */ ULONG __RPC_FAR *pcRowsUndone,
            /* [size_is][size_is][out] */ HROW __RPC_FAR *__RPC_FAR *prgRowsUndone,
            /* [size_is][size_is][out] */ DBROWSTATUS __RPC_FAR *__RPC_FAR *prgRowStatus);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Update )( 
            IRowsetUpdate __RPC_FAR * This,
            /* [in] */ HCHAPTER hReserved,
            /* [in] */ ULONG cRows,
            /* [size_is][in] */ const HROW __RPC_FAR rghRows[  ],
            /* [out][in] */ ULONG __RPC_FAR *pcRows,
            /* [size_is][size_is][out] */ HROW __RPC_FAR *__RPC_FAR *prgRows,
            /* [size_is][size_is][out] */ DBROWSTATUS __RPC_FAR *__RPC_FAR *prgRowStatus);
        
        END_INTERFACE
    } IRowsetUpdateVtbl;

    interface IRowsetUpdate
    {
        CONST_VTBL struct IRowsetUpdateVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define IRowsetUpdate_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define IRowsetUpdate_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define IRowsetUpdate_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define IRowsetUpdate_DeleteRows(This,hReserved,cRows,rghRows,rgRowStatus)	\
    (This)->lpVtbl -> DeleteRows(This,hReserved,cRows,rghRows,rgRowStatus)

#define IRowsetUpdate_SetData(This,hRow,hAccessor,pData)	\
    (This)->lpVtbl -> SetData(This,hRow,hAccessor,pData)

#define IRowsetUpdate_InsertRow(This,hReserved,hAccessor,pData,phRow)	\
    (This)->lpVtbl -> InsertRow(This,hReserved,hAccessor,pData,phRow)


#define IRowsetUpdate_GetOriginalData(This,hRow,hAccessor,pData)	\
    (This)->lpVtbl -> GetOriginalData(This,hRow,hAccessor,pData)

#define IRowsetUpdate_GetPendingRows(This,hReserved,dwRowStatus,pcPendingRows,prgPendingRows,prgPendingStatus)	\
    (This)->lpVtbl -> GetPendingRows(This,hReserved,dwRowStatus,pcPendingRows,prgPendingRows,prgPendingStatus)

#define IRowsetUpdate_GetRowStatus(This,hReserved,cRows,rghRows,rgPendingStatus)	\
    (This)->lpVtbl -> GetRowStatus(This,hReserved,cRows,rghRows,rgPendingStatus)

#define IRowsetUpdate_Undo(This,hReserved,cRows,rghRows,pcRowsUndone,prgRowsUndone,prgRowStatus)	\
    (This)->lpVtbl -> Undo(This,hReserved,cRows,rghRows,pcRowsUndone,prgRowsUndone,prgRowStatus)

#define IRowsetUpdate_Update(This,hReserved,cRows,rghRows,pcRows,prgRows,prgRowStatus)	\
    (This)->lpVtbl -> Update(This,hReserved,cRows,rghRows,pcRows,prgRows,prgRowStatus)

#endif /* COBJMACROS */


#endif 	/* C style interface */



HRESULT STDMETHODCALLTYPE IRowsetUpdate_GetOriginalData_Proxy( 
    IRowsetUpdate __RPC_FAR * This,
    /* [in] */ HROW hRow,
    /* [in] */ HACCESSOR hAccessor,
    /* [out] */ void __RPC_FAR *pData);


void __RPC_STUB IRowsetUpdate_GetOriginalData_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


HRESULT STDMETHODCALLTYPE IRowsetUpdate_GetPendingRows_Proxy( 
    IRowsetUpdate __RPC_FAR * This,
    /* [in] */ HCHAPTER hReserved,
    /* [in] */ DBPENDINGSTATUS dwRowStatus,
    /* [out][in] */ ULONG __RPC_FAR *pcPendingRows,
    /* [size_is][size_is][out] */ HROW __RPC_FAR *__RPC_FAR *prgPendingRows,
    /* [size_is][size_is][out] */ DBPENDINGSTATUS __RPC_FAR *__RPC_FAR *prgPendingStatus);


void __RPC_STUB IRowsetUpdate_GetPendingRows_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


HRESULT STDMETHODCALLTYPE IRowsetUpdate_GetRowStatus_Proxy( 
    IRowsetUpdate __RPC_FAR * This,
    /* [in] */ HCHAPTER hReserved,
    /* [in] */ ULONG cRows,
    /* [size_is][in] */ const HROW __RPC_FAR rghRows[  ],
    /* [size_is][out] */ DBPENDINGSTATUS __RPC_FAR rgPendingStatus[  ]);


void __RPC_STUB IRowsetUpdate_GetRowStatus_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


HRESULT STDMETHODCALLTYPE IRowsetUpdate_Undo_Proxy( 
    IRowsetUpdate __RPC_FAR * This,
    /* [in] */ HCHAPTER hReserved,
    /* [in] */ ULONG cRows,
    /* [size_is][in] */ const HROW __RPC_FAR rghRows[  ],
    /* [out][in] */ ULONG __RPC_FAR *pcRowsUndone,
    /* [size_is][size_is][out] */ HROW __RPC_FAR *__RPC_FAR *prgRowsUndone,
    /* [size_is][size_is][out] */ DBROWSTATUS __RPC_FAR *__RPC_FAR *prgRowStatus);


void __RPC_STUB IRowsetUpdate_Undo_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


HRESULT STDMETHODCALLTYPE IRowsetUpdate_Update_Proxy( 
    IRowsetUpdate __RPC_FAR * This,
    /* [in] */ HCHAPTER hReserved,
    /* [in] */ ULONG cRows,
    /* [size_is][in] */ const HROW __RPC_FAR rghRows[  ],
    /* [out][in] */ ULONG __RPC_FAR *pcRows,
    /* [size_is][size_is][out] */ HROW __RPC_FAR *__RPC_FAR *prgRows,
    /* [size_is][size_is][out] */ DBROWSTATUS __RPC_FAR *__RPC_FAR *prgRowStatus);


void __RPC_STUB IRowsetUpdate_Update_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __IRowsetUpdate_INTERFACE_DEFINED__ */


#ifndef __IRowsetIdentity_INTERFACE_DEFINED__
#define __IRowsetIdentity_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: IRowsetIdentity
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object] */ 



EXTERN_C const IID IID_IRowsetIdentity;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733a09-2a1c-11ce-ade5-00aa0044773d")
    IRowsetIdentity : public IUnknown
    {
    public:
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE IsSameRow( 
            /* [in] */ HROW hThisRow,
            /* [in] */ HROW hThatRow) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct IRowsetIdentityVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            IRowsetIdentity __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            IRowsetIdentity __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            IRowsetIdentity __RPC_FAR * This);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *IsSameRow )( 
            IRowsetIdentity __RPC_FAR * This,
            /* [in] */ HROW hThisRow,
            /* [in] */ HROW hThatRow);
        
        END_INTERFACE
    } IRowsetIdentityVtbl;

    interface IRowsetIdentity
    {
        CONST_VTBL struct IRowsetIdentityVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define IRowsetIdentity_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define IRowsetIdentity_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define IRowsetIdentity_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define IRowsetIdentity_IsSameRow(This,hThisRow,hThatRow)	\
    (This)->lpVtbl -> IsSameRow(This,hThisRow,hThatRow)

#endif /* COBJMACROS */


#endif 	/* C style interface */



/* [call_as] */ HRESULT STDMETHODCALLTYPE IRowsetIdentity_RemoteIsSameRow_Proxy( 
    IRowsetIdentity __RPC_FAR * This,
    /* [in] */ HROW hThisRow,
    /* [in] */ HROW hThatRow,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IRowsetIdentity_RemoteIsSameRow_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __IRowsetIdentity_INTERFACE_DEFINED__ */


#ifndef __IRowsetNotify_INTERFACE_DEFINED__
#define __IRowsetNotify_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: IRowsetNotify
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object] */ 



EXTERN_C const IID IID_IRowsetNotify;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733a83-2a1c-11ce-ade5-00aa0044773d")
    IRowsetNotify : public IUnknown
    {
    public:
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE OnFieldChange( 
            /* [in] */ IRowset __RPC_FAR *pRowset,
            /* [in] */ HROW hRow,
            /* [in] */ ULONG cColumns,
            /* [size_is][in] */ ULONG __RPC_FAR rgColumns[  ],
            /* [in] */ DBREASON eReason,
            /* [in] */ DBEVENTPHASE ePhase,
            /* [in] */ BOOL fCantDeny) = 0;
        
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE OnRowChange( 
            /* [in] */ IRowset __RPC_FAR *pRowset,
            /* [in] */ ULONG cRows,
            /* [size_is][in] */ const HROW __RPC_FAR rghRows[  ],
            /* [in] */ DBREASON eReason,
            /* [in] */ DBEVENTPHASE ePhase,
            /* [in] */ BOOL fCantDeny) = 0;
        
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE OnRowsetChange( 
            /* [in] */ IRowset __RPC_FAR *pRowset,
            /* [in] */ DBREASON eReason,
            /* [in] */ DBEVENTPHASE ePhase,
            /* [in] */ BOOL fCantDeny) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct IRowsetNotifyVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            IRowsetNotify __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            IRowsetNotify __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            IRowsetNotify __RPC_FAR * This);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *OnFieldChange )( 
            IRowsetNotify __RPC_FAR * This,
            /* [in] */ IRowset __RPC_FAR *pRowset,
            /* [in] */ HROW hRow,
            /* [in] */ ULONG cColumns,
            /* [size_is][in] */ ULONG __RPC_FAR rgColumns[  ],
            /* [in] */ DBREASON eReason,
            /* [in] */ DBEVENTPHASE ePhase,
            /* [in] */ BOOL fCantDeny);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *OnRowChange )( 
            IRowsetNotify __RPC_FAR * This,
            /* [in] */ IRowset __RPC_FAR *pRowset,
            /* [in] */ ULONG cRows,
            /* [size_is][in] */ const HROW __RPC_FAR rghRows[  ],
            /* [in] */ DBREASON eReason,
            /* [in] */ DBEVENTPHASE ePhase,
            /* [in] */ BOOL fCantDeny);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *OnRowsetChange )( 
            IRowsetNotify __RPC_FAR * This,
            /* [in] */ IRowset __RPC_FAR *pRowset,
            /* [in] */ DBREASON eReason,
            /* [in] */ DBEVENTPHASE ePhase,
            /* [in] */ BOOL fCantDeny);
        
        END_INTERFACE
    } IRowsetNotifyVtbl;

    interface IRowsetNotify
    {
        CONST_VTBL struct IRowsetNotifyVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define IRowsetNotify_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define IRowsetNotify_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define IRowsetNotify_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define IRowsetNotify_OnFieldChange(This,pRowset,hRow,cColumns,rgColumns,eReason,ePhase,fCantDeny)	\
    (This)->lpVtbl -> OnFieldChange(This,pRowset,hRow,cColumns,rgColumns,eReason,ePhase,fCantDeny)

#define IRowsetNotify_OnRowChange(This,pRowset,cRows,rghRows,eReason,ePhase,fCantDeny)	\
    (This)->lpVtbl -> OnRowChange(This,pRowset,cRows,rghRows,eReason,ePhase,fCantDeny)

#define IRowsetNotify_OnRowsetChange(This,pRowset,eReason,ePhase,fCantDeny)	\
    (This)->lpVtbl -> OnRowsetChange(This,pRowset,eReason,ePhase,fCantDeny)

#endif /* COBJMACROS */


#endif 	/* C style interface */



/* [call_as] */ HRESULT STDMETHODCALLTYPE IRowsetNotify_RemoteOnFieldChange_Proxy( 
    IRowsetNotify __RPC_FAR * This,
    /* [in] */ IRowset __RPC_FAR *pRowset,
    /* [in] */ HROW hRow,
    /* [in] */ ULONG cColumns,
    /* [size_is][in] */ ULONG __RPC_FAR *rgColumns,
    /* [in] */ DBREASON eReason,
    /* [in] */ DBEVENTPHASE ePhase,
    /* [in] */ BOOL fCantDeny,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IRowsetNotify_RemoteOnFieldChange_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IRowsetNotify_RemoteOnRowChange_Proxy( 
    IRowsetNotify __RPC_FAR * This,
    /* [in] */ IRowset __RPC_FAR *pRowset,
    /* [in] */ ULONG cRows,
    /* [size_is][in] */ const HROW __RPC_FAR *rghRows,
    /* [in] */ DBREASON eReason,
    /* [in] */ DBEVENTPHASE ePhase,
    /* [in] */ BOOL fCantDeny,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IRowsetNotify_RemoteOnRowChange_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IRowsetNotify_RemoteOnRowsetChange_Proxy( 
    IRowsetNotify __RPC_FAR * This,
    /* [in] */ IRowset __RPC_FAR *pRowset,
    /* [in] */ DBREASON eReason,
    /* [in] */ DBEVENTPHASE ePhase,
    /* [in] */ BOOL fCantDeny,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IRowsetNotify_RemoteOnRowsetChange_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __IRowsetNotify_INTERFACE_DEFINED__ */


#ifndef __IRowsetIndex_INTERFACE_DEFINED__
#define __IRowsetIndex_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: IRowsetIndex
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object][local] */ 


typedef DWORD DBSEEK;


enum DBSEEKENUM
    {	DBSEEK_INVALID	= 0,
	DBSEEK_FIRSTEQ	= 0x1,
	DBSEEK_LASTEQ	= 0x2,
	DBSEEK_AFTEREQ	= 0x4,
	DBSEEK_AFTER	= 0x8,
	DBSEEK_BEFOREEQ	= 0x10,
	DBSEEK_BEFORE	= 0x20
    };
#define	DBSEEK_GE	DBSEEK_AFTEREQ
#define	DBSEEK_GT	DBSEEK_AFTER
#define	DBSEEK_LE	DBSEEK_BEFOREEQ
#define	DBSEEK_LT	DBSEEK_BEFORE
typedef DWORD DBRANGE;


enum DBRANGEENUM
    {	DBRANGE_INCLUSIVESTART	= 0,
	DBRANGE_INCLUSIVEEND	= 0,
	DBRANGE_EXCLUSIVESTART	= 0x1,
	DBRANGE_EXCLUSIVEEND	= 0x2,
	DBRANGE_EXCLUDENULLS	= 0x4,
	DBRANGE_PREFIX	= 0x8,
	DBRANGE_MATCH	= 0x10
    };

enum DBRANGEENUM20
    {	DBRANGE_MATCH_N_SHIFT	= 0x18,
	DBRANGE_MATCH_N_MASK	= 0xff
    };

EXTERN_C const IID IID_IRowsetIndex;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733a82-2a1c-11ce-ade5-00aa0044773d")
    IRowsetIndex : public IUnknown
    {
    public:
        virtual HRESULT STDMETHODCALLTYPE GetIndexInfo( 
            /* [out][in] */ ULONG __RPC_FAR *pcKeyColumns,
            /* [size_is][size_is][out] */ DBINDEXCOLUMNDESC __RPC_FAR *__RPC_FAR *prgIndexColumnDesc,
            /* [out][in] */ ULONG __RPC_FAR *pcIndexProperties,
            /* [size_is][size_is][out] */ DBPROPSET __RPC_FAR *__RPC_FAR *prgIndexProperties) = 0;
        
        virtual HRESULT STDMETHODCALLTYPE Seek( 
            /* [in] */ HACCESSOR hAccessor,
            /* [in] */ ULONG cKeyValues,
            /* [in] */ void __RPC_FAR *pData,
            /* [in] */ DBSEEK dwSeekOptions) = 0;
        
        virtual HRESULT STDMETHODCALLTYPE SetRange( 
            /* [in] */ HACCESSOR hAccessor,
            /* [in] */ ULONG cStartKeyColumns,
            /* [in] */ void __RPC_FAR *pStartData,
            /* [in] */ ULONG cEndKeyColumns,
            /* [in] */ void __RPC_FAR *pEndData,
            /* [in] */ DBRANGE dwRangeOptions) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct IRowsetIndexVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            IRowsetIndex __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            IRowsetIndex __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            IRowsetIndex __RPC_FAR * This);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetIndexInfo )( 
            IRowsetIndex __RPC_FAR * This,
            /* [out][in] */ ULONG __RPC_FAR *pcKeyColumns,
            /* [size_is][size_is][out] */ DBINDEXCOLUMNDESC __RPC_FAR *__RPC_FAR *prgIndexColumnDesc,
            /* [out][in] */ ULONG __RPC_FAR *pcIndexProperties,
            /* [size_is][size_is][out] */ DBPROPSET __RPC_FAR *__RPC_FAR *prgIndexProperties);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Seek )( 
            IRowsetIndex __RPC_FAR * This,
            /* [in] */ HACCESSOR hAccessor,
            /* [in] */ ULONG cKeyValues,
            /* [in] */ void __RPC_FAR *pData,
            /* [in] */ DBSEEK dwSeekOptions);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *SetRange )( 
            IRowsetIndex __RPC_FAR * This,
            /* [in] */ HACCESSOR hAccessor,
            /* [in] */ ULONG cStartKeyColumns,
            /* [in] */ void __RPC_FAR *pStartData,
            /* [in] */ ULONG cEndKeyColumns,
            /* [in] */ void __RPC_FAR *pEndData,
            /* [in] */ DBRANGE dwRangeOptions);
        
        END_INTERFACE
    } IRowsetIndexVtbl;

    interface IRowsetIndex
    {
        CONST_VTBL struct IRowsetIndexVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define IRowsetIndex_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define IRowsetIndex_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define IRowsetIndex_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define IRowsetIndex_GetIndexInfo(This,pcKeyColumns,prgIndexColumnDesc,pcIndexProperties,prgIndexProperties)	\
    (This)->lpVtbl -> GetIndexInfo(This,pcKeyColumns,prgIndexColumnDesc,pcIndexProperties,prgIndexProperties)

#define IRowsetIndex_Seek(This,hAccessor,cKeyValues,pData,dwSeekOptions)	\
    (This)->lpVtbl -> Seek(This,hAccessor,cKeyValues,pData,dwSeekOptions)

#define IRowsetIndex_SetRange(This,hAccessor,cStartKeyColumns,pStartData,cEndKeyColumns,pEndData,dwRangeOptions)	\
    (This)->lpVtbl -> SetRange(This,hAccessor,cStartKeyColumns,pStartData,cEndKeyColumns,pEndData,dwRangeOptions)

#endif /* COBJMACROS */


#endif 	/* C style interface */



HRESULT STDMETHODCALLTYPE IRowsetIndex_GetIndexInfo_Proxy( 
    IRowsetIndex __RPC_FAR * This,
    /* [out][in] */ ULONG __RPC_FAR *pcKeyColumns,
    /* [size_is][size_is][out] */ DBINDEXCOLUMNDESC __RPC_FAR *__RPC_FAR *prgIndexColumnDesc,
    /* [out][in] */ ULONG __RPC_FAR *pcIndexProperties,
    /* [size_is][size_is][out] */ DBPROPSET __RPC_FAR *__RPC_FAR *prgIndexProperties);


void __RPC_STUB IRowsetIndex_GetIndexInfo_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


HRESULT STDMETHODCALLTYPE IRowsetIndex_Seek_Proxy( 
    IRowsetIndex __RPC_FAR * This,
    /* [in] */ HACCESSOR hAccessor,
    /* [in] */ ULONG cKeyValues,
    /* [in] */ void __RPC_FAR *pData,
    /* [in] */ DBSEEK dwSeekOptions);


void __RPC_STUB IRowsetIndex_Seek_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


HRESULT STDMETHODCALLTYPE IRowsetIndex_SetRange_Proxy( 
    IRowsetIndex __RPC_FAR * This,
    /* [in] */ HACCESSOR hAccessor,
    /* [in] */ ULONG cStartKeyColumns,
    /* [in] */ void __RPC_FAR *pStartData,
    /* [in] */ ULONG cEndKeyColumns,
    /* [in] */ void __RPC_FAR *pEndData,
    /* [in] */ DBRANGE dwRangeOptions);


void __RPC_STUB IRowsetIndex_SetRange_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __IRowsetIndex_INTERFACE_DEFINED__ */


#ifndef __ICommand_INTERFACE_DEFINED__
#define __ICommand_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: ICommand
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object] */ 



EXTERN_C const IID IID_ICommand;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733a63-2a1c-11ce-ade5-00aa0044773d")
    ICommand : public IUnknown
    {
    public:
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE Cancel( void) = 0;
        
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE Execute( 
            /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
            /* [in] */ REFIID riid,
            /* [out][in] */ DBPARAMS __RPC_FAR *pParams,
            /* [out] */ LONG __RPC_FAR *pcRowsAffected,
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset) = 0;
        
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetDBSession( 
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppSession) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct ICommandVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            ICommand __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            ICommand __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            ICommand __RPC_FAR * This);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Cancel )( 
            ICommand __RPC_FAR * This);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Execute )( 
            ICommand __RPC_FAR * This,
            /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
            /* [in] */ REFIID riid,
            /* [out][in] */ DBPARAMS __RPC_FAR *pParams,
            /* [out] */ LONG __RPC_FAR *pcRowsAffected,
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetDBSession )( 
            ICommand __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppSession);
        
        END_INTERFACE
    } ICommandVtbl;

    interface ICommand
    {
        CONST_VTBL struct ICommandVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define ICommand_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define ICommand_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define ICommand_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define ICommand_Cancel(This)	\
    (This)->lpVtbl -> Cancel(This)

#define ICommand_Execute(This,pUnkOuter,riid,pParams,pcRowsAffected,ppRowset)	\
    (This)->lpVtbl -> Execute(This,pUnkOuter,riid,pParams,pcRowsAffected,ppRowset)

#define ICommand_GetDBSession(This,riid,ppSession)	\
    (This)->lpVtbl -> GetDBSession(This,riid,ppSession)

#endif /* COBJMACROS */


#endif 	/* C style interface */



/* [call_as] */ HRESULT STDMETHODCALLTYPE ICommand_RemoteCancel_Proxy( 
    ICommand __RPC_FAR * This,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB ICommand_RemoteCancel_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


/* [call_as] */ HRESULT STDMETHODCALLTYPE ICommand_RemoteExecute_Proxy( 
    ICommand __RPC_FAR * This,
    /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
    /* [in] */ REFIID riid,
    /* [in] */ HACCESSOR hAccessor,
    /* [in] */ ULONG cParamSets,
    /* [in] */ ULONG cbData,
    /* [size_is][unique][out][in] */ BYTE __RPC_FAR *pbData,
    /* [unique][out][in] */ LONG __RPC_FAR *pcRowsAffected,
    /* [iid_is][unique][out][in] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB ICommand_RemoteExecute_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


/* [call_as] */ HRESULT STDMETHODCALLTYPE ICommand_RemoteGetDBSession_Proxy( 
    ICommand __RPC_FAR * This,
    /* [in] */ REFIID riid,
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppSession,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB ICommand_RemoteGetDBSession_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __ICommand_INTERFACE_DEFINED__ */


#ifndef __IMultipleResults_INTERFACE_DEFINED__
#define __IMultipleResults_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: IMultipleResults
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object] */ 



EXTERN_C const IID IID_IMultipleResults;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733a90-2a1c-11ce-ade5-00aa0044773d")
    IMultipleResults : public IUnknown
    {
    public:
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetResult( 
            /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
            /* [in] */ LONG reserved,
            /* [in] */ REFIID riid,
            /* [out] */ LONG __RPC_FAR *pcRowsAffected,
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct IMultipleResultsVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            IMultipleResults __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            IMultipleResults __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            IMultipleResults __RPC_FAR * This);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetResult )( 
            IMultipleResults __RPC_FAR * This,
            /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
            /* [in] */ LONG reserved,
            /* [in] */ REFIID riid,
            /* [out] */ LONG __RPC_FAR *pcRowsAffected,
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset);
        
        END_INTERFACE
    } IMultipleResultsVtbl;

    interface IMultipleResults
    {
        CONST_VTBL struct IMultipleResultsVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define IMultipleResults_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define IMultipleResults_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define IMultipleResults_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define IMultipleResults_GetResult(This,pUnkOuter,reserved,riid,pcRowsAffected,ppRowset)	\
    (This)->lpVtbl -> GetResult(This,pUnkOuter,reserved,riid,pcRowsAffected,ppRowset)

#endif /* COBJMACROS */


#endif 	/* C style interface */



/* [call_as] */ HRESULT STDMETHODCALLTYPE IMultipleResults_RemoteGetResult_Proxy( 
    IMultipleResults __RPC_FAR * This,
    /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
    /* [in] */ LONG reserved,
    /* [in] */ REFIID riid,
    /* [unique][out][in] */ LONG __RPC_FAR *pcRowsAffected,
    /* [iid_is][unique][out][in] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IMultipleResults_RemoteGetResult_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __IMultipleResults_INTERFACE_DEFINED__ */


#ifndef __IConvertType_INTERFACE_DEFINED__
#define __IConvertType_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: IConvertType
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object] */ 


typedef DWORD DBCONVERTFLAGS;


enum DBCONVERTFLAGSENUM
    {	DBCONVERTFLAGS_COLUMN	= 0,
	DBCONVERTFLAGS_PARAMETER	= 0x1
    };

enum DBCONVERTFLAGSENUM20
    {	DBCONVERTFLAGS_ISLONG	= 0x2,
	DBCONVERTFLAGS_ISFIXEDLENGTH	= 0x4,
	DBCONVERTFLAGS_FROMVARIANT	= 0x8
    };

EXTERN_C const IID IID_IConvertType;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733a88-2a1c-11ce-ade5-00aa0044773d")
    IConvertType : public IUnknown
    {
    public:
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE CanConvert( 
            /* [in] */ DBTYPE wFromType,
            /* [in] */ DBTYPE wToType,
            /* [in] */ DBCONVERTFLAGS dwConvertFlags) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct IConvertTypeVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            IConvertType __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            IConvertType __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            IConvertType __RPC_FAR * This);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *CanConvert )( 
            IConvertType __RPC_FAR * This,
            /* [in] */ DBTYPE wFromType,
            /* [in] */ DBTYPE wToType,
            /* [in] */ DBCONVERTFLAGS dwConvertFlags);
        
        END_INTERFACE
    } IConvertTypeVtbl;

    interface IConvertType
    {
        CONST_VTBL struct IConvertTypeVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define IConvertType_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define IConvertType_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define IConvertType_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define IConvertType_CanConvert(This,wFromType,wToType,dwConvertFlags)	\
    (This)->lpVtbl -> CanConvert(This,wFromType,wToType,dwConvertFlags)

#endif /* COBJMACROS */


#endif 	/* C style interface */



/* [call_as] */ HRESULT STDMETHODCALLTYPE IConvertType_RemoteCanConvert_Proxy( 
    IConvertType __RPC_FAR * This,
    /* [in] */ DBTYPE wFromType,
    /* [in] */ DBTYPE wToType,
    /* [in] */ DBCONVERTFLAGS dwConvertFlags,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IConvertType_RemoteCanConvert_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __IConvertType_INTERFACE_DEFINED__ */


#ifndef __ICommandPrepare_INTERFACE_DEFINED__
#define __ICommandPrepare_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: ICommandPrepare
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object] */ 



EXTERN_C const IID IID_ICommandPrepare;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733a26-2a1c-11ce-ade5-00aa0044773d")
    ICommandPrepare : public IUnknown
    {
    public:
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE Prepare( 
            /* [in] */ ULONG cExpectedRuns) = 0;
        
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE Unprepare( void) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct ICommandPrepareVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            ICommandPrepare __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            ICommandPrepare __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            ICommandPrepare __RPC_FAR * This);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Prepare )( 
            ICommandPrepare __RPC_FAR * This,
            /* [in] */ ULONG cExpectedRuns);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Unprepare )( 
            ICommandPrepare __RPC_FAR * This);
        
        END_INTERFACE
    } ICommandPrepareVtbl;

    interface ICommandPrepare
    {
        CONST_VTBL struct ICommandPrepareVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define ICommandPrepare_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define ICommandPrepare_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define ICommandPrepare_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define ICommandPrepare_Prepare(This,cExpectedRuns)	\
    (This)->lpVtbl -> Prepare(This,cExpectedRuns)

#define ICommandPrepare_Unprepare(This)	\
    (This)->lpVtbl -> Unprepare(This)

#endif /* COBJMACROS */


#endif 	/* C style interface */



/* [call_as] */ HRESULT STDMETHODCALLTYPE ICommandPrepare_RemotePrepare_Proxy( 
    ICommandPrepare __RPC_FAR * This,
    /* [in] */ ULONG cExpectedRuns,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB ICommandPrepare_RemotePrepare_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


/* [call_as] */ HRESULT STDMETHODCALLTYPE ICommandPrepare_RemoteUnprepare_Proxy( 
    ICommandPrepare __RPC_FAR * This,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB ICommandPrepare_RemoteUnprepare_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __ICommandPrepare_INTERFACE_DEFINED__ */


#ifndef __ICommandProperties_INTERFACE_DEFINED__
#define __ICommandProperties_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: ICommandProperties
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object] */ 



EXTERN_C const IID IID_ICommandProperties;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733a79-2a1c-11ce-ade5-00aa0044773d")
    ICommandProperties : public IUnknown
    {
    public:
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetProperties( 
            /* [in] */ const ULONG cPropertyIDSets,
            /* [size_is][in] */ const DBPROPIDSET __RPC_FAR rgPropertyIDSets[  ],
            /* [out][in] */ ULONG __RPC_FAR *pcPropertySets,
            /* [size_is][size_is][out] */ DBPROPSET __RPC_FAR *__RPC_FAR *prgPropertySets) = 0;
        
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE SetProperties( 
            /* [in] */ ULONG cPropertySets,
            /* [size_is][unique][out][in] */ DBPROPSET __RPC_FAR rgPropertySets[  ]) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct ICommandPropertiesVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            ICommandProperties __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            ICommandProperties __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            ICommandProperties __RPC_FAR * This);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetProperties )( 
            ICommandProperties __RPC_FAR * This,
            /* [in] */ const ULONG cPropertyIDSets,
            /* [size_is][in] */ const DBPROPIDSET __RPC_FAR rgPropertyIDSets[  ],
            /* [out][in] */ ULONG __RPC_FAR *pcPropertySets,
            /* [size_is][size_is][out] */ DBPROPSET __RPC_FAR *__RPC_FAR *prgPropertySets);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *SetProperties )( 
            ICommandProperties __RPC_FAR * This,
            /* [in] */ ULONG cPropertySets,
            /* [size_is][unique][out][in] */ DBPROPSET __RPC_FAR rgPropertySets[  ]);
        
        END_INTERFACE
    } ICommandPropertiesVtbl;

    interface ICommandProperties
    {
        CONST_VTBL struct ICommandPropertiesVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define ICommandProperties_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define ICommandProperties_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define ICommandProperties_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define ICommandProperties_GetProperties(This,cPropertyIDSets,rgPropertyIDSets,pcPropertySets,prgPropertySets)	\
    (This)->lpVtbl -> GetProperties(This,cPropertyIDSets,rgPropertyIDSets,pcPropertySets,prgPropertySets)

#define ICommandProperties_SetProperties(This,cPropertySets,rgPropertySets)	\
    (This)->lpVtbl -> SetProperties(This,cPropertySets,rgPropertySets)

#endif /* COBJMACROS */


#endif 	/* C style interface */



/* [call_as] */ HRESULT STDMETHODCALLTYPE ICommandProperties_RemoteGetProperties_Proxy( 
    ICommandProperties __RPC_FAR * This,
    /* [in] */ const ULONG cPropertyIDSets,
    /* [size_is][unique][in] */ const DBPROPIDSET __RPC_FAR *rgPropertyIDSets,
    /* [out][in] */ ULONG __RPC_FAR *pcPropertySets,
    /* [size_is][size_is][out] */ DBPROPSET __RPC_FAR *__RPC_FAR *prgPropertySets,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB ICommandProperties_RemoteGetProperties_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


/* [call_as] */ HRESULT STDMETHODCALLTYPE ICommandProperties_RemoteSetProperties_Proxy( 
    ICommandProperties __RPC_FAR * This,
    /* [in] */ ULONG cPropertySets,
    /* [size_is][unique][in] */ DBPROPSET __RPC_FAR *rgPropertySets,
    /* [in] */ ULONG cTotalProps,
    /* [size_is][out] */ DBPROPSTATUS __RPC_FAR *rgPropStatus,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB ICommandProperties_RemoteSetProperties_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __ICommandProperties_INTERFACE_DEFINED__ */


#ifndef __ICommandText_INTERFACE_DEFINED__
#define __ICommandText_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: ICommandText
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object] */ 



EXTERN_C const IID IID_ICommandText;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733a27-2a1c-11ce-ade5-00aa0044773d")
    ICommandText : public ICommand
    {
    public:
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetCommandText( 
            /* [out][in] */ GUID __RPC_FAR *pguidDialect,
            /* [out] */ LPOLESTR __RPC_FAR *ppwszCommand) = 0;
        
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE SetCommandText( 
            /* [in] */ REFGUID rguidDialect,
            /* [unique][in] */ LPCOLESTR pwszCommand) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct ICommandTextVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            ICommandText __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            ICommandText __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            ICommandText __RPC_FAR * This);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Cancel )( 
            ICommandText __RPC_FAR * This);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Execute )( 
            ICommandText __RPC_FAR * This,
            /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
            /* [in] */ REFIID riid,
            /* [out][in] */ DBPARAMS __RPC_FAR *pParams,
            /* [out] */ LONG __RPC_FAR *pcRowsAffected,
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetDBSession )( 
            ICommandText __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppSession);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetCommandText )( 
            ICommandText __RPC_FAR * This,
            /* [out][in] */ GUID __RPC_FAR *pguidDialect,
            /* [out] */ LPOLESTR __RPC_FAR *ppwszCommand);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *SetCommandText )( 
            ICommandText __RPC_FAR * This,
            /* [in] */ REFGUID rguidDialect,
            /* [unique][in] */ LPCOLESTR pwszCommand);
        
        END_INTERFACE
    } ICommandTextVtbl;

    interface ICommandText
    {
        CONST_VTBL struct ICommandTextVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define ICommandText_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define ICommandText_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define ICommandText_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define ICommandText_Cancel(This)	\
    (This)->lpVtbl -> Cancel(This)

#define ICommandText_Execute(This,pUnkOuter,riid,pParams,pcRowsAffected,ppRowset)	\
    (This)->lpVtbl -> Execute(This,pUnkOuter,riid,pParams,pcRowsAffected,ppRowset)

#define ICommandText_GetDBSession(This,riid,ppSession)	\
    (This)->lpVtbl -> GetDBSession(This,riid,ppSession)


#define ICommandText_GetCommandText(This,pguidDialect,ppwszCommand)	\
    (This)->lpVtbl -> GetCommandText(This,pguidDialect,ppwszCommand)

#define ICommandText_SetCommandText(This,rguidDialect,pwszCommand)	\
    (This)->lpVtbl -> SetCommandText(This,rguidDialect,pwszCommand)

#endif /* COBJMACROS */


#endif 	/* C style interface */



/* [call_as] */ HRESULT STDMETHODCALLTYPE ICommandText_RemoteGetCommandText_Proxy( 
    ICommandText __RPC_FAR * This,
    /* [unique][out][in] */ GUID __RPC_FAR *pguidDialect,
    /* [out] */ LPOLESTR __RPC_FAR *ppwszCommand,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB ICommandText_RemoteGetCommandText_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


/* [call_as] */ HRESULT STDMETHODCALLTYPE ICommandText_RemoteSetCommandText_Proxy( 
    ICommandText __RPC_FAR * This,
    /* [in] */ REFGUID rguidDialect,
    /* [unique][in] */ LPCOLESTR pwszCommand,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB ICommandText_RemoteSetCommandText_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __ICommandText_INTERFACE_DEFINED__ */


#ifndef __ICommandWithParameters_INTERFACE_DEFINED__
#define __ICommandWithParameters_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: ICommandWithParameters
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object] */ 


typedef struct  tagDBPARAMBINDINFO
    {
    LPOLESTR pwszDataSourceType;
    LPOLESTR pwszName;
    ULONG ulParamSize;
    DBPARAMFLAGS dwFlags;
    BYTE bPrecision;
    BYTE bScale;
    }	DBPARAMBINDINFO;


EXTERN_C const IID IID_ICommandWithParameters;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733a64-2a1c-11ce-ade5-00aa0044773d")
    ICommandWithParameters : public IUnknown
    {
    public:
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetParameterInfo( 
            /* [out][in] */ ULONG __RPC_FAR *pcParams,
            /* [size_is][size_is][out] */ DBPARAMINFO __RPC_FAR *__RPC_FAR *prgParamInfo,
            /* [out] */ OLECHAR __RPC_FAR *__RPC_FAR *ppNamesBuffer) = 0;
        
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE MapParameterNames( 
            /* [in] */ ULONG cParamNames,
            /* [size_is][in] */ const OLECHAR __RPC_FAR *__RPC_FAR rgParamNames[  ],
            /* [size_is][out] */ LONG __RPC_FAR rgParamOrdinals[  ]) = 0;
        
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE SetParameterInfo( 
            /* [in] */ ULONG cParams,
            /* [size_is][unique][in] */ const ULONG __RPC_FAR rgParamOrdinals[  ],
            /* [size_is][unique][in] */ const DBPARAMBINDINFO __RPC_FAR rgParamBindInfo[  ]) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct ICommandWithParametersVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            ICommandWithParameters __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            ICommandWithParameters __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            ICommandWithParameters __RPC_FAR * This);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetParameterInfo )( 
            ICommandWithParameters __RPC_FAR * This,
            /* [out][in] */ ULONG __RPC_FAR *pcParams,
            /* [size_is][size_is][out] */ DBPARAMINFO __RPC_FAR *__RPC_FAR *prgParamInfo,
            /* [out] */ OLECHAR __RPC_FAR *__RPC_FAR *ppNamesBuffer);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *MapParameterNames )( 
            ICommandWithParameters __RPC_FAR * This,
            /* [in] */ ULONG cParamNames,
            /* [size_is][in] */ const OLECHAR __RPC_FAR *__RPC_FAR rgParamNames[  ],
            /* [size_is][out] */ LONG __RPC_FAR rgParamOrdinals[  ]);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *SetParameterInfo )( 
            ICommandWithParameters __RPC_FAR * This,
            /* [in] */ ULONG cParams,
            /* [size_is][unique][in] */ const ULONG __RPC_FAR rgParamOrdinals[  ],
            /* [size_is][unique][in] */ const DBPARAMBINDINFO __RPC_FAR rgParamBindInfo[  ]);
        
        END_INTERFACE
    } ICommandWithParametersVtbl;

    interface ICommandWithParameters
    {
        CONST_VTBL struct ICommandWithParametersVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define ICommandWithParameters_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define ICommandWithParameters_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define ICommandWithParameters_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define ICommandWithParameters_GetParameterInfo(This,pcParams,prgParamInfo,ppNamesBuffer)	\
    (This)->lpVtbl -> GetParameterInfo(This,pcParams,prgParamInfo,ppNamesBuffer)

#define ICommandWithParameters_MapParameterNames(This,cParamNames,rgParamNames,rgParamOrdinals)	\
    (This)->lpVtbl -> MapParameterNames(This,cParamNames,rgParamNames,rgParamOrdinals)

#define ICommandWithParameters_SetParameterInfo(This,cParams,rgParamOrdinals,rgParamBindInfo)	\
    (This)->lpVtbl -> SetParameterInfo(This,cParams,rgParamOrdinals,rgParamBindInfo)

#endif /* COBJMACROS */


#endif 	/* C style interface */



/* [call_as] */ HRESULT STDMETHODCALLTYPE ICommandWithParameters_RemoteGetParameterInfo_Proxy( 
    ICommandWithParameters __RPC_FAR * This,
    /* [out][in] */ ULONG __RPC_FAR *pcParams,
    /* [size_is][size_is][out] */ DBPARAMINFO __RPC_FAR *__RPC_FAR *prgParamInfo,
    /* [size_is][size_is][out] */ ULONG __RPC_FAR *__RPC_FAR *prgNameOffsets,
    /* [out][in] */ ULONG __RPC_FAR *pcbNamesBuffer,
    /* [size_is][size_is][unique][out][in] */ OLECHAR __RPC_FAR *__RPC_FAR *ppNamesBuffer,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB ICommandWithParameters_RemoteGetParameterInfo_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


/* [call_as] */ HRESULT STDMETHODCALLTYPE ICommandWithParameters_RemoteMapParameterNames_Proxy( 
    ICommandWithParameters __RPC_FAR * This,
    /* [in] */ ULONG cParamNames,
    /* [size_is][in] */ LPCOLESTR __RPC_FAR *rgParamNames,
    /* [size_is][out] */ LONG __RPC_FAR *rgParamOrdinals,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB ICommandWithParameters_RemoteMapParameterNames_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


/* [call_as] */ HRESULT STDMETHODCALLTYPE ICommandWithParameters_RemoteSetParameterInfo_Proxy( 
    ICommandWithParameters __RPC_FAR * This,
    /* [in] */ ULONG cParams,
    /* [size_is][unique][in] */ const ULONG __RPC_FAR *rgParamOrdinals,
    /* [size_is][unique][in] */ const DBPARAMBINDINFO __RPC_FAR *rgParamBindInfo,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB ICommandWithParameters_RemoteSetParameterInfo_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __ICommandWithParameters_INTERFACE_DEFINED__ */


#ifndef __IColumnsRowset_INTERFACE_DEFINED__
#define __IColumnsRowset_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: IColumnsRowset
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object] */ 



EXTERN_C const IID IID_IColumnsRowset;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733a10-2a1c-11ce-ade5-00aa0044773d")
    IColumnsRowset : public IUnknown
    {
    public:
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetAvailableColumns( 
            /* [out][in] */ ULONG __RPC_FAR *pcOptColumns,
            /* [size_is][size_is][out] */ DBID __RPC_FAR *__RPC_FAR *prgOptColumns) = 0;
        
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetColumnsRowset( 
            /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
            /* [in] */ ULONG cOptColumns,
            /* [size_is][in] */ const DBID __RPC_FAR rgOptColumns[  ],
            /* [in] */ REFIID riid,
            /* [in] */ ULONG cPropertySets,
            /* [size_is][out][in] */ DBPROPSET __RPC_FAR rgPropertySets[  ],
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppColRowset) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct IColumnsRowsetVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            IColumnsRowset __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            IColumnsRowset __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            IColumnsRowset __RPC_FAR * This);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetAvailableColumns )( 
            IColumnsRowset __RPC_FAR * This,
            /* [out][in] */ ULONG __RPC_FAR *pcOptColumns,
            /* [size_is][size_is][out] */ DBID __RPC_FAR *__RPC_FAR *prgOptColumns);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetColumnsRowset )( 
            IColumnsRowset __RPC_FAR * This,
            /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
            /* [in] */ ULONG cOptColumns,
            /* [size_is][in] */ const DBID __RPC_FAR rgOptColumns[  ],
            /* [in] */ REFIID riid,
            /* [in] */ ULONG cPropertySets,
            /* [size_is][out][in] */ DBPROPSET __RPC_FAR rgPropertySets[  ],
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppColRowset);
        
        END_INTERFACE
    } IColumnsRowsetVtbl;

    interface IColumnsRowset
    {
        CONST_VTBL struct IColumnsRowsetVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define IColumnsRowset_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define IColumnsRowset_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define IColumnsRowset_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define IColumnsRowset_GetAvailableColumns(This,pcOptColumns,prgOptColumns)	\
    (This)->lpVtbl -> GetAvailableColumns(This,pcOptColumns,prgOptColumns)

#define IColumnsRowset_GetColumnsRowset(This,pUnkOuter,cOptColumns,rgOptColumns,riid,cPropertySets,rgPropertySets,ppColRowset)	\
    (This)->lpVtbl -> GetColumnsRowset(This,pUnkOuter,cOptColumns,rgOptColumns,riid,cPropertySets,rgPropertySets,ppColRowset)

#endif /* COBJMACROS */


#endif 	/* C style interface */



/* [call_as] */ HRESULT STDMETHODCALLTYPE IColumnsRowset_RemoteGetAvailableColumns_Proxy( 
    IColumnsRowset __RPC_FAR * This,
    /* [out][in] */ ULONG __RPC_FAR *pcOptColumns,
    /* [size_is][size_is][out] */ DBID __RPC_FAR *__RPC_FAR *prgOptColumns,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IColumnsRowset_RemoteGetAvailableColumns_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IColumnsRowset_RemoteGetColumnsRowset_Proxy( 
    IColumnsRowset __RPC_FAR * This,
    /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
    /* [in] */ ULONG cOptColumns,
    /* [size_is][unique][in] */ const DBID __RPC_FAR *rgOptColumns,
    /* [in] */ REFIID riid,
    /* [in] */ ULONG cPropertySets,
    /* [size_is][unique][in] */ DBPROPSET __RPC_FAR *rgPropertySets,
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppColRowset,
    /* [in] */ ULONG cTotalProps,
    /* [size_is][out] */ DBPROPSTATUS __RPC_FAR *rgPropStatus,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IColumnsRowset_RemoteGetColumnsRowset_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __IColumnsRowset_INTERFACE_DEFINED__ */


#ifndef __IColumnsInfo_INTERFACE_DEFINED__
#define __IColumnsInfo_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: IColumnsInfo
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object] */ 



EXTERN_C const IID IID_IColumnsInfo;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733a11-2a1c-11ce-ade5-00aa0044773d")
    IColumnsInfo : public IUnknown
    {
    public:
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetColumnInfo( 
            /* [out][in] */ ULONG __RPC_FAR *pcColumns,
            /* [size_is][size_is][out] */ DBCOLUMNINFO __RPC_FAR *__RPC_FAR *prgInfo,
            /* [out] */ OLECHAR __RPC_FAR *__RPC_FAR *ppStringsBuffer) = 0;
        
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE MapColumnIDs( 
            /* [in] */ ULONG cColumnIDs,
            /* [size_is][in] */ const DBID __RPC_FAR rgColumnIDs[  ],
            /* [size_is][out] */ ULONG __RPC_FAR rgColumns[  ]) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct IColumnsInfoVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            IColumnsInfo __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            IColumnsInfo __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            IColumnsInfo __RPC_FAR * This);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetColumnInfo )( 
            IColumnsInfo __RPC_FAR * This,
            /* [out][in] */ ULONG __RPC_FAR *pcColumns,
            /* [size_is][size_is][out] */ DBCOLUMNINFO __RPC_FAR *__RPC_FAR *prgInfo,
            /* [out] */ OLECHAR __RPC_FAR *__RPC_FAR *ppStringsBuffer);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *MapColumnIDs )( 
            IColumnsInfo __RPC_FAR * This,
            /* [in] */ ULONG cColumnIDs,
            /* [size_is][in] */ const DBID __RPC_FAR rgColumnIDs[  ],
            /* [size_is][out] */ ULONG __RPC_FAR rgColumns[  ]);
        
        END_INTERFACE
    } IColumnsInfoVtbl;

    interface IColumnsInfo
    {
        CONST_VTBL struct IColumnsInfoVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define IColumnsInfo_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define IColumnsInfo_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define IColumnsInfo_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define IColumnsInfo_GetColumnInfo(This,pcColumns,prgInfo,ppStringsBuffer)	\
    (This)->lpVtbl -> GetColumnInfo(This,pcColumns,prgInfo,ppStringsBuffer)

#define IColumnsInfo_MapColumnIDs(This,cColumnIDs,rgColumnIDs,rgColumns)	\
    (This)->lpVtbl -> MapColumnIDs(This,cColumnIDs,rgColumnIDs,rgColumns)

#endif /* COBJMACROS */


#endif 	/* C style interface */



/* [call_as] */ HRESULT STDMETHODCALLTYPE IColumnsInfo_RemoteGetColumnInfo_Proxy( 
    IColumnsInfo __RPC_FAR * This,
    /* [out][in] */ ULONG __RPC_FAR *pcColumns,
    /* [size_is][size_is][out] */ DBCOLUMNINFO __RPC_FAR *__RPC_FAR *prgInfo,
    /* [size_is][size_is][out] */ ULONG __RPC_FAR *__RPC_FAR *prgNameOffsets,
    /* [size_is][size_is][out] */ ULONG __RPC_FAR *__RPC_FAR *prgcolumnidOffsets,
    /* [out][in] */ ULONG __RPC_FAR *pcbStringsBuffer,
    /* [size_is][size_is][unique][out][in] */ OLECHAR __RPC_FAR *__RPC_FAR *ppStringsBuffer,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IColumnsInfo_RemoteGetColumnInfo_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IColumnsInfo_RemoteMapColumnIDs_Proxy( 
    IColumnsInfo __RPC_FAR * This,
    /* [in] */ ULONG cColumnIDs,
    /* [size_is][in] */ const DBID __RPC_FAR *rgColumnIDs,
    /* [size_is][out] */ ULONG __RPC_FAR *rgColumns,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IColumnsInfo_RemoteMapColumnIDs_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __IColumnsInfo_INTERFACE_DEFINED__ */


#ifndef __IDBCreateCommand_INTERFACE_DEFINED__
#define __IDBCreateCommand_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: IDBCreateCommand
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object] */ 



EXTERN_C const IID IID_IDBCreateCommand;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733a1d-2a1c-11ce-ade5-00aa0044773d")
    IDBCreateCommand : public IUnknown
    {
    public:
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE CreateCommand( 
            /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppCommand) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct IDBCreateCommandVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            IDBCreateCommand __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            IDBCreateCommand __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            IDBCreateCommand __RPC_FAR * This);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *CreateCommand )( 
            IDBCreateCommand __RPC_FAR * This,
            /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppCommand);
        
        END_INTERFACE
    } IDBCreateCommandVtbl;

    interface IDBCreateCommand
    {
        CONST_VTBL struct IDBCreateCommandVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define IDBCreateCommand_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define IDBCreateCommand_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define IDBCreateCommand_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define IDBCreateCommand_CreateCommand(This,pUnkOuter,riid,ppCommand)	\
    (This)->lpVtbl -> CreateCommand(This,pUnkOuter,riid,ppCommand)

#endif /* COBJMACROS */


#endif 	/* C style interface */



/* [call_as] */ HRESULT STDMETHODCALLTYPE IDBCreateCommand_RemoteCreateCommand_Proxy( 
    IDBCreateCommand __RPC_FAR * This,
    /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
    /* [in] */ REFIID riid,
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppCommand,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IDBCreateCommand_RemoteCreateCommand_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __IDBCreateCommand_INTERFACE_DEFINED__ */


#ifndef __IDBCreateSession_INTERFACE_DEFINED__
#define __IDBCreateSession_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: IDBCreateSession
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object] */ 



EXTERN_C const IID IID_IDBCreateSession;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733a5d-2a1c-11ce-ade5-00aa0044773d")
    IDBCreateSession : public IUnknown
    {
    public:
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE CreateSession( 
            /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppDBSession) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct IDBCreateSessionVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            IDBCreateSession __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            IDBCreateSession __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            IDBCreateSession __RPC_FAR * This);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *CreateSession )( 
            IDBCreateSession __RPC_FAR * This,
            /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppDBSession);
        
        END_INTERFACE
    } IDBCreateSessionVtbl;

    interface IDBCreateSession
    {
        CONST_VTBL struct IDBCreateSessionVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define IDBCreateSession_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define IDBCreateSession_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define IDBCreateSession_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define IDBCreateSession_CreateSession(This,pUnkOuter,riid,ppDBSession)	\
    (This)->lpVtbl -> CreateSession(This,pUnkOuter,riid,ppDBSession)

#endif /* COBJMACROS */


#endif 	/* C style interface */



/* [call_as] */ HRESULT STDMETHODCALLTYPE IDBCreateSession_RemoteCreateSession_Proxy( 
    IDBCreateSession __RPC_FAR * This,
    /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
    /* [in] */ REFIID riid,
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppDBSession,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IDBCreateSession_RemoteCreateSession_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __IDBCreateSession_INTERFACE_DEFINED__ */


#ifndef __ISourcesRowset_INTERFACE_DEFINED__
#define __ISourcesRowset_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: ISourcesRowset
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object] */ 


typedef DWORD DBSOURCETYPE;


enum DBSOURCETYPEENUM
    {	DBSOURCETYPE_DATASOURCE	= 1,
	DBSOURCETYPE_ENUMERATOR	= 2
    };

enum DBSOURCETYPEENUM20
    {	DBSOURCETYPE_DATASOURCE_TDP	= 1,
	DBSOURCETYPE_DATASOURCE_MDP	= 3
    };

EXTERN_C const IID IID_ISourcesRowset;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733a1e-2a1c-11ce-ade5-00aa0044773d")
    ISourcesRowset : public IUnknown
    {
    public:
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetSourcesRowset( 
            /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
            /* [in] */ REFIID riid,
            /* [in] */ ULONG cPropertySets,
            /* [size_is][unique][out][in] */ DBPROPSET __RPC_FAR rgProperties[  ],
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppSourcesRowset) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct ISourcesRowsetVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            ISourcesRowset __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            ISourcesRowset __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            ISourcesRowset __RPC_FAR * This);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetSourcesRowset )( 
            ISourcesRowset __RPC_FAR * This,
            /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
            /* [in] */ REFIID riid,
            /* [in] */ ULONG cPropertySets,
            /* [size_is][unique][out][in] */ DBPROPSET __RPC_FAR rgProperties[  ],
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppSourcesRowset);
        
        END_INTERFACE
    } ISourcesRowsetVtbl;

    interface ISourcesRowset
    {
        CONST_VTBL struct ISourcesRowsetVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define ISourcesRowset_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define ISourcesRowset_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define ISourcesRowset_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define ISourcesRowset_GetSourcesRowset(This,pUnkOuter,riid,cPropertySets,rgProperties,ppSourcesRowset)	\
    (This)->lpVtbl -> GetSourcesRowset(This,pUnkOuter,riid,cPropertySets,rgProperties,ppSourcesRowset)

#endif /* COBJMACROS */


#endif 	/* C style interface */



/* [call_as] */ HRESULT STDMETHODCALLTYPE ISourcesRowset_RemoteGetSourcesRowset_Proxy( 
    ISourcesRowset __RPC_FAR * This,
    /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
    /* [in] */ REFIID riid,
    /* [in] */ ULONG cPropertySets,
    /* [size_is][unique][in] */ DBPROPSET __RPC_FAR *rgProperties,
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppSourcesRowset,
    /* [in] */ ULONG cTotalProps,
    /* [size_is][out] */ DBPROPSTATUS __RPC_FAR *rgPropStatus,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB ISourcesRowset_RemoteGetSourcesRowset_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __ISourcesRowset_INTERFACE_DEFINED__ */


#ifndef __IDBProperties_INTERFACE_DEFINED__
#define __IDBProperties_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: IDBProperties
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object] */ 



EXTERN_C const IID IID_IDBProperties;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733a8a-2a1c-11ce-ade5-00aa0044773d")
    IDBProperties : public IUnknown
    {
    public:
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetProperties( 
            /* [in] */ ULONG cPropertyIDSets,
            /* [size_is][in] */ const DBPROPIDSET __RPC_FAR rgPropertyIDSets[  ],
            /* [out][in] */ ULONG __RPC_FAR *pcPropertySets,
            /* [size_is][size_is][out] */ DBPROPSET __RPC_FAR *__RPC_FAR *prgPropertySets) = 0;
        
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetPropertyInfo( 
            /* [in] */ ULONG cPropertyIDSets,
            /* [size_is][in] */ const DBPROPIDSET __RPC_FAR rgPropertyIDSets[  ],
            /* [out][in] */ ULONG __RPC_FAR *pcPropertyInfoSets,
            /* [size_is][size_is][out] */ DBPROPINFOSET __RPC_FAR *__RPC_FAR *prgPropertyInfoSets,
            /* [out] */ OLECHAR __RPC_FAR *__RPC_FAR *ppDescBuffer) = 0;
        
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE SetProperties( 
            /* [in] */ ULONG cPropertySets,
            /* [size_is][out][in] */ DBPROPSET __RPC_FAR rgPropertySets[  ]) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct IDBPropertiesVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            IDBProperties __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            IDBProperties __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            IDBProperties __RPC_FAR * This);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetProperties )( 
            IDBProperties __RPC_FAR * This,
            /* [in] */ ULONG cPropertyIDSets,
            /* [size_is][in] */ const DBPROPIDSET __RPC_FAR rgPropertyIDSets[  ],
            /* [out][in] */ ULONG __RPC_FAR *pcPropertySets,
            /* [size_is][size_is][out] */ DBPROPSET __RPC_FAR *__RPC_FAR *prgPropertySets);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetPropertyInfo )( 
            IDBProperties __RPC_FAR * This,
            /* [in] */ ULONG cPropertyIDSets,
            /* [size_is][in] */ const DBPROPIDSET __RPC_FAR rgPropertyIDSets[  ],
            /* [out][in] */ ULONG __RPC_FAR *pcPropertyInfoSets,
            /* [size_is][size_is][out] */ DBPROPINFOSET __RPC_FAR *__RPC_FAR *prgPropertyInfoSets,
            /* [out] */ OLECHAR __RPC_FAR *__RPC_FAR *ppDescBuffer);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *SetProperties )( 
            IDBProperties __RPC_FAR * This,
            /* [in] */ ULONG cPropertySets,
            /* [size_is][out][in] */ DBPROPSET __RPC_FAR rgPropertySets[  ]);
        
        END_INTERFACE
    } IDBPropertiesVtbl;

    interface IDBProperties
    {
        CONST_VTBL struct IDBPropertiesVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define IDBProperties_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define IDBProperties_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define IDBProperties_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define IDBProperties_GetProperties(This,cPropertyIDSets,rgPropertyIDSets,pcPropertySets,prgPropertySets)	\
    (This)->lpVtbl -> GetProperties(This,cPropertyIDSets,rgPropertyIDSets,pcPropertySets,prgPropertySets)

#define IDBProperties_GetPropertyInfo(This,cPropertyIDSets,rgPropertyIDSets,pcPropertyInfoSets,prgPropertyInfoSets,ppDescBuffer)	\
    (This)->lpVtbl -> GetPropertyInfo(This,cPropertyIDSets,rgPropertyIDSets,pcPropertyInfoSets,prgPropertyInfoSets,ppDescBuffer)

#define IDBProperties_SetProperties(This,cPropertySets,rgPropertySets)	\
    (This)->lpVtbl -> SetProperties(This,cPropertySets,rgPropertySets)

#endif /* COBJMACROS */


#endif 	/* C style interface */



/* [call_as] */ HRESULT STDMETHODCALLTYPE IDBProperties_RemoteGetProperties_Proxy( 
    IDBProperties __RPC_FAR * This,
    /* [in] */ ULONG cPropertyIDSets,
    /* [size_is][unique][in] */ const DBPROPIDSET __RPC_FAR *rgPropertyIDSets,
    /* [out][in] */ ULONG __RPC_FAR *pcPropertySets,
    /* [size_is][size_is][out] */ DBPROPSET __RPC_FAR *__RPC_FAR *prgPropertySets,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IDBProperties_RemoteGetProperties_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IDBProperties_RemoteGetPropertyInfo_Proxy( 
    IDBProperties __RPC_FAR * This,
    /* [in] */ ULONG cPropertyIDSets,
    /* [size_is][unique][in] */ const DBPROPIDSET __RPC_FAR *rgPropertyIDSets,
    /* [out][in] */ ULONG __RPC_FAR *pcPropertyInfoSets,
    /* [size_is][size_is][out] */ DBPROPINFOSET __RPC_FAR *__RPC_FAR *prgPropertyInfoSets,
    /* [out][in] */ ULONG __RPC_FAR *pcOffsets,
    /* [size_is][size_is][out] */ ULONG __RPC_FAR *__RPC_FAR *prgDescOffsets,
    /* [out][in] */ ULONG __RPC_FAR *pcbDescBuffer,
    /* [size_is][size_is][unique][out][in] */ OLECHAR __RPC_FAR *__RPC_FAR *ppDescBuffer,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IDBProperties_RemoteGetPropertyInfo_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IDBProperties_RemoteSetProperties_Proxy( 
    IDBProperties __RPC_FAR * This,
    /* [in] */ ULONG cPropertySets,
    /* [size_is][unique][in] */ DBPROPSET __RPC_FAR *rgPropertySets,
    /* [in] */ ULONG cTotalProps,
    /* [size_is][out] */ DBPROPSTATUS __RPC_FAR *rgPropStatus,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IDBProperties_RemoteSetProperties_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __IDBProperties_INTERFACE_DEFINED__ */


#ifndef __IDBInitialize_INTERFACE_DEFINED__
#define __IDBInitialize_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: IDBInitialize
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object] */ 



EXTERN_C const IID IID_IDBInitialize;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733a8b-2a1c-11ce-ade5-00aa0044773d")
    IDBInitialize : public IUnknown
    {
    public:
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE Initialize( void) = 0;
        
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE Uninitialize( void) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct IDBInitializeVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            IDBInitialize __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            IDBInitialize __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            IDBInitialize __RPC_FAR * This);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Initialize )( 
            IDBInitialize __RPC_FAR * This);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Uninitialize )( 
            IDBInitialize __RPC_FAR * This);
        
        END_INTERFACE
    } IDBInitializeVtbl;

    interface IDBInitialize
    {
        CONST_VTBL struct IDBInitializeVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define IDBInitialize_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define IDBInitialize_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define IDBInitialize_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define IDBInitialize_Initialize(This)	\
    (This)->lpVtbl -> Initialize(This)

#define IDBInitialize_Uninitialize(This)	\
    (This)->lpVtbl -> Uninitialize(This)

#endif /* COBJMACROS */


#endif 	/* C style interface */



/* [call_as] */ HRESULT STDMETHODCALLTYPE IDBInitialize_RemoteInitialize_Proxy( 
    IDBInitialize __RPC_FAR * This,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IDBInitialize_RemoteInitialize_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IDBInitialize_RemoteUninitialize_Proxy( 
    IDBInitialize __RPC_FAR * This,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IDBInitialize_RemoteUninitialize_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __IDBInitialize_INTERFACE_DEFINED__ */


#ifndef __IDBInfo_INTERFACE_DEFINED__
#define __IDBInfo_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: IDBInfo
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object] */ 


typedef DWORD DBLITERAL;


enum DBLITERALENUM
    {	DBLITERAL_INVALID	= 0,
	DBLITERAL_BINARY_LITERAL	= 1,
	DBLITERAL_CATALOG_NAME	= 2,
	DBLITERAL_CATALOG_SEPARATOR	= 3,
	DBLITERAL_CHAR_LITERAL	= 4,
	DBLITERAL_COLUMN_ALIAS	= 5,
	DBLITERAL_COLUMN_NAME	= 6,
	DBLITERAL_CORRELATION_NAME	= 7,
	DBLITERAL_CURSOR_NAME	= 8,
	DBLITERAL_ESCAPE_PERCENT	= 9,
	DBLITERAL_ESCAPE_UNDERSCORE	= 10,
	DBLITERAL_INDEX_NAME	= 11,
	DBLITERAL_LIKE_PERCENT	= 12,
	DBLITERAL_LIKE_UNDERSCORE	= 13,
	DBLITERAL_PROCEDURE_NAME	= 14,
	DBLITERAL_QUOTE	= 15,
	DBLITERAL_SCHEMA_NAME	= 16,
	DBLITERAL_TABLE_NAME	= 17,
	DBLITERAL_TEXT_COMMAND	= 18,
	DBLITERAL_USER_NAME	= 19,
	DBLITERAL_VIEW_NAME	= 20
    };

#define DBLITERAL_QUOTE_PREFIX DBLITERAL_QUOTE

enum DBLITERALENUM20
    {	DBLITERAL_CUBE_NAME	= 21,
	DBLITERAL_DIMENSION_NAME	= 22,
	DBLITERAL_HIERARCHY_NAME	= 23,
	DBLITERAL_LEVEL_NAME	= 24,
	DBLITERAL_MEMBER_NAME	= 25,
	DBLITERAL_PROPERTY_NAME	= 26,
	DBLITERAL_SCHEMA_SEPARATOR	= 27,
	DBLITERAL_QUOTE_SUFFIX	= 28
    };

#define DBLITERAL_ESCAPE_PERCENT_PREFIX DBLITERAL_ESCAPE_PERCENT
#define DBLITERAL_ESCAPE_UNDERSCORE_PREFIX DBLITERAL_ESCAPE_UNDERSCORE

enum DBLITERALENUM21
    {	DBLITERAL_ESCAPE_PERCENT_SUFFIX	= 29,
	DBLITERAL_ESCAPE_UNDERSCORE_SUFFIX	= 30
    };

typedef struct  tagDBLITERALINFO
    {
    LPOLESTR pwszLiteralValue;
    LPOLESTR pwszInvalidChars;
    LPOLESTR pwszInvalidStartingChars;
    DBLITERAL lt;
    BOOL fSupported;
    ULONG cchMaxLen;
    }	DBLITERALINFO;


EXTERN_C const IID IID_IDBInfo;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733a89-2a1c-11ce-ade5-00aa0044773d")
    IDBInfo : public IUnknown
    {
    public:
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetKeywords( 
            /* [out] */ LPOLESTR __RPC_FAR *ppwszKeywords) = 0;
        
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetLiteralInfo( 
            /* [in] */ ULONG cLiterals,
            /* [size_is][in] */ const DBLITERAL __RPC_FAR rgLiterals[  ],
            /* [out][in] */ ULONG __RPC_FAR *pcLiteralInfo,
            /* [size_is][size_is][out] */ DBLITERALINFO __RPC_FAR *__RPC_FAR *prgLiteralInfo,
            /* [out] */ OLECHAR __RPC_FAR *__RPC_FAR *ppCharBuffer) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct IDBInfoVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            IDBInfo __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            IDBInfo __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            IDBInfo __RPC_FAR * This);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetKeywords )( 
            IDBInfo __RPC_FAR * This,
            /* [out] */ LPOLESTR __RPC_FAR *ppwszKeywords);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetLiteralInfo )( 
            IDBInfo __RPC_FAR * This,
            /* [in] */ ULONG cLiterals,
            /* [size_is][in] */ const DBLITERAL __RPC_FAR rgLiterals[  ],
            /* [out][in] */ ULONG __RPC_FAR *pcLiteralInfo,
            /* [size_is][size_is][out] */ DBLITERALINFO __RPC_FAR *__RPC_FAR *prgLiteralInfo,
            /* [out] */ OLECHAR __RPC_FAR *__RPC_FAR *ppCharBuffer);
        
        END_INTERFACE
    } IDBInfoVtbl;

    interface IDBInfo
    {
        CONST_VTBL struct IDBInfoVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define IDBInfo_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define IDBInfo_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define IDBInfo_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define IDBInfo_GetKeywords(This,ppwszKeywords)	\
    (This)->lpVtbl -> GetKeywords(This,ppwszKeywords)

#define IDBInfo_GetLiteralInfo(This,cLiterals,rgLiterals,pcLiteralInfo,prgLiteralInfo,ppCharBuffer)	\
    (This)->lpVtbl -> GetLiteralInfo(This,cLiterals,rgLiterals,pcLiteralInfo,prgLiteralInfo,ppCharBuffer)

#endif /* COBJMACROS */


#endif 	/* C style interface */



/* [call_as] */ HRESULT STDMETHODCALLTYPE IDBInfo_RemoteGetKeywords_Proxy( 
    IDBInfo __RPC_FAR * This,
    /* [unique][out][in] */ LPOLESTR __RPC_FAR *ppwszKeywords,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IDBInfo_RemoteGetKeywords_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IDBInfo_RemoteGetLiteralInfo_Proxy( 
    IDBInfo __RPC_FAR * This,
    /* [in] */ ULONG cLiterals,
    /* [size_is][unique][in] */ const DBLITERAL __RPC_FAR *rgLiterals,
    /* [out][in] */ ULONG __RPC_FAR *pcLiteralInfo,
    /* [size_is][size_is][out] */ DBLITERALINFO __RPC_FAR *__RPC_FAR *prgLiteralInfo,
    /* [size_is][size_is][out] */ ULONG __RPC_FAR *__RPC_FAR *prgLVOffsets,
    /* [size_is][size_is][out] */ ULONG __RPC_FAR *__RPC_FAR *prgICOffsets,
    /* [size_is][size_is][out] */ ULONG __RPC_FAR *__RPC_FAR *prgISCOffsets,
    /* [out][in] */ ULONG __RPC_FAR *pcbCharBuffer,
    /* [size_is][size_is][unique][out][in] */ OLECHAR __RPC_FAR *__RPC_FAR *ppCharBuffer,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IDBInfo_RemoteGetLiteralInfo_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __IDBInfo_INTERFACE_DEFINED__ */


#ifndef __IDBDataSourceAdmin_INTERFACE_DEFINED__
#define __IDBDataSourceAdmin_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: IDBDataSourceAdmin
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object] */ 



EXTERN_C const IID IID_IDBDataSourceAdmin;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733a7a-2a1c-11ce-ade5-00aa0044773d")
    IDBDataSourceAdmin : public IUnknown
    {
    public:
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE CreateDataSource( 
            /* [in] */ ULONG cPropertySets,
            /* [size_is][out][in] */ DBPROPSET __RPC_FAR rgPropertySets[  ],
            /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppDBSession) = 0;
        
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE DestroyDataSource( void) = 0;
        
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetCreationProperties( 
            /* [in] */ ULONG cPropertyIDSets,
            /* [size_is][in] */ const DBPROPIDSET __RPC_FAR rgPropertyIDSets[  ],
            /* [out][in] */ ULONG __RPC_FAR *pcPropertyInfoSets,
            /* [size_is][size_is][out] */ DBPROPINFOSET __RPC_FAR *__RPC_FAR *prgPropertyInfoSets,
            /* [out] */ OLECHAR __RPC_FAR *__RPC_FAR *ppDescBuffer) = 0;
        
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE ModifyDataSource( 
            /* [in] */ ULONG cPropertySets,
            /* [size_is][in] */ DBPROPSET __RPC_FAR rgPropertySets[  ]) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct IDBDataSourceAdminVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            IDBDataSourceAdmin __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            IDBDataSourceAdmin __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            IDBDataSourceAdmin __RPC_FAR * This);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *CreateDataSource )( 
            IDBDataSourceAdmin __RPC_FAR * This,
            /* [in] */ ULONG cPropertySets,
            /* [size_is][out][in] */ DBPROPSET __RPC_FAR rgPropertySets[  ],
            /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppDBSession);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *DestroyDataSource )( 
            IDBDataSourceAdmin __RPC_FAR * This);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetCreationProperties )( 
            IDBDataSourceAdmin __RPC_FAR * This,
            /* [in] */ ULONG cPropertyIDSets,
            /* [size_is][in] */ const DBPROPIDSET __RPC_FAR rgPropertyIDSets[  ],
            /* [out][in] */ ULONG __RPC_FAR *pcPropertyInfoSets,
            /* [size_is][size_is][out] */ DBPROPINFOSET __RPC_FAR *__RPC_FAR *prgPropertyInfoSets,
            /* [out] */ OLECHAR __RPC_FAR *__RPC_FAR *ppDescBuffer);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *ModifyDataSource )( 
            IDBDataSourceAdmin __RPC_FAR * This,
            /* [in] */ ULONG cPropertySets,
            /* [size_is][in] */ DBPROPSET __RPC_FAR rgPropertySets[  ]);
        
        END_INTERFACE
    } IDBDataSourceAdminVtbl;

    interface IDBDataSourceAdmin
    {
        CONST_VTBL struct IDBDataSourceAdminVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define IDBDataSourceAdmin_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define IDBDataSourceAdmin_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define IDBDataSourceAdmin_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define IDBDataSourceAdmin_CreateDataSource(This,cPropertySets,rgPropertySets,pUnkOuter,riid,ppDBSession)	\
    (This)->lpVtbl -> CreateDataSource(This,cPropertySets,rgPropertySets,pUnkOuter,riid,ppDBSession)

#define IDBDataSourceAdmin_DestroyDataSource(This)	\
    (This)->lpVtbl -> DestroyDataSource(This)

#define IDBDataSourceAdmin_GetCreationProperties(This,cPropertyIDSets,rgPropertyIDSets,pcPropertyInfoSets,prgPropertyInfoSets,ppDescBuffer)	\
    (This)->lpVtbl -> GetCreationProperties(This,cPropertyIDSets,rgPropertyIDSets,pcPropertyInfoSets,prgPropertyInfoSets,ppDescBuffer)

#define IDBDataSourceAdmin_ModifyDataSource(This,cPropertySets,rgPropertySets)	\
    (This)->lpVtbl -> ModifyDataSource(This,cPropertySets,rgPropertySets)

#endif /* COBJMACROS */


#endif 	/* C style interface */



/* [call_as] */ HRESULT STDMETHODCALLTYPE IDBDataSourceAdmin_RemoteCreateDataSource_Proxy( 
    IDBDataSourceAdmin __RPC_FAR * This,
    /* [in] */ ULONG cPropertySets,
    /* [size_is][unique][in] */ DBPROPSET __RPC_FAR *rgPropertySets,
    /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
    /* [in] */ REFIID riid,
    /* [iid_is][unique][out][in] */ IUnknown __RPC_FAR *__RPC_FAR *ppDBSession,
    /* [in] */ ULONG cTotalProps,
    /* [size_is][out] */ DBPROPSTATUS __RPC_FAR *rgPropStatus,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IDBDataSourceAdmin_RemoteCreateDataSource_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IDBDataSourceAdmin_RemoteDestroyDataSource_Proxy( 
    IDBDataSourceAdmin __RPC_FAR * This,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IDBDataSourceAdmin_RemoteDestroyDataSource_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IDBDataSourceAdmin_RemoteGetCreationProperties_Proxy( 
    IDBDataSourceAdmin __RPC_FAR * This,
    /* [in] */ ULONG cPropertyIDSets,
    /* [size_is][unique][in] */ const DBPROPIDSET __RPC_FAR *rgPropertyIDSets,
    /* [out][in] */ ULONG __RPC_FAR *pcPropertyInfoSets,
    /* [size_is][size_is][out] */ DBPROPINFOSET __RPC_FAR *__RPC_FAR *prgPropertyInfoSets,
    /* [out][in] */ ULONG __RPC_FAR *pcOffsets,
    /* [size_is][size_is][out] */ ULONG __RPC_FAR *__RPC_FAR *prgDescOffsets,
    /* [out][in] */ ULONG __RPC_FAR *pcbDescBuffer,
    /* [size_is][size_is][unique][out][in] */ OLECHAR __RPC_FAR *__RPC_FAR *ppDescBuffer,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IDBDataSourceAdmin_RemoteGetCreationProperties_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IDBDataSourceAdmin_RemoteModifyDataSource_Proxy( 
    IDBDataSourceAdmin __RPC_FAR * This,
    /* [in] */ ULONG cPropertySets,
    /* [size_is][in] */ DBPROPSET __RPC_FAR *rgPropertySets,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IDBDataSourceAdmin_RemoteModifyDataSource_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __IDBDataSourceAdmin_INTERFACE_DEFINED__ */


/****************************************
 * Generated header for interface: __MIDL_itf_oledb_0192
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [local] */ 


extern RPC_IF_HANDLE __MIDL_itf_oledb_0192_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_oledb_0192_v0_0_s_ifspec;

#ifndef __IDBAsynchNotify_INTERFACE_DEFINED__
#define __IDBAsynchNotify_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: IDBAsynchNotify
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object] */ 



EXTERN_C const IID IID_IDBAsynchNotify;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733a96-2a1c-11ce-ade5-00aa0044773d")
    IDBAsynchNotify : public IUnknown
    {
    public:
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE OnLowResource( 
            /* [in] */ DWORD dwReserved) = 0;
        
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE OnProgress( 
            /* [in] */ HCHAPTER hChapter,
            /* [in] */ DBASYNCHOP eOperation,
            /* [in] */ ULONG ulProgress,
            /* [in] */ ULONG ulProgressMax,
            /* [in] */ DBASYNCHPHASE eAsynchPhase,
            /* [in] */ LPOLESTR pwszStatusText) = 0;
        
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE OnStop( 
            /* [in] */ HCHAPTER hChapter,
            /* [in] */ DBASYNCHOP eOperation,
            /* [in] */ HRESULT hrStatus,
            /* [in] */ LPOLESTR pwszStatusText) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct IDBAsynchNotifyVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            IDBAsynchNotify __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            IDBAsynchNotify __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            IDBAsynchNotify __RPC_FAR * This);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *OnLowResource )( 
            IDBAsynchNotify __RPC_FAR * This,
            /* [in] */ DWORD dwReserved);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *OnProgress )( 
            IDBAsynchNotify __RPC_FAR * This,
            /* [in] */ HCHAPTER hChapter,
            /* [in] */ DBASYNCHOP eOperation,
            /* [in] */ ULONG ulProgress,
            /* [in] */ ULONG ulProgressMax,
            /* [in] */ DBASYNCHPHASE eAsynchPhase,
            /* [in] */ LPOLESTR pwszStatusText);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *OnStop )( 
            IDBAsynchNotify __RPC_FAR * This,
            /* [in] */ HCHAPTER hChapter,
            /* [in] */ DBASYNCHOP eOperation,
            /* [in] */ HRESULT hrStatus,
            /* [in] */ LPOLESTR pwszStatusText);
        
        END_INTERFACE
    } IDBAsynchNotifyVtbl;

    interface IDBAsynchNotify
    {
        CONST_VTBL struct IDBAsynchNotifyVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define IDBAsynchNotify_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define IDBAsynchNotify_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define IDBAsynchNotify_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define IDBAsynchNotify_OnLowResource(This,dwReserved)	\
    (This)->lpVtbl -> OnLowResource(This,dwReserved)

#define IDBAsynchNotify_OnProgress(This,hChapter,eOperation,ulProgress,ulProgressMax,eAsynchPhase,pwszStatusText)	\
    (This)->lpVtbl -> OnProgress(This,hChapter,eOperation,ulProgress,ulProgressMax,eAsynchPhase,pwszStatusText)

#define IDBAsynchNotify_OnStop(This,hChapter,eOperation,hrStatus,pwszStatusText)	\
    (This)->lpVtbl -> OnStop(This,hChapter,eOperation,hrStatus,pwszStatusText)

#endif /* COBJMACROS */


#endif 	/* C style interface */



/* [call_as] */ HRESULT STDMETHODCALLTYPE IDBAsynchNotify_RemoteOnLowResource_Proxy( 
    IDBAsynchNotify __RPC_FAR * This,
    /* [in] */ DWORD dwReserved,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IDBAsynchNotify_RemoteOnLowResource_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IDBAsynchNotify_RemoteOnProgress_Proxy( 
    IDBAsynchNotify __RPC_FAR * This,
    /* [in] */ HCHAPTER hChapter,
    /* [in] */ DBASYNCHOP eOperation,
    /* [in] */ ULONG ulProgress,
    /* [in] */ ULONG ulProgressMax,
    /* [in] */ DBASYNCHPHASE eAsynchPhase,
    /* [in] */ LPOLESTR pwszStatusText,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IDBAsynchNotify_RemoteOnProgress_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IDBAsynchNotify_RemoteOnStop_Proxy( 
    IDBAsynchNotify __RPC_FAR * This,
    /* [in] */ HCHAPTER hChapter,
    /* [in] */ DBASYNCHOP eOperation,
    /* [in] */ HRESULT hrStatus,
    /* [in] */ LPOLESTR pwszStatusText,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IDBAsynchNotify_RemoteOnStop_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __IDBAsynchNotify_INTERFACE_DEFINED__ */


#ifndef __IDBAsynchStatus_INTERFACE_DEFINED__
#define __IDBAsynchStatus_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: IDBAsynchStatus
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object] */ 



EXTERN_C const IID IID_IDBAsynchStatus;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733a95-2a1c-11ce-ade5-00aa0044773d")
    IDBAsynchStatus : public IUnknown
    {
    public:
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE Abort( 
            /* [in] */ HCHAPTER hChapter,
            /* [in] */ DBASYNCHOP eOperation) = 0;
        
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetStatus( 
            /* [in] */ HCHAPTER hChapter,
            /* [in] */ DBASYNCHOP eOperation,
            /* [out] */ ULONG __RPC_FAR *pulProgress,
            /* [out] */ ULONG __RPC_FAR *pulProgressMax,
            /* [out] */ DBASYNCHPHASE __RPC_FAR *peAsynchPhase,
            /* [out] */ LPOLESTR __RPC_FAR *ppwszStatusText) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct IDBAsynchStatusVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            IDBAsynchStatus __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            IDBAsynchStatus __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            IDBAsynchStatus __RPC_FAR * This);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Abort )( 
            IDBAsynchStatus __RPC_FAR * This,
            /* [in] */ HCHAPTER hChapter,
            /* [in] */ DBASYNCHOP eOperation);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetStatus )( 
            IDBAsynchStatus __RPC_FAR * This,
            /* [in] */ HCHAPTER hChapter,
            /* [in] */ DBASYNCHOP eOperation,
            /* [out] */ ULONG __RPC_FAR *pulProgress,
            /* [out] */ ULONG __RPC_FAR *pulProgressMax,
            /* [out] */ DBASYNCHPHASE __RPC_FAR *peAsynchPhase,
            /* [out] */ LPOLESTR __RPC_FAR *ppwszStatusText);
        
        END_INTERFACE
    } IDBAsynchStatusVtbl;

    interface IDBAsynchStatus
    {
        CONST_VTBL struct IDBAsynchStatusVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define IDBAsynchStatus_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define IDBAsynchStatus_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define IDBAsynchStatus_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define IDBAsynchStatus_Abort(This,hChapter,eOperation)	\
    (This)->lpVtbl -> Abort(This,hChapter,eOperation)

#define IDBAsynchStatus_GetStatus(This,hChapter,eOperation,pulProgress,pulProgressMax,peAsynchPhase,ppwszStatusText)	\
    (This)->lpVtbl -> GetStatus(This,hChapter,eOperation,pulProgress,pulProgressMax,peAsynchPhase,ppwszStatusText)

#endif /* COBJMACROS */


#endif 	/* C style interface */



/* [call_as] */ HRESULT STDMETHODCALLTYPE IDBAsynchStatus_RemoteAbort_Proxy( 
    IDBAsynchStatus __RPC_FAR * This,
    /* [in] */ HCHAPTER hChapter,
    /* [in] */ DBASYNCHOP eOperation,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IDBAsynchStatus_RemoteAbort_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IDBAsynchStatus_RemoteGetStatus_Proxy( 
    IDBAsynchStatus __RPC_FAR * This,
    /* [in] */ HCHAPTER hChapter,
    /* [in] */ DBASYNCHOP eOperation,
    /* [out] */ ULONG __RPC_FAR *pulProgress,
    /* [out] */ ULONG __RPC_FAR *pulProgressMax,
    /* [out] */ DBASYNCHPHASE __RPC_FAR *peAsynchPhase,
    /* [out] */ LPOLESTR __RPC_FAR *ppwszStatusText,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IDBAsynchStatus_RemoteGetStatus_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __IDBAsynchStatus_INTERFACE_DEFINED__ */


/****************************************
 * Generated header for interface: __MIDL_itf_oledb_0194
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [local] */ 


extern RPC_IF_HANDLE __MIDL_itf_oledb_0194_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_oledb_0194_v0_0_s_ifspec;

#ifndef __ISessionProperties_INTERFACE_DEFINED__
#define __ISessionProperties_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: ISessionProperties
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object] */ 



EXTERN_C const IID IID_ISessionProperties;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733a85-2a1c-11ce-ade5-00aa0044773d")
    ISessionProperties : public IUnknown
    {
    public:
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetProperties( 
            /* [in] */ ULONG cPropertyIDSets,
            /* [size_is][in] */ const DBPROPIDSET __RPC_FAR rgPropertyIDSets[  ],
            /* [out][in] */ ULONG __RPC_FAR *pcPropertySets,
            /* [size_is][size_is][out] */ DBPROPSET __RPC_FAR *__RPC_FAR *prgPropertySets) = 0;
        
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE SetProperties( 
            /* [in] */ ULONG cPropertySets,
            /* [size_is][unique][out][in] */ DBPROPSET __RPC_FAR rgPropertySets[  ]) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct ISessionPropertiesVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            ISessionProperties __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            ISessionProperties __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            ISessionProperties __RPC_FAR * This);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetProperties )( 
            ISessionProperties __RPC_FAR * This,
            /* [in] */ ULONG cPropertyIDSets,
            /* [size_is][in] */ const DBPROPIDSET __RPC_FAR rgPropertyIDSets[  ],
            /* [out][in] */ ULONG __RPC_FAR *pcPropertySets,
            /* [size_is][size_is][out] */ DBPROPSET __RPC_FAR *__RPC_FAR *prgPropertySets);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *SetProperties )( 
            ISessionProperties __RPC_FAR * This,
            /* [in] */ ULONG cPropertySets,
            /* [size_is][unique][out][in] */ DBPROPSET __RPC_FAR rgPropertySets[  ]);
        
        END_INTERFACE
    } ISessionPropertiesVtbl;

    interface ISessionProperties
    {
        CONST_VTBL struct ISessionPropertiesVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define ISessionProperties_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define ISessionProperties_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define ISessionProperties_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define ISessionProperties_GetProperties(This,cPropertyIDSets,rgPropertyIDSets,pcPropertySets,prgPropertySets)	\
    (This)->lpVtbl -> GetProperties(This,cPropertyIDSets,rgPropertyIDSets,pcPropertySets,prgPropertySets)

#define ISessionProperties_SetProperties(This,cPropertySets,rgPropertySets)	\
    (This)->lpVtbl -> SetProperties(This,cPropertySets,rgPropertySets)

#endif /* COBJMACROS */


#endif 	/* C style interface */



/* [call_as] */ HRESULT STDMETHODCALLTYPE ISessionProperties_RemoteGetProperties_Proxy( 
    ISessionProperties __RPC_FAR * This,
    /* [in] */ ULONG cPropertyIDSets,
    /* [size_is][unique][in] */ const DBPROPIDSET __RPC_FAR *rgPropertyIDSets,
    /* [out][in] */ ULONG __RPC_FAR *pcPropertySets,
    /* [size_is][size_is][out] */ DBPROPSET __RPC_FAR *__RPC_FAR *prgPropertySets,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB ISessionProperties_RemoteGetProperties_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


/* [call_as] */ HRESULT STDMETHODCALLTYPE ISessionProperties_RemoteSetProperties_Proxy( 
    ISessionProperties __RPC_FAR * This,
    /* [in] */ ULONG cPropertySets,
    /* [size_is][unique][in] */ DBPROPSET __RPC_FAR *rgPropertySets,
    /* [in] */ ULONG cTotalProps,
    /* [size_is][out] */ DBPROPSTATUS __RPC_FAR *rgPropStatus,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB ISessionProperties_RemoteSetProperties_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __ISessionProperties_INTERFACE_DEFINED__ */


#ifndef __IIndexDefinition_INTERFACE_DEFINED__
#define __IIndexDefinition_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: IIndexDefinition
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object] */ 



EXTERN_C const IID IID_IIndexDefinition;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733a68-2a1c-11ce-ade5-00aa0044773d")
    IIndexDefinition : public IUnknown
    {
    public:
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE CreateIndex( 
            /* [in] */ DBID __RPC_FAR *pTableID,
            /* [in] */ DBID __RPC_FAR *pIndexID,
            /* [in] */ ULONG cIndexColumnDescs,
            /* [size_is][in] */ const DBINDEXCOLUMNDESC __RPC_FAR rgIndexColumnDescs[  ],
            /* [in] */ ULONG cPropertySets,
            /* [size_is][out][in] */ DBPROPSET __RPC_FAR rgPropertySets[  ],
            /* [out] */ DBID __RPC_FAR *__RPC_FAR *ppIndexID) = 0;
        
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE DropIndex( 
            /* [unique][in] */ DBID __RPC_FAR *pTableID,
            /* [unique][in] */ DBID __RPC_FAR *pIndexID) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct IIndexDefinitionVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            IIndexDefinition __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            IIndexDefinition __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            IIndexDefinition __RPC_FAR * This);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *CreateIndex )( 
            IIndexDefinition __RPC_FAR * This,
            /* [in] */ DBID __RPC_FAR *pTableID,
            /* [in] */ DBID __RPC_FAR *pIndexID,
            /* [in] */ ULONG cIndexColumnDescs,
            /* [size_is][in] */ const DBINDEXCOLUMNDESC __RPC_FAR rgIndexColumnDescs[  ],
            /* [in] */ ULONG cPropertySets,
            /* [size_is][out][in] */ DBPROPSET __RPC_FAR rgPropertySets[  ],
            /* [out] */ DBID __RPC_FAR *__RPC_FAR *ppIndexID);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *DropIndex )( 
            IIndexDefinition __RPC_FAR * This,
            /* [unique][in] */ DBID __RPC_FAR *pTableID,
            /* [unique][in] */ DBID __RPC_FAR *pIndexID);
        
        END_INTERFACE
    } IIndexDefinitionVtbl;

    interface IIndexDefinition
    {
        CONST_VTBL struct IIndexDefinitionVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define IIndexDefinition_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define IIndexDefinition_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define IIndexDefinition_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define IIndexDefinition_CreateIndex(This,pTableID,pIndexID,cIndexColumnDescs,rgIndexColumnDescs,cPropertySets,rgPropertySets,ppIndexID)	\
    (This)->lpVtbl -> CreateIndex(This,pTableID,pIndexID,cIndexColumnDescs,rgIndexColumnDescs,cPropertySets,rgPropertySets,ppIndexID)

#define IIndexDefinition_DropIndex(This,pTableID,pIndexID)	\
    (This)->lpVtbl -> DropIndex(This,pTableID,pIndexID)

#endif /* COBJMACROS */


#endif 	/* C style interface */



/* [call_as] */ HRESULT STDMETHODCALLTYPE IIndexDefinition_RemoteCreateIndex_Proxy( 
    IIndexDefinition __RPC_FAR * This,
    /* [in] */ DBID __RPC_FAR *pTableID,
    /* [unique][in] */ DBID __RPC_FAR *pIndexID,
    /* [in] */ ULONG cIndexColumnDescs,
    /* [size_is][in] */ const DBINDEXCOLUMNDESC __RPC_FAR *rgIndexColumnDescs,
    /* [in] */ ULONG cPropertySets,
    /* [size_is][unique][in] */ DBPROPSET __RPC_FAR *rgPropertySets,
    /* [unique][out][in] */ DBID __RPC_FAR *__RPC_FAR *ppIndexID,
    /* [in] */ ULONG cTotalProps,
    /* [size_is][out] */ DBPROPSTATUS __RPC_FAR *rgPropStatus,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IIndexDefinition_RemoteCreateIndex_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IIndexDefinition_RemoteDropIndex_Proxy( 
    IIndexDefinition __RPC_FAR * This,
    /* [unique][in] */ DBID __RPC_FAR *pTableID,
    /* [unique][in] */ DBID __RPC_FAR *pIndexID,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IIndexDefinition_RemoteDropIndex_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __IIndexDefinition_INTERFACE_DEFINED__ */


#ifndef __ITableDefinition_INTERFACE_DEFINED__
#define __ITableDefinition_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: ITableDefinition
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object] */ 



EXTERN_C const IID IID_ITableDefinition;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733a86-2a1c-11ce-ade5-00aa0044773d")
    ITableDefinition : public IUnknown
    {
    public:
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE CreateTable( 
            /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
            /* [in] */ DBID __RPC_FAR *pTableID,
            /* [in] */ ULONG cColumnDescs,
            /* [size_is][in] */ const DBCOLUMNDESC __RPC_FAR rgColumnDescs[  ],
            /* [in] */ REFIID riid,
            /* [in] */ ULONG cPropertySets,
            /* [size_is][out][in] */ DBPROPSET __RPC_FAR rgPropertySets[  ],
            /* [out] */ DBID __RPC_FAR *__RPC_FAR *ppTableID,
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset) = 0;
        
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE DropTable( 
            /* [unique][in] */ DBID __RPC_FAR *pTableID) = 0;
        
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE AddColumn( 
            /* [in] */ DBID __RPC_FAR *pTableID,
            /* [out][in] */ DBCOLUMNDESC __RPC_FAR *pColumnDesc,
            /* [out] */ DBID __RPC_FAR *__RPC_FAR *ppColumnID) = 0;
        
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE DropColumn( 
            /* [unique][in] */ DBID __RPC_FAR *pTableID,
            /* [unique][in] */ DBID __RPC_FAR *pColumnID) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct ITableDefinitionVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            ITableDefinition __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            ITableDefinition __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            ITableDefinition __RPC_FAR * This);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *CreateTable )( 
            ITableDefinition __RPC_FAR * This,
            /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
            /* [in] */ DBID __RPC_FAR *pTableID,
            /* [in] */ ULONG cColumnDescs,
            /* [size_is][in] */ const DBCOLUMNDESC __RPC_FAR rgColumnDescs[  ],
            /* [in] */ REFIID riid,
            /* [in] */ ULONG cPropertySets,
            /* [size_is][out][in] */ DBPROPSET __RPC_FAR rgPropertySets[  ],
            /* [out] */ DBID __RPC_FAR *__RPC_FAR *ppTableID,
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *DropTable )( 
            ITableDefinition __RPC_FAR * This,
            /* [unique][in] */ DBID __RPC_FAR *pTableID);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *AddColumn )( 
            ITableDefinition __RPC_FAR * This,
            /* [in] */ DBID __RPC_FAR *pTableID,
            /* [out][in] */ DBCOLUMNDESC __RPC_FAR *pColumnDesc,
            /* [out] */ DBID __RPC_FAR *__RPC_FAR *ppColumnID);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *DropColumn )( 
            ITableDefinition __RPC_FAR * This,
            /* [unique][in] */ DBID __RPC_FAR *pTableID,
            /* [unique][in] */ DBID __RPC_FAR *pColumnID);
        
        END_INTERFACE
    } ITableDefinitionVtbl;

    interface ITableDefinition
    {
        CONST_VTBL struct ITableDefinitionVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define ITableDefinition_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define ITableDefinition_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define ITableDefinition_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define ITableDefinition_CreateTable(This,pUnkOuter,pTableID,cColumnDescs,rgColumnDescs,riid,cPropertySets,rgPropertySets,ppTableID,ppRowset)	\
    (This)->lpVtbl -> CreateTable(This,pUnkOuter,pTableID,cColumnDescs,rgColumnDescs,riid,cPropertySets,rgPropertySets,ppTableID,ppRowset)

#define ITableDefinition_DropTable(This,pTableID)	\
    (This)->lpVtbl -> DropTable(This,pTableID)

#define ITableDefinition_AddColumn(This,pTableID,pColumnDesc,ppColumnID)	\
    (This)->lpVtbl -> AddColumn(This,pTableID,pColumnDesc,ppColumnID)

#define ITableDefinition_DropColumn(This,pTableID,pColumnID)	\
    (This)->lpVtbl -> DropColumn(This,pTableID,pColumnID)

#endif /* COBJMACROS */


#endif 	/* C style interface */



/* [call_as] */ HRESULT STDMETHODCALLTYPE ITableDefinition_RemoteCreateTable_Proxy( 
    ITableDefinition __RPC_FAR * This,
    /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
    /* [unique][in] */ DBID __RPC_FAR *pTableID,
    /* [in] */ ULONG cColumnDescs,
    /* [size_is][in] */ const DBCOLUMNDESC __RPC_FAR *rgColumnDescs,
    /* [in] */ REFIID riid,
    /* [in] */ ULONG cPropertySets,
    /* [size_is][unique][in] */ DBPROPSET __RPC_FAR *rgPropertySets,
    /* [unique][out][in] */ DBID __RPC_FAR *__RPC_FAR *ppTableID,
    /* [iid_is][unique][out][in] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset,
    /* [in] */ ULONG cTotalProps,
    /* [size_is][out] */ DBPROPSTATUS __RPC_FAR *rgPropStatus,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB ITableDefinition_RemoteCreateTable_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


/* [call_as] */ HRESULT STDMETHODCALLTYPE ITableDefinition_RemoteDropTable_Proxy( 
    ITableDefinition __RPC_FAR * This,
    /* [unique][in] */ DBID __RPC_FAR *pTableID,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB ITableDefinition_RemoteDropTable_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


/* [call_as] */ HRESULT STDMETHODCALLTYPE ITableDefinition_RemoteAddColumn_Proxy( 
    ITableDefinition __RPC_FAR * This,
    /* [in] */ DBID __RPC_FAR *pTableID,
    /* [in] */ DBCOLUMNDESC __RPC_FAR *pColumnDesc,
    /* [unique][out][in] */ DBID __RPC_FAR *__RPC_FAR *ppColumnID,
    /* [in] */ ULONG cTotalProps,
    /* [size_is][out] */ DBPROPSTATUS __RPC_FAR *rgPropStatus,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB ITableDefinition_RemoteAddColumn_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


/* [call_as] */ HRESULT STDMETHODCALLTYPE ITableDefinition_RemoteDropColumn_Proxy( 
    ITableDefinition __RPC_FAR * This,
    /* [unique][in] */ DBID __RPC_FAR *pTableID,
    /* [unique][in] */ DBID __RPC_FAR *pColumnID,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB ITableDefinition_RemoteDropColumn_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __ITableDefinition_INTERFACE_DEFINED__ */


#ifndef __IOpenRowset_INTERFACE_DEFINED__
#define __IOpenRowset_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: IOpenRowset
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object] */ 



EXTERN_C const IID IID_IOpenRowset;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733a69-2a1c-11ce-ade5-00aa0044773d")
    IOpenRowset : public IUnknown
    {
    public:
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE OpenRowset( 
            /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
            /* [unique][in] */ DBID __RPC_FAR *pTableID,
            /* [unique][in] */ DBID __RPC_FAR *pIndexID,
            /* [in] */ REFIID riid,
            /* [in] */ ULONG cPropertySets,
            /* [size_is][out][in] */ DBPROPSET __RPC_FAR rgPropertySets[  ],
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct IOpenRowsetVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            IOpenRowset __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            IOpenRowset __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            IOpenRowset __RPC_FAR * This);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *OpenRowset )( 
            IOpenRowset __RPC_FAR * This,
            /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
            /* [unique][in] */ DBID __RPC_FAR *pTableID,
            /* [unique][in] */ DBID __RPC_FAR *pIndexID,
            /* [in] */ REFIID riid,
            /* [in] */ ULONG cPropertySets,
            /* [size_is][out][in] */ DBPROPSET __RPC_FAR rgPropertySets[  ],
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset);
        
        END_INTERFACE
    } IOpenRowsetVtbl;

    interface IOpenRowset
    {
        CONST_VTBL struct IOpenRowsetVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define IOpenRowset_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define IOpenRowset_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define IOpenRowset_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define IOpenRowset_OpenRowset(This,pUnkOuter,pTableID,pIndexID,riid,cPropertySets,rgPropertySets,ppRowset)	\
    (This)->lpVtbl -> OpenRowset(This,pUnkOuter,pTableID,pIndexID,riid,cPropertySets,rgPropertySets,ppRowset)

#endif /* COBJMACROS */


#endif 	/* C style interface */



/* [call_as] */ HRESULT STDMETHODCALLTYPE IOpenRowset_RemoteOpenRowset_Proxy( 
    IOpenRowset __RPC_FAR * This,
    /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
    /* [unique][in] */ DBID __RPC_FAR *pTableID,
    /* [unique][in] */ DBID __RPC_FAR *pIndexID,
    /* [in] */ REFIID riid,
    /* [in] */ ULONG cPropertySets,
    /* [size_is][unique][in] */ DBPROPSET __RPC_FAR *rgPropertySets,
    /* [iid_is][unique][out][in] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset,
    /* [in] */ ULONG cTotalProps,
    /* [size_is][out] */ DBPROPSTATUS __RPC_FAR *rgPropStatus,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IOpenRowset_RemoteOpenRowset_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __IOpenRowset_INTERFACE_DEFINED__ */


#ifndef __IDBSchemaRowset_INTERFACE_DEFINED__
#define __IDBSchemaRowset_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: IDBSchemaRowset
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object] */ 


#define CRESTRICTIONS_DBSCHEMA_ASSERTIONS                      3
#define CRESTRICTIONS_DBSCHEMA_CATALOGS                        1
#define CRESTRICTIONS_DBSCHEMA_CHARACTER_SETS                  3
#define CRESTRICTIONS_DBSCHEMA_COLLATIONS                      3
#define CRESTRICTIONS_DBSCHEMA_COLUMNS                         4
#define CRESTRICTIONS_DBSCHEMA_CHECK_CONSTRAINTS               3
#define CRESTRICTIONS_DBSCHEMA_CONSTRAINT_COLUMN_USAGE         4
#define CRESTRICTIONS_DBSCHEMA_CONSTRAINT_TABLE_USAGE          3
#define CRESTRICTIONS_DBSCHEMA_KEY_COLUMN_USAGE                7
#define CRESTRICTIONS_DBSCHEMA_REFERENTIAL_CONSTRAINTS         3
#define CRESTRICTIONS_DBSCHEMA_TABLE_CONSTRAINTS               7
#define CRESTRICTIONS_DBSCHEMA_COLUMN_DOMAIN_USAGE             4
#define CRESTRICTIONS_DBSCHEMA_INDEXES                         5
#define CRESTRICTIONS_DBSCHEMA_OBJECT_ACTIONS                  1
#define CRESTRICTIONS_DBSCHEMA_OBJECTS                         1
#define CRESTRICTIONS_DBSCHEMA_COLUMN_PRIVILEGES               6
#define CRESTRICTIONS_DBSCHEMA_TABLE_PRIVILEGES                5
#define CRESTRICTIONS_DBSCHEMA_USAGE_PRIVILEGES                6
#define CRESTRICTIONS_DBSCHEMA_PROCEDURES                      4
#define CRESTRICTIONS_DBSCHEMA_SCHEMATA                        3
#define CRESTRICTIONS_DBSCHEMA_SQL_LANGUAGES                   0
#define CRESTRICTIONS_DBSCHEMA_STATISTICS                      3
#define CRESTRICTIONS_DBSCHEMA_TABLES                          4
#define CRESTRICTIONS_DBSCHEMA_TRANSLATIONS                    3
#define CRESTRICTIONS_DBSCHEMA_PROVIDER_TYPES                  2
#define CRESTRICTIONS_DBSCHEMA_VIEWS                           3
#define CRESTRICTIONS_DBSCHEMA_VIEW_COLUMN_USAGE               3
#define CRESTRICTIONS_DBSCHEMA_VIEW_TABLE_USAGE                3
#define CRESTRICTIONS_DBSCHEMA_PROCEDURE_PARAMETERS            4
#define CRESTRICTIONS_DBSCHEMA_FOREIGN_KEYS                    6
#define CRESTRICTIONS_DBSCHEMA_PRIMARY_KEYS                    3
#define CRESTRICTIONS_DBSCHEMA_PROCEDURE_COLUMNS               4

#define CRESTRICTIONS_DBSCHEMA_TABLES_INFO                     4
#define CRESTRICTIONS_MDSCHEMA_CUBES                           3
#define CRESTRICTIONS_MDSCHEMA_DIMENSIONS                      5
#define CRESTRICTIONS_MDSCHEMA_HIERARCHIES                     6
#define CRESTRICTIONS_MDSCHEMA_LEVELS                          7
#define CRESTRICTIONS_MDSCHEMA_MEASURES                        5
#define CRESTRICTIONS_MDSCHEMA_PROPERTIES                      9
#define CRESTRICTIONS_MDSCHEMA_MEMBERS                         12

#define CRESTRICTIONS_DBSCHEMA_TRUSTEE		                     4

EXTERN_C const IID IID_IDBSchemaRowset;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733a7b-2a1c-11ce-ade5-00aa0044773d")
    IDBSchemaRowset : public IUnknown
    {
    public:
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetRowset( 
            /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
            /* [in] */ REFGUID rguidSchema,
            /* [in] */ ULONG cRestrictions,
            /* [size_is][in] */ const VARIANT __RPC_FAR rgRestrictions[  ],
            /* [in] */ REFIID riid,
            /* [in] */ ULONG cPropertySets,
            /* [size_is][unique][out][in] */ DBPROPSET __RPC_FAR rgPropertySets[  ],
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset) = 0;
        
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetSchemas( 
            /* [out][in] */ ULONG __RPC_FAR *pcSchemas,
            /* [size_is][size_is][out] */ GUID __RPC_FAR *__RPC_FAR *prgSchemas,
            /* [size_is][size_is][out] */ ULONG __RPC_FAR *__RPC_FAR *prgRestrictionSupport) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct IDBSchemaRowsetVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            IDBSchemaRowset __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            IDBSchemaRowset __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            IDBSchemaRowset __RPC_FAR * This);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetRowset )( 
            IDBSchemaRowset __RPC_FAR * This,
            /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
            /* [in] */ REFGUID rguidSchema,
            /* [in] */ ULONG cRestrictions,
            /* [size_is][in] */ const VARIANT __RPC_FAR rgRestrictions[  ],
            /* [in] */ REFIID riid,
            /* [in] */ ULONG cPropertySets,
            /* [size_is][unique][out][in] */ DBPROPSET __RPC_FAR rgPropertySets[  ],
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetSchemas )( 
            IDBSchemaRowset __RPC_FAR * This,
            /* [out][in] */ ULONG __RPC_FAR *pcSchemas,
            /* [size_is][size_is][out] */ GUID __RPC_FAR *__RPC_FAR *prgSchemas,
            /* [size_is][size_is][out] */ ULONG __RPC_FAR *__RPC_FAR *prgRestrictionSupport);
        
        END_INTERFACE
    } IDBSchemaRowsetVtbl;

    interface IDBSchemaRowset
    {
        CONST_VTBL struct IDBSchemaRowsetVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define IDBSchemaRowset_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define IDBSchemaRowset_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define IDBSchemaRowset_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define IDBSchemaRowset_GetRowset(This,pUnkOuter,rguidSchema,cRestrictions,rgRestrictions,riid,cPropertySets,rgPropertySets,ppRowset)	\
    (This)->lpVtbl -> GetRowset(This,pUnkOuter,rguidSchema,cRestrictions,rgRestrictions,riid,cPropertySets,rgPropertySets,ppRowset)

#define IDBSchemaRowset_GetSchemas(This,pcSchemas,prgSchemas,prgRestrictionSupport)	\
    (This)->lpVtbl -> GetSchemas(This,pcSchemas,prgSchemas,prgRestrictionSupport)

#endif /* COBJMACROS */


#endif 	/* C style interface */



/* [call_as] */ HRESULT STDMETHODCALLTYPE IDBSchemaRowset_RemoteGetRowset_Proxy( 
    IDBSchemaRowset __RPC_FAR * This,
    /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
    /* [in] */ REFGUID rguidSchema,
    /* [in] */ ULONG cRestrictions,
    /* [size_is][unique][in] */ const VARIANT __RPC_FAR *rgRestrictions,
    /* [in] */ REFIID riid,
    /* [in] */ ULONG cPropertySets,
    /* [size_is][unique][in] */ DBPROPSET __RPC_FAR *rgPropertySets,
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset,
    /* [in] */ ULONG cTotalProps,
    /* [size_is][out] */ DBPROPSTATUS __RPC_FAR *rgPropStatus,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IDBSchemaRowset_RemoteGetRowset_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IDBSchemaRowset_RemoteGetSchemas_Proxy( 
    IDBSchemaRowset __RPC_FAR * This,
    /* [out][in] */ ULONG __RPC_FAR *pcSchemas,
    /* [size_is][size_is][out] */ GUID __RPC_FAR *__RPC_FAR *prgSchemas,
    /* [size_is][size_is][out] */ ULONG __RPC_FAR *__RPC_FAR *prgRestrictionSupport,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IDBSchemaRowset_RemoteGetSchemas_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __IDBSchemaRowset_INTERFACE_DEFINED__ */


/****************************************
 * Generated header for interface: __MIDL_itf_oledb_0199
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [local] */ 


extern RPC_IF_HANDLE __MIDL_itf_oledb_0199_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_oledb_0199_v0_0_s_ifspec;

#ifndef __IMDDataset_INTERFACE_DEFINED__
#define __IMDDataset_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: IMDDataset
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object][local] */ 



EXTERN_C const IID IID_IMDDataset;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("a07cccd1-8148-11d0-87bb-00c04fc33942")
    IMDDataset : public IUnknown
    {
    public:
        virtual HRESULT STDMETHODCALLTYPE FreeAxisInfo( 
            /* [in] */ ULONG cAxes,
            /* [size_is][in] */ MDAXISINFO __RPC_FAR *rgAxisInfo) = 0;
        
        virtual HRESULT STDMETHODCALLTYPE GetAxisInfo( 
            /* [out][in] */ ULONG __RPC_FAR *pcAxes,
            /* [size_is][size_is][out] */ MDAXISINFO __RPC_FAR *__RPC_FAR *prgAxisInfo) = 0;
        
        virtual HRESULT STDMETHODCALLTYPE GetAxisRowset( 
            /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
            /* [in] */ ULONG iAxis,
            /* [in] */ REFIID riid,
            /* [in] */ ULONG cPropertySets,
            /* [size_is][out][in] */ DBPROPSET __RPC_FAR rgPropertySets[  ],
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset) = 0;
        
        virtual HRESULT STDMETHODCALLTYPE GetCellData( 
            /* [in] */ HACCESSOR hAccessor,
            /* [in] */ ULONG ulStartCell,
            /* [in] */ ULONG ulEndCell,
            /* [out] */ void __RPC_FAR *pData) = 0;
        
        virtual HRESULT STDMETHODCALLTYPE GetSpecification( 
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppSpecification) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct IMDDatasetVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            IMDDataset __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            IMDDataset __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            IMDDataset __RPC_FAR * This);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *FreeAxisInfo )( 
            IMDDataset __RPC_FAR * This,
            /* [in] */ ULONG cAxes,
            /* [size_is][in] */ MDAXISINFO __RPC_FAR *rgAxisInfo);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetAxisInfo )( 
            IMDDataset __RPC_FAR * This,
            /* [out][in] */ ULONG __RPC_FAR *pcAxes,
            /* [size_is][size_is][out] */ MDAXISINFO __RPC_FAR *__RPC_FAR *prgAxisInfo);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetAxisRowset )( 
            IMDDataset __RPC_FAR * This,
            /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
            /* [in] */ ULONG iAxis,
            /* [in] */ REFIID riid,
            /* [in] */ ULONG cPropertySets,
            /* [size_is][out][in] */ DBPROPSET __RPC_FAR rgPropertySets[  ],
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetCellData )( 
            IMDDataset __RPC_FAR * This,
            /* [in] */ HACCESSOR hAccessor,
            /* [in] */ ULONG ulStartCell,
            /* [in] */ ULONG ulEndCell,
            /* [out] */ void __RPC_FAR *pData);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetSpecification )( 
            IMDDataset __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppSpecification);
        
        END_INTERFACE
    } IMDDatasetVtbl;

    interface IMDDataset
    {
        CONST_VTBL struct IMDDatasetVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define IMDDataset_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define IMDDataset_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define IMDDataset_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define IMDDataset_FreeAxisInfo(This,cAxes,rgAxisInfo)	\
    (This)->lpVtbl -> FreeAxisInfo(This,cAxes,rgAxisInfo)

#define IMDDataset_GetAxisInfo(This,pcAxes,prgAxisInfo)	\
    (This)->lpVtbl -> GetAxisInfo(This,pcAxes,prgAxisInfo)

#define IMDDataset_GetAxisRowset(This,pUnkOuter,iAxis,riid,cPropertySets,rgPropertySets,ppRowset)	\
    (This)->lpVtbl -> GetAxisRowset(This,pUnkOuter,iAxis,riid,cPropertySets,rgPropertySets,ppRowset)

#define IMDDataset_GetCellData(This,hAccessor,ulStartCell,ulEndCell,pData)	\
    (This)->lpVtbl -> GetCellData(This,hAccessor,ulStartCell,ulEndCell,pData)

#define IMDDataset_GetSpecification(This,riid,ppSpecification)	\
    (This)->lpVtbl -> GetSpecification(This,riid,ppSpecification)

#endif /* COBJMACROS */


#endif 	/* C style interface */



HRESULT STDMETHODCALLTYPE IMDDataset_FreeAxisInfo_Proxy( 
    IMDDataset __RPC_FAR * This,
    /* [in] */ ULONG cAxes,
    /* [size_is][in] */ MDAXISINFO __RPC_FAR *rgAxisInfo);


void __RPC_STUB IMDDataset_FreeAxisInfo_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


HRESULT STDMETHODCALLTYPE IMDDataset_GetAxisInfo_Proxy( 
    IMDDataset __RPC_FAR * This,
    /* [out][in] */ ULONG __RPC_FAR *pcAxes,
    /* [size_is][size_is][out] */ MDAXISINFO __RPC_FAR *__RPC_FAR *prgAxisInfo);


void __RPC_STUB IMDDataset_GetAxisInfo_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


HRESULT STDMETHODCALLTYPE IMDDataset_GetAxisRowset_Proxy( 
    IMDDataset __RPC_FAR * This,
    /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
    /* [in] */ ULONG iAxis,
    /* [in] */ REFIID riid,
    /* [in] */ ULONG cPropertySets,
    /* [size_is][out][in] */ DBPROPSET __RPC_FAR rgPropertySets[  ],
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset);


void __RPC_STUB IMDDataset_GetAxisRowset_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


HRESULT STDMETHODCALLTYPE IMDDataset_GetCellData_Proxy( 
    IMDDataset __RPC_FAR * This,
    /* [in] */ HACCESSOR hAccessor,
    /* [in] */ ULONG ulStartCell,
    /* [in] */ ULONG ulEndCell,
    /* [out] */ void __RPC_FAR *pData);


void __RPC_STUB IMDDataset_GetCellData_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


HRESULT STDMETHODCALLTYPE IMDDataset_GetSpecification_Proxy( 
    IMDDataset __RPC_FAR * This,
    /* [in] */ REFIID riid,
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppSpecification);


void __RPC_STUB IMDDataset_GetSpecification_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __IMDDataset_INTERFACE_DEFINED__ */


#ifndef __IMDFind_INTERFACE_DEFINED__
#define __IMDFind_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: IMDFind
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object][local] */ 



EXTERN_C const IID IID_IMDFind;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("a07cccd2-8148-11d0-87bb-00c04fc33942")
    IMDFind : public IUnknown
    {
    public:
        virtual HRESULT STDMETHODCALLTYPE FindCell( 
            /* [in] */ ULONG ulStartingOrdinal,
            /* [in] */ ULONG cMembers,
            /* [size_is][in] */ LPCOLESTR __RPC_FAR *rgpwszMember,
            /* [out] */ ULONG __RPC_FAR *pulCellOrdinal) = 0;
        
        virtual HRESULT STDMETHODCALLTYPE FindTuple( 
            /* [in] */ ULONG ulAxisIdentifier,
            /* [in] */ ULONG ulStartingOrdinal,
            /* [in] */ ULONG cMembers,
            /* [size_is][in] */ LPCOLESTR __RPC_FAR *rgpwszMember,
            /* [out] */ ULONG __RPC_FAR *pulTupleOrdinal) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct IMDFindVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            IMDFind __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            IMDFind __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            IMDFind __RPC_FAR * This);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *FindCell )( 
            IMDFind __RPC_FAR * This,
            /* [in] */ ULONG ulStartingOrdinal,
            /* [in] */ ULONG cMembers,
            /* [size_is][in] */ LPCOLESTR __RPC_FAR *rgpwszMember,
            /* [out] */ ULONG __RPC_FAR *pulCellOrdinal);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *FindTuple )( 
            IMDFind __RPC_FAR * This,
            /* [in] */ ULONG ulAxisIdentifier,
            /* [in] */ ULONG ulStartingOrdinal,
            /* [in] */ ULONG cMembers,
            /* [size_is][in] */ LPCOLESTR __RPC_FAR *rgpwszMember,
            /* [out] */ ULONG __RPC_FAR *pulTupleOrdinal);
        
        END_INTERFACE
    } IMDFindVtbl;

    interface IMDFind
    {
        CONST_VTBL struct IMDFindVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define IMDFind_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define IMDFind_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define IMDFind_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define IMDFind_FindCell(This,ulStartingOrdinal,cMembers,rgpwszMember,pulCellOrdinal)	\
    (This)->lpVtbl -> FindCell(This,ulStartingOrdinal,cMembers,rgpwszMember,pulCellOrdinal)

#define IMDFind_FindTuple(This,ulAxisIdentifier,ulStartingOrdinal,cMembers,rgpwszMember,pulTupleOrdinal)	\
    (This)->lpVtbl -> FindTuple(This,ulAxisIdentifier,ulStartingOrdinal,cMembers,rgpwszMember,pulTupleOrdinal)

#endif /* COBJMACROS */


#endif 	/* C style interface */



HRESULT STDMETHODCALLTYPE IMDFind_FindCell_Proxy( 
    IMDFind __RPC_FAR * This,
    /* [in] */ ULONG ulStartingOrdinal,
    /* [in] */ ULONG cMembers,
    /* [size_is][in] */ LPCOLESTR __RPC_FAR *rgpwszMember,
    /* [out] */ ULONG __RPC_FAR *pulCellOrdinal);


void __RPC_STUB IMDFind_FindCell_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


HRESULT STDMETHODCALLTYPE IMDFind_FindTuple_Proxy( 
    IMDFind __RPC_FAR * This,
    /* [in] */ ULONG ulAxisIdentifier,
    /* [in] */ ULONG ulStartingOrdinal,
    /* [in] */ ULONG cMembers,
    /* [size_is][in] */ LPCOLESTR __RPC_FAR *rgpwszMember,
    /* [out] */ ULONG __RPC_FAR *pulTupleOrdinal);


void __RPC_STUB IMDFind_FindTuple_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __IMDFind_INTERFACE_DEFINED__ */


#ifndef __IMDRangeRowset_INTERFACE_DEFINED__
#define __IMDRangeRowset_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: IMDRangeRowset
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object][local] */ 



EXTERN_C const IID IID_IMDRangeRowset;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733aa0-2a1c-11ce-ade5-00aa0044773d")
    IMDRangeRowset : public IUnknown
    {
    public:
        virtual HRESULT STDMETHODCALLTYPE GetRangeRowset( 
            /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
            /* [in] */ ULONG ulStartCell,
            /* [in] */ ULONG ulEndCell,
            /* [in] */ REFIID riid,
            /* [in] */ ULONG cPropertySets,
            /* [size_is][out][in] */ DBPROPSET __RPC_FAR rgPropertySets[  ],
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct IMDRangeRowsetVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            IMDRangeRowset __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            IMDRangeRowset __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            IMDRangeRowset __RPC_FAR * This);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetRangeRowset )( 
            IMDRangeRowset __RPC_FAR * This,
            /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
            /* [in] */ ULONG ulStartCell,
            /* [in] */ ULONG ulEndCell,
            /* [in] */ REFIID riid,
            /* [in] */ ULONG cPropertySets,
            /* [size_is][out][in] */ DBPROPSET __RPC_FAR rgPropertySets[  ],
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset);
        
        END_INTERFACE
    } IMDRangeRowsetVtbl;

    interface IMDRangeRowset
    {
        CONST_VTBL struct IMDRangeRowsetVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define IMDRangeRowset_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define IMDRangeRowset_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define IMDRangeRowset_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define IMDRangeRowset_GetRangeRowset(This,pUnkOuter,ulStartCell,ulEndCell,riid,cPropertySets,rgPropertySets,ppRowset)	\
    (This)->lpVtbl -> GetRangeRowset(This,pUnkOuter,ulStartCell,ulEndCell,riid,cPropertySets,rgPropertySets,ppRowset)

#endif /* COBJMACROS */


#endif 	/* C style interface */



HRESULT STDMETHODCALLTYPE IMDRangeRowset_GetRangeRowset_Proxy( 
    IMDRangeRowset __RPC_FAR * This,
    /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
    /* [in] */ ULONG ulStartCell,
    /* [in] */ ULONG ulEndCell,
    /* [in] */ REFIID riid,
    /* [in] */ ULONG cPropertySets,
    /* [size_is][out][in] */ DBPROPSET __RPC_FAR rgPropertySets[  ],
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset);


void __RPC_STUB IMDRangeRowset_GetRangeRowset_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __IMDRangeRowset_INTERFACE_DEFINED__ */


#ifndef __IAlterTable_INTERFACE_DEFINED__
#define __IAlterTable_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: IAlterTable
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object][local] */ 



EXTERN_C const IID IID_IAlterTable;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733aa5-2a1c-11ce-ade5-00aa0044773d")
    IAlterTable : public IUnknown
    {
    public:
        virtual HRESULT STDMETHODCALLTYPE AlterColumn( 
            /* [in] */ DBID __RPC_FAR *pTableId,
            /* [in] */ DBID __RPC_FAR *pColumnId,
            /* [in] */ DBCOLUMNDESCFLAGS ColumnDescFlags,
            /* [in] */ DBCOLUMNDESC __RPC_FAR *pColumnDesc) = 0;
        
        virtual HRESULT STDMETHODCALLTYPE AlterTable( 
            /* [in] */ DBID __RPC_FAR *pTableId,
            /* [in] */ DBID __RPC_FAR *pNewTableId,
            /* [in] */ ULONG cPropertySets,
            /* [size_is][out][in] */ DBPROPSET __RPC_FAR rgPropertySets[  ]) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct IAlterTableVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            IAlterTable __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            IAlterTable __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            IAlterTable __RPC_FAR * This);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *AlterColumn )( 
            IAlterTable __RPC_FAR * This,
            /* [in] */ DBID __RPC_FAR *pTableId,
            /* [in] */ DBID __RPC_FAR *pColumnId,
            /* [in] */ DBCOLUMNDESCFLAGS ColumnDescFlags,
            /* [in] */ DBCOLUMNDESC __RPC_FAR *pColumnDesc);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *AlterTable )( 
            IAlterTable __RPC_FAR * This,
            /* [in] */ DBID __RPC_FAR *pTableId,
            /* [in] */ DBID __RPC_FAR *pNewTableId,
            /* [in] */ ULONG cPropertySets,
            /* [size_is][out][in] */ DBPROPSET __RPC_FAR rgPropertySets[  ]);
        
        END_INTERFACE
    } IAlterTableVtbl;

    interface IAlterTable
    {
        CONST_VTBL struct IAlterTableVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define IAlterTable_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define IAlterTable_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define IAlterTable_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define IAlterTable_AlterColumn(This,pTableId,pColumnId,ColumnDescFlags,pColumnDesc)	\
    (This)->lpVtbl -> AlterColumn(This,pTableId,pColumnId,ColumnDescFlags,pColumnDesc)

#define IAlterTable_AlterTable(This,pTableId,pNewTableId,cPropertySets,rgPropertySets)	\
    (This)->lpVtbl -> AlterTable(This,pTableId,pNewTableId,cPropertySets,rgPropertySets)

#endif /* COBJMACROS */


#endif 	/* C style interface */



HRESULT STDMETHODCALLTYPE IAlterTable_AlterColumn_Proxy( 
    IAlterTable __RPC_FAR * This,
    /* [in] */ DBID __RPC_FAR *pTableId,
    /* [in] */ DBID __RPC_FAR *pColumnId,
    /* [in] */ DBCOLUMNDESCFLAGS ColumnDescFlags,
    /* [in] */ DBCOLUMNDESC __RPC_FAR *pColumnDesc);


void __RPC_STUB IAlterTable_AlterColumn_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


HRESULT STDMETHODCALLTYPE IAlterTable_AlterTable_Proxy( 
    IAlterTable __RPC_FAR * This,
    /* [in] */ DBID __RPC_FAR *pTableId,
    /* [in] */ DBID __RPC_FAR *pNewTableId,
    /* [in] */ ULONG cPropertySets,
    /* [size_is][out][in] */ DBPROPSET __RPC_FAR rgPropertySets[  ]);


void __RPC_STUB IAlterTable_AlterTable_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __IAlterTable_INTERFACE_DEFINED__ */


#ifndef __IAlterIndex_INTERFACE_DEFINED__
#define __IAlterIndex_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: IAlterIndex
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object][local] */ 



EXTERN_C const IID IID_IAlterIndex;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733aa6-2a1c-11ce-ade5-00aa0044773d")
    IAlterIndex : public IUnknown
    {
    public:
        virtual HRESULT STDMETHODCALLTYPE AlterIndex( 
            /* [in] */ DBID __RPC_FAR *pTableId,
            /* [in] */ DBID __RPC_FAR *pIndexId,
            /* [in] */ DBID __RPC_FAR *pNewIndexId,
            /* [in] */ ULONG cPropertySets,
            /* [size_is][out][in] */ DBPROPSET __RPC_FAR rgPropertySet[  ]) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct IAlterIndexVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            IAlterIndex __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            IAlterIndex __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            IAlterIndex __RPC_FAR * This);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *AlterIndex )( 
            IAlterIndex __RPC_FAR * This,
            /* [in] */ DBID __RPC_FAR *pTableId,
            /* [in] */ DBID __RPC_FAR *pIndexId,
            /* [in] */ DBID __RPC_FAR *pNewIndexId,
            /* [in] */ ULONG cPropertySets,
            /* [size_is][out][in] */ DBPROPSET __RPC_FAR rgPropertySet[  ]);
        
        END_INTERFACE
    } IAlterIndexVtbl;

    interface IAlterIndex
    {
        CONST_VTBL struct IAlterIndexVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define IAlterIndex_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define IAlterIndex_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define IAlterIndex_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define IAlterIndex_AlterIndex(This,pTableId,pIndexId,pNewIndexId,cPropertySets,rgPropertySet)	\
    (This)->lpVtbl -> AlterIndex(This,pTableId,pIndexId,pNewIndexId,cPropertySets,rgPropertySet)

#endif /* COBJMACROS */


#endif 	/* C style interface */



HRESULT STDMETHODCALLTYPE IAlterIndex_AlterIndex_Proxy( 
    IAlterIndex __RPC_FAR * This,
    /* [in] */ DBID __RPC_FAR *pTableId,
    /* [in] */ DBID __RPC_FAR *pIndexId,
    /* [in] */ DBID __RPC_FAR *pNewIndexId,
    /* [in] */ ULONG cPropertySets,
    /* [size_is][out][in] */ DBPROPSET __RPC_FAR rgPropertySet[  ]);


void __RPC_STUB IAlterIndex_AlterIndex_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __IAlterIndex_INTERFACE_DEFINED__ */


#ifndef __IRowsetChapterMember_INTERFACE_DEFINED__
#define __IRowsetChapterMember_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: IRowsetChapterMember
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object][local] */ 



EXTERN_C const IID IID_IRowsetChapterMember;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733aa8-2a1c-11ce-ade5-00aa0044773d")
    IRowsetChapterMember : public IUnknown
    {
    public:
        virtual HRESULT STDMETHODCALLTYPE IsRowInChapter( 
            /* [in] */ HCHAPTER hChapter,
            /* [in] */ HROW hRow) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct IRowsetChapterMemberVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            IRowsetChapterMember __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            IRowsetChapterMember __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            IRowsetChapterMember __RPC_FAR * This);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *IsRowInChapter )( 
            IRowsetChapterMember __RPC_FAR * This,
            /* [in] */ HCHAPTER hChapter,
            /* [in] */ HROW hRow);
        
        END_INTERFACE
    } IRowsetChapterMemberVtbl;

    interface IRowsetChapterMember
    {
        CONST_VTBL struct IRowsetChapterMemberVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define IRowsetChapterMember_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define IRowsetChapterMember_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define IRowsetChapterMember_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define IRowsetChapterMember_IsRowInChapter(This,hChapter,hRow)	\
    (This)->lpVtbl -> IsRowInChapter(This,hChapter,hRow)

#endif /* COBJMACROS */


#endif 	/* C style interface */



HRESULT STDMETHODCALLTYPE IRowsetChapterMember_IsRowInChapter_Proxy( 
    IRowsetChapterMember __RPC_FAR * This,
    /* [in] */ HCHAPTER hChapter,
    /* [in] */ HROW hRow);


void __RPC_STUB IRowsetChapterMember_IsRowInChapter_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __IRowsetChapterMember_INTERFACE_DEFINED__ */


#ifndef __ICommandPersist_INTERFACE_DEFINED__
#define __ICommandPersist_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: ICommandPersist
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object][local] */ 



EXTERN_C const IID IID_ICommandPersist;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733aa7-2a1c-11ce-ade5-00aa0044773d")
    ICommandPersist : public IUnknown
    {
    public:
        virtual HRESULT STDMETHODCALLTYPE DeleteCommand( 
            /* [in] */ DBID __RPC_FAR *pCommandID) = 0;
        
        virtual HRESULT STDMETHODCALLTYPE GetCurrentCommand( 
            /* [out] */ DBID __RPC_FAR *__RPC_FAR *ppCommandID) = 0;
        
        virtual HRESULT STDMETHODCALLTYPE LoadCommand( 
            /* [in] */ DBID __RPC_FAR *pCommandID,
            /* [in] */ DWORD dwFlags) = 0;
        
        virtual HRESULT STDMETHODCALLTYPE SaveCommand( 
            /* [in] */ DBID __RPC_FAR *pCommandID,
            /* [in] */ DWORD dwFlags) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct ICommandPersistVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            ICommandPersist __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            ICommandPersist __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            ICommandPersist __RPC_FAR * This);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *DeleteCommand )( 
            ICommandPersist __RPC_FAR * This,
            /* [in] */ DBID __RPC_FAR *pCommandID);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetCurrentCommand )( 
            ICommandPersist __RPC_FAR * This,
            /* [out] */ DBID __RPC_FAR *__RPC_FAR *ppCommandID);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *LoadCommand )( 
            ICommandPersist __RPC_FAR * This,
            /* [in] */ DBID __RPC_FAR *pCommandID,
            /* [in] */ DWORD dwFlags);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *SaveCommand )( 
            ICommandPersist __RPC_FAR * This,
            /* [in] */ DBID __RPC_FAR *pCommandID,
            /* [in] */ DWORD dwFlags);
        
        END_INTERFACE
    } ICommandPersistVtbl;

    interface ICommandPersist
    {
        CONST_VTBL struct ICommandPersistVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define ICommandPersist_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define ICommandPersist_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define ICommandPersist_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define ICommandPersist_DeleteCommand(This,pCommandID)	\
    (This)->lpVtbl -> DeleteCommand(This,pCommandID)

#define ICommandPersist_GetCurrentCommand(This,ppCommandID)	\
    (This)->lpVtbl -> GetCurrentCommand(This,ppCommandID)

#define ICommandPersist_LoadCommand(This,pCommandID,dwFlags)	\
    (This)->lpVtbl -> LoadCommand(This,pCommandID,dwFlags)

#define ICommandPersist_SaveCommand(This,pCommandID,dwFlags)	\
    (This)->lpVtbl -> SaveCommand(This,pCommandID,dwFlags)

#endif /* COBJMACROS */


#endif 	/* C style interface */



HRESULT STDMETHODCALLTYPE ICommandPersist_DeleteCommand_Proxy( 
    ICommandPersist __RPC_FAR * This,
    /* [in] */ DBID __RPC_FAR *pCommandID);


void __RPC_STUB ICommandPersist_DeleteCommand_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


HRESULT STDMETHODCALLTYPE ICommandPersist_GetCurrentCommand_Proxy( 
    ICommandPersist __RPC_FAR * This,
    /* [out] */ DBID __RPC_FAR *__RPC_FAR *ppCommandID);


void __RPC_STUB ICommandPersist_GetCurrentCommand_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


HRESULT STDMETHODCALLTYPE ICommandPersist_LoadCommand_Proxy( 
    ICommandPersist __RPC_FAR * This,
    /* [in] */ DBID __RPC_FAR *pCommandID,
    /* [in] */ DWORD dwFlags);


void __RPC_STUB ICommandPersist_LoadCommand_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


HRESULT STDMETHODCALLTYPE ICommandPersist_SaveCommand_Proxy( 
    ICommandPersist __RPC_FAR * This,
    /* [in] */ DBID __RPC_FAR *pCommandID,
    /* [in] */ DWORD dwFlags);


void __RPC_STUB ICommandPersist_SaveCommand_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __ICommandPersist_INTERFACE_DEFINED__ */


#ifndef __IRowsetRefresh_INTERFACE_DEFINED__
#define __IRowsetRefresh_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: IRowsetRefresh
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object][local] */ 



EXTERN_C const IID IID_IRowsetRefresh;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733aa9-2a1c-11ce-ade5-00aa0044773d")
    IRowsetRefresh : public IUnknown
    {
    public:
        virtual HRESULT STDMETHODCALLTYPE RefreshVisibleData( 
            /* [in] */ HCHAPTER hChapter,
            /* [in] */ ULONG cRows,
            /* [in] */ const HROW __RPC_FAR rghRows[  ],
            /* [in] */ BOOL fOverWrite,
            /* [out] */ ULONG __RPC_FAR *pcRowsRefreshed,
            /* [out] */ HROW __RPC_FAR *__RPC_FAR *prghRowsRefreshed,
            /* [out] */ DBROWSTATUS __RPC_FAR *__RPC_FAR *prgRowStatus) = 0;
        
        virtual HRESULT STDMETHODCALLTYPE GetLastVisibleData( 
            /* [in] */ HROW hRow,
            /* [in] */ HACCESSOR hAccessor,
            /* [out] */ void __RPC_FAR *pData) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct IRowsetRefreshVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            IRowsetRefresh __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            IRowsetRefresh __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            IRowsetRefresh __RPC_FAR * This);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *RefreshVisibleData )( 
            IRowsetRefresh __RPC_FAR * This,
            /* [in] */ HCHAPTER hChapter,
            /* [in] */ ULONG cRows,
            /* [in] */ const HROW __RPC_FAR rghRows[  ],
            /* [in] */ BOOL fOverWrite,
            /* [out] */ ULONG __RPC_FAR *pcRowsRefreshed,
            /* [out] */ HROW __RPC_FAR *__RPC_FAR *prghRowsRefreshed,
            /* [out] */ DBROWSTATUS __RPC_FAR *__RPC_FAR *prgRowStatus);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetLastVisibleData )( 
            IRowsetRefresh __RPC_FAR * This,
            /* [in] */ HROW hRow,
            /* [in] */ HACCESSOR hAccessor,
            /* [out] */ void __RPC_FAR *pData);
        
        END_INTERFACE
    } IRowsetRefreshVtbl;

    interface IRowsetRefresh
    {
        CONST_VTBL struct IRowsetRefreshVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define IRowsetRefresh_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define IRowsetRefresh_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define IRowsetRefresh_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define IRowsetRefresh_RefreshVisibleData(This,hChapter,cRows,rghRows,fOverWrite,pcRowsRefreshed,prghRowsRefreshed,prgRowStatus)	\
    (This)->lpVtbl -> RefreshVisibleData(This,hChapter,cRows,rghRows,fOverWrite,pcRowsRefreshed,prghRowsRefreshed,prgRowStatus)

#define IRowsetRefresh_GetLastVisibleData(This,hRow,hAccessor,pData)	\
    (This)->lpVtbl -> GetLastVisibleData(This,hRow,hAccessor,pData)

#endif /* COBJMACROS */


#endif 	/* C style interface */



HRESULT STDMETHODCALLTYPE IRowsetRefresh_RefreshVisibleData_Proxy( 
    IRowsetRefresh __RPC_FAR * This,
    /* [in] */ HCHAPTER hChapter,
    /* [in] */ ULONG cRows,
    /* [in] */ const HROW __RPC_FAR rghRows[  ],
    /* [in] */ BOOL fOverWrite,
    /* [out] */ ULONG __RPC_FAR *pcRowsRefreshed,
    /* [out] */ HROW __RPC_FAR *__RPC_FAR *prghRowsRefreshed,
    /* [out] */ DBROWSTATUS __RPC_FAR *__RPC_FAR *prgRowStatus);


void __RPC_STUB IRowsetRefresh_RefreshVisibleData_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


HRESULT STDMETHODCALLTYPE IRowsetRefresh_GetLastVisibleData_Proxy( 
    IRowsetRefresh __RPC_FAR * This,
    /* [in] */ HROW hRow,
    /* [in] */ HACCESSOR hAccessor,
    /* [out] */ void __RPC_FAR *pData);


void __RPC_STUB IRowsetRefresh_GetLastVisibleData_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __IRowsetRefresh_INTERFACE_DEFINED__ */


#ifndef __IParentRowset_INTERFACE_DEFINED__
#define __IParentRowset_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: IParentRowset
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object][local] */ 



EXTERN_C const IID IID_IParentRowset;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733aaa-2a1c-11ce-ade5-00aa0044773d")
    IParentRowset : public IUnknown
    {
    public:
        virtual HRESULT STDMETHODCALLTYPE GetChildRowset( 
            /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
            /* [in] */ ULONG iOrdinal,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct IParentRowsetVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            IParentRowset __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            IParentRowset __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            IParentRowset __RPC_FAR * This);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetChildRowset )( 
            IParentRowset __RPC_FAR * This,
            /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
            /* [in] */ ULONG iOrdinal,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset);
        
        END_INTERFACE
    } IParentRowsetVtbl;

    interface IParentRowset
    {
        CONST_VTBL struct IParentRowsetVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define IParentRowset_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define IParentRowset_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define IParentRowset_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define IParentRowset_GetChildRowset(This,pUnkOuter,iOrdinal,riid,ppRowset)	\
    (This)->lpVtbl -> GetChildRowset(This,pUnkOuter,iOrdinal,riid,ppRowset)

#endif /* COBJMACROS */


#endif 	/* C style interface */



HRESULT STDMETHODCALLTYPE IParentRowset_GetChildRowset_Proxy( 
    IParentRowset __RPC_FAR * This,
    /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
    /* [in] */ ULONG iOrdinal,
    /* [in] */ REFIID riid,
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset);


void __RPC_STUB IParentRowset_GetChildRowset_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __IParentRowset_INTERFACE_DEFINED__ */


/****************************************
 * Generated header for interface: __MIDL_itf_oledb_0208
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [local] */ 


extern RPC_IF_HANDLE __MIDL_itf_oledb_0208_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_oledb_0208_v0_0_s_ifspec;

#ifndef __IErrorRecords_INTERFACE_DEFINED__
#define __IErrorRecords_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: IErrorRecords
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object] */ 


#define IDENTIFIER_SDK_MASK	0xF0000000
#define IDENTIFIER_SDK_ERROR	0x10000000
typedef struct  tagERRORINFO
    {
    HRESULT hrError;
    DWORD dwMinor;
    CLSID clsid;
    IID iid;
    DISPID dispid;
    }	ERRORINFO;


EXTERN_C const IID IID_IErrorRecords;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733a67-2a1c-11ce-ade5-00aa0044773d")
    IErrorRecords : public IUnknown
    {
    public:
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE AddErrorRecord( 
            /* [in] */ ERRORINFO __RPC_FAR *pErrorInfo,
            /* [in] */ DWORD dwLookupID,
            /* [in] */ DISPPARAMS __RPC_FAR *pdispparams,
            /* [in] */ IUnknown __RPC_FAR *punkCustomError,
            /* [in] */ DWORD dwDynamicErrorID) = 0;
        
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetBasicErrorInfo( 
            /* [in] */ ULONG ulRecordNum,
            /* [out] */ ERRORINFO __RPC_FAR *pErrorInfo) = 0;
        
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetCustomErrorObject( 
            /* [in] */ ULONG ulRecordNum,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppObject) = 0;
        
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetErrorInfo( 
            /* [in] */ ULONG ulRecordNum,
            /* [in] */ LCID lcid,
            /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfo) = 0;
        
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetErrorParameters( 
            /* [in] */ ULONG ulRecordNum,
            /* [out] */ DISPPARAMS __RPC_FAR *pdispparams) = 0;
        
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetRecordCount( 
            /* [out] */ ULONG __RPC_FAR *pcRecords) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct IErrorRecordsVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            IErrorRecords __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            IErrorRecords __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            IErrorRecords __RPC_FAR * This);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *AddErrorRecord )( 
            IErrorRecords __RPC_FAR * This,
            /* [in] */ ERRORINFO __RPC_FAR *pErrorInfo,
            /* [in] */ DWORD dwLookupID,
            /* [in] */ DISPPARAMS __RPC_FAR *pdispparams,
            /* [in] */ IUnknown __RPC_FAR *punkCustomError,
            /* [in] */ DWORD dwDynamicErrorID);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetBasicErrorInfo )( 
            IErrorRecords __RPC_FAR * This,
            /* [in] */ ULONG ulRecordNum,
            /* [out] */ ERRORINFO __RPC_FAR *pErrorInfo);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetCustomErrorObject )( 
            IErrorRecords __RPC_FAR * This,
            /* [in] */ ULONG ulRecordNum,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppObject);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetErrorInfo )( 
            IErrorRecords __RPC_FAR * This,
            /* [in] */ ULONG ulRecordNum,
            /* [in] */ LCID lcid,
            /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfo);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetErrorParameters )( 
            IErrorRecords __RPC_FAR * This,
            /* [in] */ ULONG ulRecordNum,
            /* [out] */ DISPPARAMS __RPC_FAR *pdispparams);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetRecordCount )( 
            IErrorRecords __RPC_FAR * This,
            /* [out] */ ULONG __RPC_FAR *pcRecords);
        
        END_INTERFACE
    } IErrorRecordsVtbl;

    interface IErrorRecords
    {
        CONST_VTBL struct IErrorRecordsVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define IErrorRecords_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define IErrorRecords_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define IErrorRecords_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define IErrorRecords_AddErrorRecord(This,pErrorInfo,dwLookupID,pdispparams,punkCustomError,dwDynamicErrorID)	\
    (This)->lpVtbl -> AddErrorRecord(This,pErrorInfo,dwLookupID,pdispparams,punkCustomError,dwDynamicErrorID)

#define IErrorRecords_GetBasicErrorInfo(This,ulRecordNum,pErrorInfo)	\
    (This)->lpVtbl -> GetBasicErrorInfo(This,ulRecordNum,pErrorInfo)

#define IErrorRecords_GetCustomErrorObject(This,ulRecordNum,riid,ppObject)	\
    (This)->lpVtbl -> GetCustomErrorObject(This,ulRecordNum,riid,ppObject)

#define IErrorRecords_GetErrorInfo(This,ulRecordNum,lcid,ppErrorInfo)	\
    (This)->lpVtbl -> GetErrorInfo(This,ulRecordNum,lcid,ppErrorInfo)

#define IErrorRecords_GetErrorParameters(This,ulRecordNum,pdispparams)	\
    (This)->lpVtbl -> GetErrorParameters(This,ulRecordNum,pdispparams)

#define IErrorRecords_GetRecordCount(This,pcRecords)	\
    (This)->lpVtbl -> GetRecordCount(This,pcRecords)

#endif /* COBJMACROS */


#endif 	/* C style interface */



/* [call_as] */ HRESULT STDMETHODCALLTYPE IErrorRecords_RemoteAddErrorRecord_Proxy( 
    IErrorRecords __RPC_FAR * This,
    /* [in] */ ERRORINFO __RPC_FAR *pErrorInfo,
    /* [in] */ DWORD dwLookupID,
    /* [in] */ DISPPARAMS __RPC_FAR *pdispparams,
    /* [in] */ IUnknown __RPC_FAR *punkCustomError,
    /* [in] */ DWORD dwDynamicErrorID,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IErrorRecords_RemoteAddErrorRecord_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IErrorRecords_RemoteGetBasicErrorInfo_Proxy( 
    IErrorRecords __RPC_FAR * This,
    /* [in] */ ULONG ulRecordNum,
    /* [out] */ ERRORINFO __RPC_FAR *pErrorInfo,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IErrorRecords_RemoteGetBasicErrorInfo_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IErrorRecords_RemoteGetCustomErrorObject_Proxy( 
    IErrorRecords __RPC_FAR * This,
    /* [in] */ ULONG ulRecordNum,
    /* [in] */ REFIID riid,
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppObject,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IErrorRecords_RemoteGetCustomErrorObject_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IErrorRecords_RemoteGetErrorInfo_Proxy( 
    IErrorRecords __RPC_FAR * This,
    /* [in] */ ULONG ulRecordNum,
    /* [in] */ LCID lcid,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfo,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IErrorRecords_RemoteGetErrorInfo_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IErrorRecords_RemoteGetErrorParameters_Proxy( 
    IErrorRecords __RPC_FAR * This,
    /* [in] */ ULONG ulRecordNum,
    /* [out] */ DISPPARAMS __RPC_FAR *pdispparams,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IErrorRecords_RemoteGetErrorParameters_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IErrorRecords_RemoteGetRecordCount_Proxy( 
    IErrorRecords __RPC_FAR * This,
    /* [out] */ ULONG __RPC_FAR *pcRecords,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IErrorRecords_RemoteGetRecordCount_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __IErrorRecords_INTERFACE_DEFINED__ */


#ifndef __IErrorLookup_INTERFACE_DEFINED__
#define __IErrorLookup_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: IErrorLookup
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object] */ 



EXTERN_C const IID IID_IErrorLookup;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733a66-2a1c-11ce-ade5-00aa0044773d")
    IErrorLookup : public IUnknown
    {
    public:
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetErrorDescription( 
            /* [in] */ HRESULT hrError,
            /* [in] */ DWORD dwLookupID,
            /* [in] */ DISPPARAMS __RPC_FAR *pdispparams,
            /* [in] */ LCID lcid,
            /* [out] */ BSTR __RPC_FAR *pbstrSource,
            /* [out] */ BSTR __RPC_FAR *pbstrDescription) = 0;
        
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetHelpInfo( 
            /* [in] */ HRESULT hrError,
            /* [in] */ DWORD dwLookupID,
            /* [in] */ LCID lcid,
            /* [out] */ BSTR __RPC_FAR *pbstrHelpFile,
            /* [out] */ DWORD __RPC_FAR *pdwHelpContext) = 0;
        
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE ReleaseErrors( 
            /* [in] */ const DWORD dwDynamicErrorID) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct IErrorLookupVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            IErrorLookup __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            IErrorLookup __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            IErrorLookup __RPC_FAR * This);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetErrorDescription )( 
            IErrorLookup __RPC_FAR * This,
            /* [in] */ HRESULT hrError,
            /* [in] */ DWORD dwLookupID,
            /* [in] */ DISPPARAMS __RPC_FAR *pdispparams,
            /* [in] */ LCID lcid,
            /* [out] */ BSTR __RPC_FAR *pbstrSource,
            /* [out] */ BSTR __RPC_FAR *pbstrDescription);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetHelpInfo )( 
            IErrorLookup __RPC_FAR * This,
            /* [in] */ HRESULT hrError,
            /* [in] */ DWORD dwLookupID,
            /* [in] */ LCID lcid,
            /* [out] */ BSTR __RPC_FAR *pbstrHelpFile,
            /* [out] */ DWORD __RPC_FAR *pdwHelpContext);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *ReleaseErrors )( 
            IErrorLookup __RPC_FAR * This,
            /* [in] */ const DWORD dwDynamicErrorID);
        
        END_INTERFACE
    } IErrorLookupVtbl;

    interface IErrorLookup
    {
        CONST_VTBL struct IErrorLookupVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define IErrorLookup_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define IErrorLookup_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define IErrorLookup_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define IErrorLookup_GetErrorDescription(This,hrError,dwLookupID,pdispparams,lcid,pbstrSource,pbstrDescription)	\
    (This)->lpVtbl -> GetErrorDescription(This,hrError,dwLookupID,pdispparams,lcid,pbstrSource,pbstrDescription)

#define IErrorLookup_GetHelpInfo(This,hrError,dwLookupID,lcid,pbstrHelpFile,pdwHelpContext)	\
    (This)->lpVtbl -> GetHelpInfo(This,hrError,dwLookupID,lcid,pbstrHelpFile,pdwHelpContext)

#define IErrorLookup_ReleaseErrors(This,dwDynamicErrorID)	\
    (This)->lpVtbl -> ReleaseErrors(This,dwDynamicErrorID)

#endif /* COBJMACROS */


#endif 	/* C style interface */



/* [call_as] */ HRESULT STDMETHODCALLTYPE IErrorLookup_RemoteGetErrorDescription_Proxy( 
    IErrorLookup __RPC_FAR * This,
    /* [in] */ HRESULT hrError,
    /* [in] */ DWORD dwLookupID,
    /* [in] */ DISPPARAMS __RPC_FAR *pdispparams,
    /* [in] */ LCID lcid,
    /* [out] */ BSTR __RPC_FAR *pbstrSource,
    /* [out] */ BSTR __RPC_FAR *pbstrDescription,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IErrorLookup_RemoteGetErrorDescription_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IErrorLookup_RemoteGetHelpInfo_Proxy( 
    IErrorLookup __RPC_FAR * This,
    /* [in] */ HRESULT hrError,
    /* [in] */ DWORD dwLookupID,
    /* [in] */ LCID lcid,
    /* [out] */ BSTR __RPC_FAR *pbstrHelpFile,
    /* [out] */ DWORD __RPC_FAR *pdwHelpContext,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IErrorLookup_RemoteGetHelpInfo_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IErrorLookup_RemoteReleaseErrors_Proxy( 
    IErrorLookup __RPC_FAR * This,
    /* [in] */ const DWORD dwDynamicErrorID,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IErrorLookup_RemoteReleaseErrors_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __IErrorLookup_INTERFACE_DEFINED__ */


#ifndef __ISQLErrorInfo_INTERFACE_DEFINED__
#define __ISQLErrorInfo_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: ISQLErrorInfo
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object] */ 



EXTERN_C const IID IID_ISQLErrorInfo;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733a74-2a1c-11ce-ade5-00aa0044773d")
    ISQLErrorInfo : public IUnknown
    {
    public:
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetSQLInfo( 
            /* [out] */ BSTR __RPC_FAR *pbstrSQLState,
            /* [out] */ LONG __RPC_FAR *plNativeError) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct ISQLErrorInfoVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            ISQLErrorInfo __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            ISQLErrorInfo __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            ISQLErrorInfo __RPC_FAR * This);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetSQLInfo )( 
            ISQLErrorInfo __RPC_FAR * This,
            /* [out] */ BSTR __RPC_FAR *pbstrSQLState,
            /* [out] */ LONG __RPC_FAR *plNativeError);
        
        END_INTERFACE
    } ISQLErrorInfoVtbl;

    interface ISQLErrorInfo
    {
        CONST_VTBL struct ISQLErrorInfoVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define ISQLErrorInfo_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define ISQLErrorInfo_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define ISQLErrorInfo_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define ISQLErrorInfo_GetSQLInfo(This,pbstrSQLState,plNativeError)	\
    (This)->lpVtbl -> GetSQLInfo(This,pbstrSQLState,plNativeError)

#endif /* COBJMACROS */


#endif 	/* C style interface */



/* [call_as] */ HRESULT STDMETHODCALLTYPE ISQLErrorInfo_RemoteGetSQLInfo_Proxy( 
    ISQLErrorInfo __RPC_FAR * This,
    /* [out] */ BSTR __RPC_FAR *pbstrSQLState,
    /* [out] */ LONG __RPC_FAR *plNativeError,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB ISQLErrorInfo_RemoteGetSQLInfo_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __ISQLErrorInfo_INTERFACE_DEFINED__ */


#ifndef __IGetDataSource_INTERFACE_DEFINED__
#define __IGetDataSource_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: IGetDataSource
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object] */ 



EXTERN_C const IID IID_IGetDataSource;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733a75-2a1c-11ce-ade5-00aa0044773d")
    IGetDataSource : public IUnknown
    {
    public:
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetDataSource( 
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppDataSource) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct IGetDataSourceVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            IGetDataSource __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            IGetDataSource __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            IGetDataSource __RPC_FAR * This);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetDataSource )( 
            IGetDataSource __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppDataSource);
        
        END_INTERFACE
    } IGetDataSourceVtbl;

    interface IGetDataSource
    {
        CONST_VTBL struct IGetDataSourceVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define IGetDataSource_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define IGetDataSource_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define IGetDataSource_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define IGetDataSource_GetDataSource(This,riid,ppDataSource)	\
    (This)->lpVtbl -> GetDataSource(This,riid,ppDataSource)

#endif /* COBJMACROS */


#endif 	/* C style interface */



/* [call_as] */ HRESULT STDMETHODCALLTYPE IGetDataSource_RemoteGetDataSource_Proxy( 
    IGetDataSource __RPC_FAR * This,
    /* [in] */ REFIID riid,
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppDataSource,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB IGetDataSource_RemoteGetDataSource_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __IGetDataSource_INTERFACE_DEFINED__ */


#ifndef __ITransactionLocal_INTERFACE_DEFINED__
#define __ITransactionLocal_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: ITransactionLocal
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object] */ 



EXTERN_C const IID IID_ITransactionLocal;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733a5f-2a1c-11ce-ade5-00aa0044773d")
    ITransactionLocal : public ITransaction
    {
    public:
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetOptionsObject( 
            /* [out] */ ITransactionOptions __RPC_FAR *__RPC_FAR *ppOptions) = 0;
        
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE StartTransaction( 
            /* [in] */ ISOLEVEL isoLevel,
            /* [in] */ ULONG isoFlags,
            /* [in] */ ITransactionOptions __RPC_FAR *pOtherOptions,
            /* [out] */ ULONG __RPC_FAR *pulTransactionLevel) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct ITransactionLocalVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            ITransactionLocal __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            ITransactionLocal __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            ITransactionLocal __RPC_FAR * This);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Commit )( 
            ITransactionLocal __RPC_FAR * This,
            /* [in] */ BOOL fRetaining,
            /* [in] */ DWORD grfTC,
            /* [in] */ DWORD grfRM);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Abort )( 
            ITransactionLocal __RPC_FAR * This,
            /* [unique][in] */ BOID __RPC_FAR *pboidReason,
            /* [in] */ BOOL fRetaining,
            /* [in] */ BOOL fAsync);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetTransactionInfo )( 
            ITransactionLocal __RPC_FAR * This,
            /* [out] */ XACTTRANSINFO __RPC_FAR *pinfo);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetOptionsObject )( 
            ITransactionLocal __RPC_FAR * This,
            /* [out] */ ITransactionOptions __RPC_FAR *__RPC_FAR *ppOptions);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *StartTransaction )( 
            ITransactionLocal __RPC_FAR * This,
            /* [in] */ ISOLEVEL isoLevel,
            /* [in] */ ULONG isoFlags,
            /* [in] */ ITransactionOptions __RPC_FAR *pOtherOptions,
            /* [out] */ ULONG __RPC_FAR *pulTransactionLevel);
        
        END_INTERFACE
    } ITransactionLocalVtbl;

    interface ITransactionLocal
    {
        CONST_VTBL struct ITransactionLocalVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define ITransactionLocal_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define ITransactionLocal_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define ITransactionLocal_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define ITransactionLocal_Commit(This,fRetaining,grfTC,grfRM)	\
    (This)->lpVtbl -> Commit(This,fRetaining,grfTC,grfRM)

#define ITransactionLocal_Abort(This,pboidReason,fRetaining,fAsync)	\
    (This)->lpVtbl -> Abort(This,pboidReason,fRetaining,fAsync)

#define ITransactionLocal_GetTransactionInfo(This,pinfo)	\
    (This)->lpVtbl -> GetTransactionInfo(This,pinfo)


#define ITransactionLocal_GetOptionsObject(This,ppOptions)	\
    (This)->lpVtbl -> GetOptionsObject(This,ppOptions)

#define ITransactionLocal_StartTransaction(This,isoLevel,isoFlags,pOtherOptions,pulTransactionLevel)	\
    (This)->lpVtbl -> StartTransaction(This,isoLevel,isoFlags,pOtherOptions,pulTransactionLevel)

#endif /* COBJMACROS */


#endif 	/* C style interface */



/* [call_as] */ HRESULT STDMETHODCALLTYPE ITransactionLocal_RemoteGetOptionsObject_Proxy( 
    ITransactionLocal __RPC_FAR * This,
    /* [out] */ ITransactionOptions __RPC_FAR *__RPC_FAR *ppOptions,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB ITransactionLocal_RemoteGetOptionsObject_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


/* [call_as] */ HRESULT STDMETHODCALLTYPE ITransactionLocal_RemoteStartTransaction_Proxy( 
    ITransactionLocal __RPC_FAR * This,
    /* [in] */ ISOLEVEL isoLevel,
    /* [in] */ ULONG isoFlags,
    /* [in] */ ITransactionOptions __RPC_FAR *pOtherOptions,
    /* [unique][out][in] */ ULONG __RPC_FAR *pulTransactionLevel,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB ITransactionLocal_RemoteStartTransaction_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __ITransactionLocal_INTERFACE_DEFINED__ */


#ifndef __ITransactionJoin_INTERFACE_DEFINED__
#define __ITransactionJoin_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: ITransactionJoin
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object] */ 



EXTERN_C const IID IID_ITransactionJoin;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733a5e-2a1c-11ce-ade5-00aa0044773d")
    ITransactionJoin : public IUnknown
    {
    public:
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetOptionsObject( 
            /* [out] */ ITransactionOptions __RPC_FAR *__RPC_FAR *ppOptions) = 0;
        
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE JoinTransaction( 
            /* [in] */ IUnknown __RPC_FAR *punkTransactionCoord,
            /* [in] */ ISOLEVEL isoLevel,
            /* [in] */ ULONG isoFlags,
            /* [in] */ ITransactionOptions __RPC_FAR *pOtherOptions) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct ITransactionJoinVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            ITransactionJoin __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            ITransactionJoin __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            ITransactionJoin __RPC_FAR * This);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetOptionsObject )( 
            ITransactionJoin __RPC_FAR * This,
            /* [out] */ ITransactionOptions __RPC_FAR *__RPC_FAR *ppOptions);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *JoinTransaction )( 
            ITransactionJoin __RPC_FAR * This,
            /* [in] */ IUnknown __RPC_FAR *punkTransactionCoord,
            /* [in] */ ISOLEVEL isoLevel,
            /* [in] */ ULONG isoFlags,
            /* [in] */ ITransactionOptions __RPC_FAR *pOtherOptions);
        
        END_INTERFACE
    } ITransactionJoinVtbl;

    interface ITransactionJoin
    {
        CONST_VTBL struct ITransactionJoinVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define ITransactionJoin_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define ITransactionJoin_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define ITransactionJoin_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define ITransactionJoin_GetOptionsObject(This,ppOptions)	\
    (This)->lpVtbl -> GetOptionsObject(This,ppOptions)

#define ITransactionJoin_JoinTransaction(This,punkTransactionCoord,isoLevel,isoFlags,pOtherOptions)	\
    (This)->lpVtbl -> JoinTransaction(This,punkTransactionCoord,isoLevel,isoFlags,pOtherOptions)

#endif /* COBJMACROS */


#endif 	/* C style interface */



/* [call_as] */ HRESULT STDMETHODCALLTYPE ITransactionJoin_RemoteGetOptionsObject_Proxy( 
    ITransactionJoin __RPC_FAR * This,
    /* [out] */ ITransactionOptions __RPC_FAR *__RPC_FAR *ppOptions,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB ITransactionJoin_RemoteGetOptionsObject_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


/* [call_as] */ HRESULT STDMETHODCALLTYPE ITransactionJoin_RemoteJoinTransaction_Proxy( 
    ITransactionJoin __RPC_FAR * This,
    /* [in] */ IUnknown __RPC_FAR *punkTransactionCoord,
    /* [in] */ ISOLEVEL isoLevel,
    /* [in] */ ULONG isoFlags,
    /* [in] */ ITransactionOptions __RPC_FAR *pOtherOptions,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB ITransactionJoin_RemoteJoinTransaction_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __ITransactionJoin_INTERFACE_DEFINED__ */


#ifndef __ITransactionObject_INTERFACE_DEFINED__
#define __ITransactionObject_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: ITransactionObject
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object] */ 



EXTERN_C const IID IID_ITransactionObject;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733a60-2a1c-11ce-ade5-00aa0044773d")
    ITransactionObject : public IUnknown
    {
    public:
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetTransactionObject( 
            /* [in] */ ULONG ulTransactionLevel,
            /* [out] */ ITransaction __RPC_FAR *__RPC_FAR *ppTransactionObject) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct ITransactionObjectVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            ITransactionObject __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            ITransactionObject __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            ITransactionObject __RPC_FAR * This);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetTransactionObject )( 
            ITransactionObject __RPC_FAR * This,
            /* [in] */ ULONG ulTransactionLevel,
            /* [out] */ ITransaction __RPC_FAR *__RPC_FAR *ppTransactionObject);
        
        END_INTERFACE
    } ITransactionObjectVtbl;

    interface ITransactionObject
    {
        CONST_VTBL struct ITransactionObjectVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define ITransactionObject_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define ITransactionObject_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define ITransactionObject_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define ITransactionObject_GetTransactionObject(This,ulTransactionLevel,ppTransactionObject)	\
    (This)->lpVtbl -> GetTransactionObject(This,ulTransactionLevel,ppTransactionObject)

#endif /* COBJMACROS */


#endif 	/* C style interface */



/* [call_as] */ HRESULT STDMETHODCALLTYPE ITransactionObject_RemoteGetTransactionObject_Proxy( 
    ITransactionObject __RPC_FAR * This,
    /* [in] */ ULONG ulTransactionLevel,
    /* [out] */ ITransaction __RPC_FAR *__RPC_FAR *ppTransactionObject,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);


void __RPC_STUB ITransactionObject_RemoteGetTransactionObject_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __ITransactionObject_INTERFACE_DEFINED__ */


/****************************************
 * Generated header for interface: __MIDL_itf_oledb_0223
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [local] */ 


#ifndef UNDER_CE
#if 0  // to get around a MIDL limitation
typedef 
enum _TRUSTEE_TYPE
    {	TRUSTEE_IS_UNKNOWN	= 0,
	TRUSTEE_IS_USER	= TRUSTEE_IS_UNKNOWN + 1,
	TRUSTEE_IS_GROUP	= TRUSTEE_IS_USER + 1
    }	TRUSTEE_TYPE;

typedef 
enum _TRUSTEE_FORM
    {	TRUSTEE_IS_SID	= 0,
	TRUSTEE_IS_NAME	= TRUSTEE_IS_SID + 1
    }	TRUSTEE_FORM;

typedef 
enum _MULTIPLE_TRUSTEE_OPERATION
    {	NO_MULTIPLE_TRUSTEE	= 0,
	TRUSTEE_IS_IMPERSONATE	= NO_MULTIPLE_TRUSTEE + 1
    }	MULTIPLE_TRUSTEE_OPERATION;

typedef struct _TRUSTEE_A __RPC_FAR *PTRUSTEE_A;

typedef struct _TRUSTEE_W __RPC_FAR *PTRUSTEE_W;

typedef struct  _TRUSTEE_W
    {
    PTRUSTEE_W pMultipleTrustee;
    MULTIPLE_TRUSTEE_OPERATION MultipleTrusteeOperation;
    TRUSTEE_FORM TrusteeForm;
    TRUSTEE_TYPE TrusteeType;
    LPWSTR ptstrName;
    }	TRUSTEE_W;

typedef struct  _TRUSTEE_A
    {
    PTRUSTEE_A pMultipleTrustee;
    MULTIPLE_TRUSTEE_OPERATION MultipleTrusteeOperation;
    TRUSTEE_FORM TrusteeForm;
    TRUSTEE_TYPE TrusteeType;
    LPSTR ptstrName;
    }	TRUSTEE_A;

typedef 
enum _ACCESS_MODE
    {	NOT_USED_ACCESS	= 0,
	GRANT_ACCESS	= NOT_USED_ACCESS + 1,
	SET_ACCESS	= GRANT_ACCESS + 1,
	DENY_ACCESS	= SET_ACCESS + 1,
	REVOKE_ACCESS	= DENY_ACCESS + 1,
	SET_AUDIT_SUCCESS	= REVOKE_ACCESS + 1,
	SET_AUDIT_FAILURE	= SET_AUDIT_SUCCESS + 1
    }	ACCESS_MODE;

typedef 
enum _SE_OBJECT_TYPE
    {	SE_UNKNOWN_OBJECT_TYPE	= 0,
	SE_FILE_OBJECT	= SE_UNKNOWN_OBJECT_TYPE + 1,
	SE_SERVICE	= SE_FILE_OBJECT + 1,
	SE_PRINTER	= SE_SERVICE + 1,
	SE_REGISTRY_KEY	= SE_PRINTER + 1,
	SE_LMSHARE	= SE_REGISTRY_KEY + 1,
	SE_KERNEL_OBJECT	= SE_LMSHARE + 1,
	SE_WINDOW_OBJECT	= SE_KERNEL_OBJECT + 1
    }	SE_OBJECT_TYPE;

typedef struct  _EXPLICIT_ACCESS_W
    {
    DWORD grfAccessPermissions;
    ACCESS_MODE grfAccessMode;
    DWORD grfInheritance;
    TRUSTEE_W Trustee;
    }	EXPLICIT_ACCESS_W;

typedef struct _EXPLICIT_ACCESS_W __RPC_FAR *PEXPLICIT_ACCESS_W;

typedef struct  _EXPLICIT_ACCESS_A
    {
    DWORD grfAccessPermissions;
    ACCESS_MODE grfAccessMode;
    DWORD grfInheritance;
    TRUSTEE_A Trustee;
    }	EXPLICIT_ACCESS_A;

typedef struct _EXPLICIT_ACCESS_A __RPC_FAR *PEXPLICIT_ACCESS_A;

#else
#include <accctrl.h>
#endif


extern RPC_IF_HANDLE __MIDL_itf_oledb_0223_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_oledb_0223_v0_0_s_ifspec;

#ifndef __ITrusteeAdmin_INTERFACE_DEFINED__
#define __ITrusteeAdmin_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: ITrusteeAdmin
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object][local] */ 



EXTERN_C const IID IID_ITrusteeAdmin;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733aa1-2a1c-11ce-ade5-00aa0044773d")
    ITrusteeAdmin : public IUnknown
    {
    public:
        virtual HRESULT STDMETHODCALLTYPE CompareTrustees( 
            /* [in] */ TRUSTEE_W __RPC_FAR *pTrustee1,
            /* [in] */ TRUSTEE_W __RPC_FAR *pTrustee2) = 0;
        
        virtual HRESULT STDMETHODCALLTYPE CreateTrustee( 
            /* [in] */ TRUSTEE_W __RPC_FAR *pTrustee,
            /* [in] */ ULONG cPropertySets,
            /* [size_is][out][in] */ DBPROPSET __RPC_FAR rgPropertySets[  ]) = 0;
        
        virtual HRESULT STDMETHODCALLTYPE DeleteTrustee( 
            /* [in] */ TRUSTEE_W __RPC_FAR *pTrustee) = 0;
        
        virtual HRESULT STDMETHODCALLTYPE SetTrusteeProperties( 
            /* [in] */ TRUSTEE_W __RPC_FAR *pTrustee,
            /* [in] */ ULONG cPropertySets,
            /* [size_is][out][in] */ DBPROPSET __RPC_FAR rgPropertySets[  ]) = 0;
        
        virtual HRESULT STDMETHODCALLTYPE GetTrusteeProperties( 
            /* [in] */ TRUSTEE_W __RPC_FAR *pTrustee,
            /* [in] */ const ULONG cPropertyIDSets,
            /* [size_is][in] */ const DBPROPIDSET __RPC_FAR rgPropertyIDSets[  ],
            /* [out][in] */ ULONG __RPC_FAR *pcPropertySets,
            /* [size_is][size_is][out] */ DBPROPSET __RPC_FAR *__RPC_FAR *prgPropertySets) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct ITrusteeAdminVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            ITrusteeAdmin __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            ITrusteeAdmin __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            ITrusteeAdmin __RPC_FAR * This);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *CompareTrustees )( 
            ITrusteeAdmin __RPC_FAR * This,
            /* [in] */ TRUSTEE_W __RPC_FAR *pTrustee1,
            /* [in] */ TRUSTEE_W __RPC_FAR *pTrustee2);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *CreateTrustee )( 
            ITrusteeAdmin __RPC_FAR * This,
            /* [in] */ TRUSTEE_W __RPC_FAR *pTrustee,
            /* [in] */ ULONG cPropertySets,
            /* [size_is][out][in] */ DBPROPSET __RPC_FAR rgPropertySets[  ]);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *DeleteTrustee )( 
            ITrusteeAdmin __RPC_FAR * This,
            /* [in] */ TRUSTEE_W __RPC_FAR *pTrustee);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *SetTrusteeProperties )( 
            ITrusteeAdmin __RPC_FAR * This,
            /* [in] */ TRUSTEE_W __RPC_FAR *pTrustee,
            /* [in] */ ULONG cPropertySets,
            /* [size_is][out][in] */ DBPROPSET __RPC_FAR rgPropertySets[  ]);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetTrusteeProperties )( 
            ITrusteeAdmin __RPC_FAR * This,
            /* [in] */ TRUSTEE_W __RPC_FAR *pTrustee,
            /* [in] */ const ULONG cPropertyIDSets,
            /* [size_is][in] */ const DBPROPIDSET __RPC_FAR rgPropertyIDSets[  ],
            /* [out][in] */ ULONG __RPC_FAR *pcPropertySets,
            /* [size_is][size_is][out] */ DBPROPSET __RPC_FAR *__RPC_FAR *prgPropertySets);
        
        END_INTERFACE
    } ITrusteeAdminVtbl;

    interface ITrusteeAdmin
    {
        CONST_VTBL struct ITrusteeAdminVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define ITrusteeAdmin_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define ITrusteeAdmin_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define ITrusteeAdmin_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define ITrusteeAdmin_CompareTrustees(This,pTrustee1,pTrustee2)	\
    (This)->lpVtbl -> CompareTrustees(This,pTrustee1,pTrustee2)

#define ITrusteeAdmin_CreateTrustee(This,pTrustee,cPropertySets,rgPropertySets)	\
    (This)->lpVtbl -> CreateTrustee(This,pTrustee,cPropertySets,rgPropertySets)

#define ITrusteeAdmin_DeleteTrustee(This,pTrustee)	\
    (This)->lpVtbl -> DeleteTrustee(This,pTrustee)

#define ITrusteeAdmin_SetTrusteeProperties(This,pTrustee,cPropertySets,rgPropertySets)	\
    (This)->lpVtbl -> SetTrusteeProperties(This,pTrustee,cPropertySets,rgPropertySets)

#define ITrusteeAdmin_GetTrusteeProperties(This,pTrustee,cPropertyIDSets,rgPropertyIDSets,pcPropertySets,prgPropertySets)	\
    (This)->lpVtbl -> GetTrusteeProperties(This,pTrustee,cPropertyIDSets,rgPropertyIDSets,pcPropertySets,prgPropertySets)

#endif /* COBJMACROS */


#endif 	/* C style interface */



HRESULT STDMETHODCALLTYPE ITrusteeAdmin_CompareTrustees_Proxy( 
    ITrusteeAdmin __RPC_FAR * This,
    /* [in] */ TRUSTEE_W __RPC_FAR *pTrustee1,
    /* [in] */ TRUSTEE_W __RPC_FAR *pTrustee2);


void __RPC_STUB ITrusteeAdmin_CompareTrustees_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


HRESULT STDMETHODCALLTYPE ITrusteeAdmin_CreateTrustee_Proxy( 
    ITrusteeAdmin __RPC_FAR * This,
    /* [in] */ TRUSTEE_W __RPC_FAR *pTrustee,
    /* [in] */ ULONG cPropertySets,
    /* [size_is][out][in] */ DBPROPSET __RPC_FAR rgPropertySets[  ]);


void __RPC_STUB ITrusteeAdmin_CreateTrustee_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


HRESULT STDMETHODCALLTYPE ITrusteeAdmin_DeleteTrustee_Proxy( 
    ITrusteeAdmin __RPC_FAR * This,
    /* [in] */ TRUSTEE_W __RPC_FAR *pTrustee);


void __RPC_STUB ITrusteeAdmin_DeleteTrustee_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


HRESULT STDMETHODCALLTYPE ITrusteeAdmin_SetTrusteeProperties_Proxy( 
    ITrusteeAdmin __RPC_FAR * This,
    /* [in] */ TRUSTEE_W __RPC_FAR *pTrustee,
    /* [in] */ ULONG cPropertySets,
    /* [size_is][out][in] */ DBPROPSET __RPC_FAR rgPropertySets[  ]);


void __RPC_STUB ITrusteeAdmin_SetTrusteeProperties_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


HRESULT STDMETHODCALLTYPE ITrusteeAdmin_GetTrusteeProperties_Proxy( 
    ITrusteeAdmin __RPC_FAR * This,
    /* [in] */ TRUSTEE_W __RPC_FAR *pTrustee,
    /* [in] */ const ULONG cPropertyIDSets,
    /* [size_is][in] */ const DBPROPIDSET __RPC_FAR rgPropertyIDSets[  ],
    /* [out][in] */ ULONG __RPC_FAR *pcPropertySets,
    /* [size_is][size_is][out] */ DBPROPSET __RPC_FAR *__RPC_FAR *prgPropertySets);


void __RPC_STUB ITrusteeAdmin_GetTrusteeProperties_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __ITrusteeAdmin_INTERFACE_DEFINED__ */


#ifndef __ITrusteeGroupAdmin_INTERFACE_DEFINED__
#define __ITrusteeGroupAdmin_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: ITrusteeGroupAdmin
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object][local] */ 



EXTERN_C const IID IID_ITrusteeGroupAdmin;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733aa2-2a1c-11ce-ade5-00aa0044773d")
    ITrusteeGroupAdmin : public IUnknown
    {
    public:
        virtual HRESULT STDMETHODCALLTYPE AddMember( 
            /* [in] */ TRUSTEE_W __RPC_FAR *pMembershipTrustee,
            /* [in] */ TRUSTEE_W __RPC_FAR *pMemberTrustee) = 0;
        
        virtual HRESULT STDMETHODCALLTYPE DeleteMember( 
            /* [in] */ TRUSTEE_W __RPC_FAR *pMembershipTrustee,
            /* [in] */ TRUSTEE_W __RPC_FAR *pMemberTrustee) = 0;
        
        virtual HRESULT STDMETHODCALLTYPE IsMember( 
            /* [in] */ TRUSTEE_W __RPC_FAR *pMembershipTrustee,
            /* [in] */ TRUSTEE_W __RPC_FAR *pMemberTrustee,
            /* [out] */ BOOL __RPC_FAR *pfStatus) = 0;
        
        virtual HRESULT STDMETHODCALLTYPE GetMembers( 
            /* [in] */ TRUSTEE_W __RPC_FAR *pMembershipTrustee,
            /* [out] */ ULONG __RPC_FAR *pcMembers,
            /* [out] */ TRUSTEE_W __RPC_FAR *__RPC_FAR *prgMembers) = 0;
        
        virtual HRESULT STDMETHODCALLTYPE GetMemberships( 
            /* [in] */ TRUSTEE_W __RPC_FAR *pTrustee,
            /* [out] */ ULONG __RPC_FAR *pcMemberships,
            /* [out] */ TRUSTEE_W __RPC_FAR *__RPC_FAR *prgMemberships) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct ITrusteeGroupAdminVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            ITrusteeGroupAdmin __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            ITrusteeGroupAdmin __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            ITrusteeGroupAdmin __RPC_FAR * This);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *AddMember )( 
            ITrusteeGroupAdmin __RPC_FAR * This,
            /* [in] */ TRUSTEE_W __RPC_FAR *pMembershipTrustee,
            /* [in] */ TRUSTEE_W __RPC_FAR *pMemberTrustee);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *DeleteMember )( 
            ITrusteeGroupAdmin __RPC_FAR * This,
            /* [in] */ TRUSTEE_W __RPC_FAR *pMembershipTrustee,
            /* [in] */ TRUSTEE_W __RPC_FAR *pMemberTrustee);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *IsMember )( 
            ITrusteeGroupAdmin __RPC_FAR * This,
            /* [in] */ TRUSTEE_W __RPC_FAR *pMembershipTrustee,
            /* [in] */ TRUSTEE_W __RPC_FAR *pMemberTrustee,
            /* [out] */ BOOL __RPC_FAR *pfStatus);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetMembers )( 
            ITrusteeGroupAdmin __RPC_FAR * This,
            /* [in] */ TRUSTEE_W __RPC_FAR *pMembershipTrustee,
            /* [out] */ ULONG __RPC_FAR *pcMembers,
            /* [out] */ TRUSTEE_W __RPC_FAR *__RPC_FAR *prgMembers);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetMemberships )( 
            ITrusteeGroupAdmin __RPC_FAR * This,
            /* [in] */ TRUSTEE_W __RPC_FAR *pTrustee,
            /* [out] */ ULONG __RPC_FAR *pcMemberships,
            /* [out] */ TRUSTEE_W __RPC_FAR *__RPC_FAR *prgMemberships);
        
        END_INTERFACE
    } ITrusteeGroupAdminVtbl;

    interface ITrusteeGroupAdmin
    {
        CONST_VTBL struct ITrusteeGroupAdminVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define ITrusteeGroupAdmin_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define ITrusteeGroupAdmin_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define ITrusteeGroupAdmin_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define ITrusteeGroupAdmin_AddMember(This,pMembershipTrustee,pMemberTrustee)	\
    (This)->lpVtbl -> AddMember(This,pMembershipTrustee,pMemberTrustee)

#define ITrusteeGroupAdmin_DeleteMember(This,pMembershipTrustee,pMemberTrustee)	\
    (This)->lpVtbl -> DeleteMember(This,pMembershipTrustee,pMemberTrustee)

#define ITrusteeGroupAdmin_IsMember(This,pMembershipTrustee,pMemberTrustee,pfStatus)	\
    (This)->lpVtbl -> IsMember(This,pMembershipTrustee,pMemberTrustee,pfStatus)

#define ITrusteeGroupAdmin_GetMembers(This,pMembershipTrustee,pcMembers,prgMembers)	\
    (This)->lpVtbl -> GetMembers(This,pMembershipTrustee,pcMembers,prgMembers)

#define ITrusteeGroupAdmin_GetMemberships(This,pTrustee,pcMemberships,prgMemberships)	\
    (This)->lpVtbl -> GetMemberships(This,pTrustee,pcMemberships,prgMemberships)

#endif /* COBJMACROS */


#endif 	/* C style interface */



HRESULT STDMETHODCALLTYPE ITrusteeGroupAdmin_AddMember_Proxy( 
    ITrusteeGroupAdmin __RPC_FAR * This,
    /* [in] */ TRUSTEE_W __RPC_FAR *pMembershipTrustee,
    /* [in] */ TRUSTEE_W __RPC_FAR *pMemberTrustee);


void __RPC_STUB ITrusteeGroupAdmin_AddMember_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


HRESULT STDMETHODCALLTYPE ITrusteeGroupAdmin_DeleteMember_Proxy( 
    ITrusteeGroupAdmin __RPC_FAR * This,
    /* [in] */ TRUSTEE_W __RPC_FAR *pMembershipTrustee,
    /* [in] */ TRUSTEE_W __RPC_FAR *pMemberTrustee);


void __RPC_STUB ITrusteeGroupAdmin_DeleteMember_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


HRESULT STDMETHODCALLTYPE ITrusteeGroupAdmin_IsMember_Proxy( 
    ITrusteeGroupAdmin __RPC_FAR * This,
    /* [in] */ TRUSTEE_W __RPC_FAR *pMembershipTrustee,
    /* [in] */ TRUSTEE_W __RPC_FAR *pMemberTrustee,
    /* [out] */ BOOL __RPC_FAR *pfStatus);


void __RPC_STUB ITrusteeGroupAdmin_IsMember_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


HRESULT STDMETHODCALLTYPE ITrusteeGroupAdmin_GetMembers_Proxy( 
    ITrusteeGroupAdmin __RPC_FAR * This,
    /* [in] */ TRUSTEE_W __RPC_FAR *pMembershipTrustee,
    /* [out] */ ULONG __RPC_FAR *pcMembers,
    /* [out] */ TRUSTEE_W __RPC_FAR *__RPC_FAR *prgMembers);


void __RPC_STUB ITrusteeGroupAdmin_GetMembers_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


HRESULT STDMETHODCALLTYPE ITrusteeGroupAdmin_GetMemberships_Proxy( 
    ITrusteeGroupAdmin __RPC_FAR * This,
    /* [in] */ TRUSTEE_W __RPC_FAR *pTrustee,
    /* [out] */ ULONG __RPC_FAR *pcMemberships,
    /* [out] */ TRUSTEE_W __RPC_FAR *__RPC_FAR *prgMemberships);


void __RPC_STUB ITrusteeGroupAdmin_GetMemberships_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __ITrusteeGroupAdmin_INTERFACE_DEFINED__ */


#ifndef __IObjectAccessControl_INTERFACE_DEFINED__
#define __IObjectAccessControl_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: IObjectAccessControl
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object][local] */ 



EXTERN_C const IID IID_IObjectAccessControl;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733aa3-2a1c-11ce-ade5-00aa0044773d")
    IObjectAccessControl : public IUnknown
    {
    public:
        virtual HRESULT STDMETHODCALLTYPE GetObjectAccessRights( 
            /* [in] */ SEC_OBJECT __RPC_FAR *pObject,
            /* [out][in] */ ULONG __RPC_FAR *pcAccessEntries,
            /* [out][in] */ EXPLICIT_ACCESS_W __RPC_FAR *__RPC_FAR *prgAccessEntries) = 0;
        
        virtual HRESULT STDMETHODCALLTYPE GetObjectOwner( 
            /* [in] */ SEC_OBJECT __RPC_FAR *pObject,
            /* [out] */ TRUSTEE_W __RPC_FAR *__RPC_FAR *ppOwner) = 0;
        
        virtual HRESULT STDMETHODCALLTYPE IsObjectAccessAllowed( 
            /* [in] */ SEC_OBJECT __RPC_FAR *pObject,
            /* [in] */ EXPLICIT_ACCESS_W __RPC_FAR *pAccessEntry,
            /* [out] */ BOOL __RPC_FAR *pfResult) = 0;
        
        virtual HRESULT STDMETHODCALLTYPE SetObjectAccessRights( 
            /* [in] */ SEC_OBJECT __RPC_FAR *pObject,
            /* [in] */ ULONG cAccessEntries,
            /* [out][in] */ EXPLICIT_ACCESS_W __RPC_FAR *prgAccessEntries) = 0;
        
        virtual HRESULT STDMETHODCALLTYPE SetObjectOwner( 
            /* [in] */ SEC_OBJECT __RPC_FAR *pObject,
            /* [in] */ TRUSTEE_W __RPC_FAR *pOwner) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct IObjectAccessControlVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            IObjectAccessControl __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            IObjectAccessControl __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            IObjectAccessControl __RPC_FAR * This);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetObjectAccessRights )( 
            IObjectAccessControl __RPC_FAR * This,
            /* [in] */ SEC_OBJECT __RPC_FAR *pObject,
            /* [out][in] */ ULONG __RPC_FAR *pcAccessEntries,
            /* [out][in] */ EXPLICIT_ACCESS_W __RPC_FAR *__RPC_FAR *prgAccessEntries);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetObjectOwner )( 
            IObjectAccessControl __RPC_FAR * This,
            /* [in] */ SEC_OBJECT __RPC_FAR *pObject,
            /* [out] */ TRUSTEE_W __RPC_FAR *__RPC_FAR *ppOwner);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *IsObjectAccessAllowed )( 
            IObjectAccessControl __RPC_FAR * This,
            /* [in] */ SEC_OBJECT __RPC_FAR *pObject,
            /* [in] */ EXPLICIT_ACCESS_W __RPC_FAR *pAccessEntry,
            /* [out] */ BOOL __RPC_FAR *pfResult);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *SetObjectAccessRights )( 
            IObjectAccessControl __RPC_FAR * This,
            /* [in] */ SEC_OBJECT __RPC_FAR *pObject,
            /* [in] */ ULONG cAccessEntries,
            /* [out][in] */ EXPLICIT_ACCESS_W __RPC_FAR *prgAccessEntries);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *SetObjectOwner )( 
            IObjectAccessControl __RPC_FAR * This,
            /* [in] */ SEC_OBJECT __RPC_FAR *pObject,
            /* [in] */ TRUSTEE_W __RPC_FAR *pOwner);
        
        END_INTERFACE
    } IObjectAccessControlVtbl;

    interface IObjectAccessControl
    {
        CONST_VTBL struct IObjectAccessControlVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define IObjectAccessControl_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define IObjectAccessControl_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define IObjectAccessControl_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define IObjectAccessControl_GetObjectAccessRights(This,pObject,pcAccessEntries,prgAccessEntries)	\
    (This)->lpVtbl -> GetObjectAccessRights(This,pObject,pcAccessEntries,prgAccessEntries)

#define IObjectAccessControl_GetObjectOwner(This,pObject,ppOwner)	\
    (This)->lpVtbl -> GetObjectOwner(This,pObject,ppOwner)

#define IObjectAccessControl_IsObjectAccessAllowed(This,pObject,pAccessEntry,pfResult)	\
    (This)->lpVtbl -> IsObjectAccessAllowed(This,pObject,pAccessEntry,pfResult)

#define IObjectAccessControl_SetObjectAccessRights(This,pObject,cAccessEntries,prgAccessEntries)	\
    (This)->lpVtbl -> SetObjectAccessRights(This,pObject,cAccessEntries,prgAccessEntries)

#define IObjectAccessControl_SetObjectOwner(This,pObject,pOwner)	\
    (This)->lpVtbl -> SetObjectOwner(This,pObject,pOwner)

#endif /* COBJMACROS */


#endif 	/* C style interface */



HRESULT STDMETHODCALLTYPE IObjectAccessControl_GetObjectAccessRights_Proxy( 
    IObjectAccessControl __RPC_FAR * This,
    /* [in] */ SEC_OBJECT __RPC_FAR *pObject,
    /* [out][in] */ ULONG __RPC_FAR *pcAccessEntries,
    /* [out][in] */ EXPLICIT_ACCESS_W __RPC_FAR *__RPC_FAR *prgAccessEntries);


void __RPC_STUB IObjectAccessControl_GetObjectAccessRights_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


HRESULT STDMETHODCALLTYPE IObjectAccessControl_GetObjectOwner_Proxy( 
    IObjectAccessControl __RPC_FAR * This,
    /* [in] */ SEC_OBJECT __RPC_FAR *pObject,
    /* [out] */ TRUSTEE_W __RPC_FAR *__RPC_FAR *ppOwner);


void __RPC_STUB IObjectAccessControl_GetObjectOwner_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


HRESULT STDMETHODCALLTYPE IObjectAccessControl_IsObjectAccessAllowed_Proxy( 
    IObjectAccessControl __RPC_FAR * This,
    /* [in] */ SEC_OBJECT __RPC_FAR *pObject,
    /* [in] */ EXPLICIT_ACCESS_W __RPC_FAR *pAccessEntry,
    /* [out] */ BOOL __RPC_FAR *pfResult);


void __RPC_STUB IObjectAccessControl_IsObjectAccessAllowed_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


HRESULT STDMETHODCALLTYPE IObjectAccessControl_SetObjectAccessRights_Proxy( 
    IObjectAccessControl __RPC_FAR * This,
    /* [in] */ SEC_OBJECT __RPC_FAR *pObject,
    /* [in] */ ULONG cAccessEntries,
    /* [out][in] */ EXPLICIT_ACCESS_W __RPC_FAR *prgAccessEntries);


void __RPC_STUB IObjectAccessControl_SetObjectAccessRights_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


HRESULT STDMETHODCALLTYPE IObjectAccessControl_SetObjectOwner_Proxy( 
    IObjectAccessControl __RPC_FAR * This,
    /* [in] */ SEC_OBJECT __RPC_FAR *pObject,
    /* [in] */ TRUSTEE_W __RPC_FAR *pOwner);


void __RPC_STUB IObjectAccessControl_SetObjectOwner_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __IObjectAccessControl_INTERFACE_DEFINED__ */


#ifndef __ISecurityInfo_INTERFACE_DEFINED__
#define __ISecurityInfo_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: ISecurityInfo
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object][local] */ 


typedef DWORD ACCESS_MASK;


enum ACCESS_MASKENUM
    {	PERM_EXCLUSIVE	= 0x200L,
	PERM_READDESIGN	= 0x400L,
	PERM_WRITEDESIGN	= 0x800L,
	PERM_WITHGRANT	= 0x1000L,
	PERM_REFERENCE	= 0x2000L,
	PERM_CREATE	= 0x4000L,
	PERM_INSERT	= 0x8000L,
	PERM_DELETE	= 0x10000L,
	PERM_READCONTROL	= 0x20000L,
	PERM_WRITEPERMISSIONS	= 0x40000L,
	PERM_WRITEOWNER	= 0x80000L,
	PERM_MAXIMUM_ALLOWED	= 0x2000000L,
	PERM_ALL	= 0x10000000L,
	PERM_EXECUTE	= 0x20000000L,
	PERM_READ	= 0x80000000L,
	PERM_UPDATE	= 0x40000000L,
	PERM_DROP	= 0x100L
    };
#define PERM_DESIGN 							PERM_WRITEDESIGN

EXTERN_C const IID IID_ISecurityInfo;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733aa4-2a1c-11ce-ade5-00aa0044773d")
    ISecurityInfo : public IUnknown
    {
    public:
        virtual HRESULT STDMETHODCALLTYPE GetCurrentTrustee( 
            /* [out] */ TRUSTEE_W __RPC_FAR *__RPC_FAR *ppTrustee) = 0;
        
        virtual HRESULT STDMETHODCALLTYPE GetObjectTypes( 
            /* [out] */ ULONG __RPC_FAR *cObjectTypes,
            /* [out] */ GUID __RPC_FAR *__RPC_FAR *rgObjectTypes) = 0;
        
        virtual HRESULT STDMETHODCALLTYPE GetPermissions( 
            /* [in] */ GUID ObjectType,
            /* [out] */ ACCESS_MASK __RPC_FAR *pPermissions) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct ISecurityInfoVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            ISecurityInfo __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            ISecurityInfo __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            ISecurityInfo __RPC_FAR * This);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetCurrentTrustee )( 
            ISecurityInfo __RPC_FAR * This,
            /* [out] */ TRUSTEE_W __RPC_FAR *__RPC_FAR *ppTrustee);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetObjectTypes )( 
            ISecurityInfo __RPC_FAR * This,
            /* [out] */ ULONG __RPC_FAR *cObjectTypes,
            /* [out] */ GUID __RPC_FAR *__RPC_FAR *rgObjectTypes);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetPermissions )( 
            ISecurityInfo __RPC_FAR * This,
            /* [in] */ GUID ObjectType,
            /* [out] */ ACCESS_MASK __RPC_FAR *pPermissions);
        
        END_INTERFACE
    } ISecurityInfoVtbl;

    interface ISecurityInfo
    {
        CONST_VTBL struct ISecurityInfoVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define ISecurityInfo_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define ISecurityInfo_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define ISecurityInfo_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define ISecurityInfo_GetCurrentTrustee(This,ppTrustee)	\
    (This)->lpVtbl -> GetCurrentTrustee(This,ppTrustee)

#define ISecurityInfo_GetObjectTypes(This,cObjectTypes,rgObjectTypes)	\
    (This)->lpVtbl -> GetObjectTypes(This,cObjectTypes,rgObjectTypes)

#define ISecurityInfo_GetPermissions(This,ObjectType,pPermissions)	\
    (This)->lpVtbl -> GetPermissions(This,ObjectType,pPermissions)

#endif /* COBJMACROS */


#endif 	/* C style interface */



HRESULT STDMETHODCALLTYPE ISecurityInfo_GetCurrentTrustee_Proxy( 
    ISecurityInfo __RPC_FAR * This,
    /* [out] */ TRUSTEE_W __RPC_FAR *__RPC_FAR *ppTrustee);


void __RPC_STUB ISecurityInfo_GetCurrentTrustee_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


HRESULT STDMETHODCALLTYPE ISecurityInfo_GetObjectTypes_Proxy( 
    ISecurityInfo __RPC_FAR * This,
    /* [out] */ ULONG __RPC_FAR *cObjectTypes,
    /* [out] */ GUID __RPC_FAR *__RPC_FAR *rgObjectTypes);


void __RPC_STUB ISecurityInfo_GetObjectTypes_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


HRESULT STDMETHODCALLTYPE ISecurityInfo_GetPermissions_Proxy( 
    ISecurityInfo __RPC_FAR * This,
    /* [in] */ GUID ObjectType,
    /* [out] */ ACCESS_MASK __RPC_FAR *pPermissions);


void __RPC_STUB ISecurityInfo_GetPermissions_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __ISecurityInfo_INTERFACE_DEFINED__ */
#endif // (UNDER_CE)

#ifndef __ITableCreation_INTERFACE_DEFINED__
#define __ITableCreation_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: ITableCreation
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object][local] */ 



EXTERN_C const IID IID_ITableCreation;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733abc-2a1c-11ce-ade5-00aa0044773d")
    ITableCreation : public ITableDefinition
    {
    public:
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetTableDefinition( 
            /* [in] */ DBID __RPC_FAR *pTableID,
            /* [out] */ ULONG __RPC_FAR *pcColumnDescs,
            /* [size_is][size_is][out] */ DBCOLUMNDESC __RPC_FAR *__RPC_FAR prgColumnDescs[  ],
            /* [out] */ ULONG __RPC_FAR *pcPropertySets,
            /* [size_is][size_is][out] */ DBPROPSET __RPC_FAR *__RPC_FAR prgPropertySets[  ],
            /* [out] */ ULONG __RPC_FAR *pcConstraintDescs,
            /* [size_is][size_is][out] */ DBCONSTRAINTDESC __RPC_FAR *__RPC_FAR prgConstraintDescs[  ],
            /* [out] */ OLECHAR __RPC_FAR *__RPC_FAR *ppwszStringBuffer) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct ITableCreationVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            ITableCreation __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            ITableCreation __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            ITableCreation __RPC_FAR * This);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *CreateTable )( 
            ITableCreation __RPC_FAR * This,
            /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
            /* [in] */ DBID __RPC_FAR *pTableID,
            /* [in] */ ULONG cColumnDescs,
            /* [size_is][in] */ const DBCOLUMNDESC __RPC_FAR rgColumnDescs[  ],
            /* [in] */ REFIID riid,
            /* [in] */ ULONG cPropertySets,
            /* [size_is][out][in] */ DBPROPSET __RPC_FAR rgPropertySets[  ],
            /* [out] */ DBID __RPC_FAR *__RPC_FAR *ppTableID,
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *DropTable )( 
            ITableCreation __RPC_FAR * This,
            /* [unique][in] */ DBID __RPC_FAR *pTableID);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *AddColumn )( 
            ITableCreation __RPC_FAR * This,
            /* [in] */ DBID __RPC_FAR *pTableID,
            /* [out][in] */ DBCOLUMNDESC __RPC_FAR *pColumnDesc,
            /* [out] */ DBID __RPC_FAR *__RPC_FAR *ppColumnID);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *DropColumn )( 
            ITableCreation __RPC_FAR * This,
            /* [unique][in] */ DBID __RPC_FAR *pTableID,
            /* [unique][in] */ DBID __RPC_FAR *pColumnID);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetTableDefinition )( 
            ITableCreation __RPC_FAR * This,
            /* [in] */ DBID __RPC_FAR *pTableID,
            /* [out] */ ULONG __RPC_FAR *pcColumnDescs,
            /* [size_is][size_is][out] */ DBCOLUMNDESC __RPC_FAR *__RPC_FAR prgColumnDescs[  ],
            /* [out] */ ULONG __RPC_FAR *pcPropertySets,
            /* [size_is][size_is][out] */ DBPROPSET __RPC_FAR *__RPC_FAR prgPropertySets[  ],
            /* [out] */ ULONG __RPC_FAR *pcConstraintDescs,
            /* [size_is][size_is][out] */ DBCONSTRAINTDESC __RPC_FAR *__RPC_FAR prgConstraintDescs[  ],
            /* [out] */ OLECHAR __RPC_FAR *__RPC_FAR *ppwszStringBuffer);
        
        END_INTERFACE
    } ITableCreationVtbl;

    interface ITableCreation
    {
        CONST_VTBL struct ITableCreationVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define ITableCreation_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define ITableCreation_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define ITableCreation_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define ITableCreation_CreateTable(This,pUnkOuter,pTableID,cColumnDescs,rgColumnDescs,riid,cPropertySets,rgPropertySets,ppTableID,ppRowset)	\
    (This)->lpVtbl -> CreateTable(This,pUnkOuter,pTableID,cColumnDescs,rgColumnDescs,riid,cPropertySets,rgPropertySets,ppTableID,ppRowset)

#define ITableCreation_DropTable(This,pTableID)	\
    (This)->lpVtbl -> DropTable(This,pTableID)

#define ITableCreation_AddColumn(This,pTableID,pColumnDesc,ppColumnID)	\
    (This)->lpVtbl -> AddColumn(This,pTableID,pColumnDesc,ppColumnID)

#define ITableCreation_DropColumn(This,pTableID,pColumnID)	\
    (This)->lpVtbl -> DropColumn(This,pTableID,pColumnID)


#define ITableCreation_GetTableDefinition(This,pTableID,pcColumnDescs,prgColumnDescs,pcPropertySets,prgPropertySets,pcConstraintDescs,prgConstraintDescs,ppwszStringBuffer)	\
    (This)->lpVtbl -> GetTableDefinition(This,pTableID,pcColumnDescs,prgColumnDescs,pcPropertySets,prgPropertySets,pcConstraintDescs,prgConstraintDescs,ppwszStringBuffer)

#endif /* COBJMACROS */


#endif 	/* C style interface */



/* [local] */ HRESULT STDMETHODCALLTYPE ITableCreation_GetTableDefinition_Proxy( 
    ITableCreation __RPC_FAR * This,
    /* [in] */ DBID __RPC_FAR *pTableID,
    /* [out] */ ULONG __RPC_FAR *pcColumnDescs,
    /* [size_is][size_is][out] */ DBCOLUMNDESC __RPC_FAR *__RPC_FAR prgColumnDescs[  ],
    /* [out] */ ULONG __RPC_FAR *pcPropertySets,
    /* [size_is][size_is][out] */ DBPROPSET __RPC_FAR *__RPC_FAR prgPropertySets[  ],
    /* [out] */ ULONG __RPC_FAR *pcConstraintDescs,
    /* [size_is][size_is][out] */ DBCONSTRAINTDESC __RPC_FAR *__RPC_FAR prgConstraintDescs[  ],
    /* [out] */ OLECHAR __RPC_FAR *__RPC_FAR *ppwszStringBuffer);


void __RPC_STUB ITableCreation_GetTableDefinition_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __ITableCreation_INTERFACE_DEFINED__ */


#ifndef __ITableDefinitionWithConstraints_INTERFACE_DEFINED__
#define __ITableDefinitionWithConstraints_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: ITableDefinitionWithConstraints
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object][local] */ 



EXTERN_C const IID IID_ITableDefinitionWithConstraints;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733aab-2a1c-11ce-ade5-00aa0044773d")
    ITableDefinitionWithConstraints : public ITableCreation
    {
    public:
        virtual HRESULT STDMETHODCALLTYPE AddConstraint( 
            /* [in] */ DBID __RPC_FAR *pTableID,
            /* [in] */ DBCONSTRAINTDESC __RPC_FAR *pConstraintDesc) = 0;
        
        virtual HRESULT STDMETHODCALLTYPE CreateTableWithConstraints( 
            /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
            /* [in] */ DBID __RPC_FAR *pTableID,
            /* [in] */ ULONG cColumnDescs,
            /* [out][size_is][in] */ DBCOLUMNDESC __RPC_FAR rgColumnDescs[  ],
            /* [in] */ ULONG cConstraintDescs,
            /* [size_is][in] */ DBCONSTRAINTDESC __RPC_FAR rgConstraintDescs[  ],
            /* [in] */ REFIID riid,
            /* [in] */ ULONG cPropertySets,
            /* [out][size_is][in] */ DBPROPSET __RPC_FAR rgPropertySets[  ],
            /* [out] */ DBID __RPC_FAR *__RPC_FAR *ppTableID,
            /* [out] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset) = 0;
        
        virtual HRESULT STDMETHODCALLTYPE DropConstraint( 
            /* [in] */ DBID __RPC_FAR *pTableID,
            /* [in] */ DBID __RPC_FAR *pConstraintID) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct ITableDefinitionWithConstraintsVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            ITableDefinitionWithConstraints __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            ITableDefinitionWithConstraints __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            ITableDefinitionWithConstraints __RPC_FAR * This);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *CreateTable )( 
            ITableDefinitionWithConstraints __RPC_FAR * This,
            /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
            /* [in] */ DBID __RPC_FAR *pTableID,
            /* [in] */ ULONG cColumnDescs,
            /* [size_is][in] */ const DBCOLUMNDESC __RPC_FAR rgColumnDescs[  ],
            /* [in] */ REFIID riid,
            /* [in] */ ULONG cPropertySets,
            /* [size_is][out][in] */ DBPROPSET __RPC_FAR rgPropertySets[  ],
            /* [out] */ DBID __RPC_FAR *__RPC_FAR *ppTableID,
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *DropTable )( 
            ITableDefinitionWithConstraints __RPC_FAR * This,
            /* [unique][in] */ DBID __RPC_FAR *pTableID);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *AddColumn )( 
            ITableDefinitionWithConstraints __RPC_FAR * This,
            /* [in] */ DBID __RPC_FAR *pTableID,
            /* [out][in] */ DBCOLUMNDESC __RPC_FAR *pColumnDesc,
            /* [out] */ DBID __RPC_FAR *__RPC_FAR *ppColumnID);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *DropColumn )( 
            ITableDefinitionWithConstraints __RPC_FAR * This,
            /* [unique][in] */ DBID __RPC_FAR *pTableID,
            /* [unique][in] */ DBID __RPC_FAR *pColumnID);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetTableDefinition )( 
            ITableDefinitionWithConstraints __RPC_FAR * This,
            /* [in] */ DBID __RPC_FAR *pTableID,
            /* [out] */ ULONG __RPC_FAR *pcColumnDescs,
            /* [size_is][size_is][out] */ DBCOLUMNDESC __RPC_FAR *__RPC_FAR prgColumnDescs[  ],
            /* [out] */ ULONG __RPC_FAR *pcPropertySets,
            /* [size_is][size_is][out] */ DBPROPSET __RPC_FAR *__RPC_FAR prgPropertySets[  ],
            /* [out] */ ULONG __RPC_FAR *pcConstraintDescs,
            /* [size_is][size_is][out] */ DBCONSTRAINTDESC __RPC_FAR *__RPC_FAR prgConstraintDescs[  ],
            /* [out] */ OLECHAR __RPC_FAR *__RPC_FAR *ppwszStringBuffer);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *AddConstraint )( 
            ITableDefinitionWithConstraints __RPC_FAR * This,
            /* [in] */ DBID __RPC_FAR *pTableID,
            /* [in] */ DBCONSTRAINTDESC __RPC_FAR *pConstraintDesc);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *CreateTableWithConstraints )( 
            ITableDefinitionWithConstraints __RPC_FAR * This,
            /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
            /* [in] */ DBID __RPC_FAR *pTableID,
            /* [in] */ ULONG cColumnDescs,
            /* [out][size_is][in] */ DBCOLUMNDESC __RPC_FAR rgColumnDescs[  ],
            /* [in] */ ULONG cConstraintDescs,
            /* [size_is][in] */ DBCONSTRAINTDESC __RPC_FAR rgConstraintDescs[  ],
            /* [in] */ REFIID riid,
            /* [in] */ ULONG cPropertySets,
            /* [out][size_is][in] */ DBPROPSET __RPC_FAR rgPropertySets[  ],
            /* [out] */ DBID __RPC_FAR *__RPC_FAR *ppTableID,
            /* [out] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *DropConstraint )( 
            ITableDefinitionWithConstraints __RPC_FAR * This,
            /* [in] */ DBID __RPC_FAR *pTableID,
            /* [in] */ DBID __RPC_FAR *pConstraintID);
        
        END_INTERFACE
    } ITableDefinitionWithConstraintsVtbl;

    interface ITableDefinitionWithConstraints
    {
        CONST_VTBL struct ITableDefinitionWithConstraintsVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define ITableDefinitionWithConstraints_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define ITableDefinitionWithConstraints_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define ITableDefinitionWithConstraints_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define ITableDefinitionWithConstraints_CreateTable(This,pUnkOuter,pTableID,cColumnDescs,rgColumnDescs,riid,cPropertySets,rgPropertySets,ppTableID,ppRowset)	\
    (This)->lpVtbl -> CreateTable(This,pUnkOuter,pTableID,cColumnDescs,rgColumnDescs,riid,cPropertySets,rgPropertySets,ppTableID,ppRowset)

#define ITableDefinitionWithConstraints_DropTable(This,pTableID)	\
    (This)->lpVtbl -> DropTable(This,pTableID)

#define ITableDefinitionWithConstraints_AddColumn(This,pTableID,pColumnDesc,ppColumnID)	\
    (This)->lpVtbl -> AddColumn(This,pTableID,pColumnDesc,ppColumnID)

#define ITableDefinitionWithConstraints_DropColumn(This,pTableID,pColumnID)	\
    (This)->lpVtbl -> DropColumn(This,pTableID,pColumnID)


#define ITableDefinitionWithConstraints_GetTableDefinition(This,pTableID,pcColumnDescs,prgColumnDescs,pcPropertySets,prgPropertySets,pcConstraintDescs,prgConstraintDescs,ppwszStringBuffer)	\
    (This)->lpVtbl -> GetTableDefinition(This,pTableID,pcColumnDescs,prgColumnDescs,pcPropertySets,prgPropertySets,pcConstraintDescs,prgConstraintDescs,ppwszStringBuffer)


#define ITableDefinitionWithConstraints_AddConstraint(This,pTableID,pConstraintDesc)	\
    (This)->lpVtbl -> AddConstraint(This,pTableID,pConstraintDesc)

#define ITableDefinitionWithConstraints_CreateTableWithConstraints(This,pUnkOuter,pTableID,cColumnDescs,rgColumnDescs,cConstraintDescs,rgConstraintDescs,riid,cPropertySets,rgPropertySets,ppTableID,ppRowset)	\
    (This)->lpVtbl -> CreateTableWithConstraints(This,pUnkOuter,pTableID,cColumnDescs,rgColumnDescs,cConstraintDescs,rgConstraintDescs,riid,cPropertySets,rgPropertySets,ppTableID,ppRowset)

#define ITableDefinitionWithConstraints_DropConstraint(This,pTableID,pConstraintID)	\
    (This)->lpVtbl -> DropConstraint(This,pTableID,pConstraintID)

#endif /* COBJMACROS */


#endif 	/* C style interface */



HRESULT STDMETHODCALLTYPE ITableDefinitionWithConstraints_AddConstraint_Proxy( 
    ITableDefinitionWithConstraints __RPC_FAR * This,
    /* [in] */ DBID __RPC_FAR *pTableID,
    /* [in] */ DBCONSTRAINTDESC __RPC_FAR *pConstraintDesc);


void __RPC_STUB ITableDefinitionWithConstraints_AddConstraint_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


HRESULT STDMETHODCALLTYPE ITableDefinitionWithConstraints_CreateTableWithConstraints_Proxy( 
    ITableDefinitionWithConstraints __RPC_FAR * This,
    /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
    /* [in] */ DBID __RPC_FAR *pTableID,
    /* [in] */ ULONG cColumnDescs,
    /* [out][size_is][in] */ DBCOLUMNDESC __RPC_FAR rgColumnDescs[  ],
    /* [in] */ ULONG cConstraintDescs,
    /* [size_is][in] */ DBCONSTRAINTDESC __RPC_FAR rgConstraintDescs[  ],
    /* [in] */ REFIID riid,
    /* [in] */ ULONG cPropertySets,
    /* [out][size_is][in] */ DBPROPSET __RPC_FAR rgPropertySets[  ],
    /* [out] */ DBID __RPC_FAR *__RPC_FAR *ppTableID,
    /* [out] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset);


void __RPC_STUB ITableDefinitionWithConstraints_CreateTableWithConstraints_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


HRESULT STDMETHODCALLTYPE ITableDefinitionWithConstraints_DropConstraint_Proxy( 
    ITableDefinitionWithConstraints __RPC_FAR * This,
    /* [in] */ DBID __RPC_FAR *pTableID,
    /* [in] */ DBID __RPC_FAR *pConstraintID);


void __RPC_STUB ITableDefinitionWithConstraints_DropConstraint_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __ITableDefinitionWithConstraints_INTERFACE_DEFINED__ */

#ifndef UNDER_CE

#ifndef __IRow_INTERFACE_DEFINED__
#define __IRow_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: IRow
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object][local] */ 



EXTERN_C const IID IID_IRow;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733ab4-2a1c-11ce-ade5-00aa0044773d")
    IRow : public IUnknown
    {
    public:
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetColumns( 
            /* [in] */ ULONG cColumns,
            /* [size_is][out][in] */ DBCOLUMNACCESS __RPC_FAR rgColumns[  ]) = 0;
        
        virtual HRESULT STDMETHODCALLTYPE GetSourceRowset( 
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset,
            /* [out] */ HROW __RPC_FAR *phRow) = 0;
        
        virtual HRESULT STDMETHODCALLTYPE Open( 
            /* [unique][in] */ IUnknown __RPC_FAR *pUnkOuter,
            /* [in] */ DBID __RPC_FAR *pColumnID,
            /* [in] */ REFGUID rguidColumnType,
            /* [in] */ DWORD dwBindFlags,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppUnk) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct IRowVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            IRow __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            IRow __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            IRow __RPC_FAR * This);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetColumns )( 
            IRow __RPC_FAR * This,
            /* [in] */ ULONG cColumns,
            /* [size_is][out][in] */ DBCOLUMNACCESS __RPC_FAR rgColumns[  ]);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetSourceRowset )( 
            IRow __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset,
            /* [out] */ HROW __RPC_FAR *phRow);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Open )( 
            IRow __RPC_FAR * This,
            /* [unique][in] */ IUnknown __RPC_FAR *pUnkOuter,
            /* [in] */ DBID __RPC_FAR *pColumnID,
            /* [in] */ REFGUID rguidColumnType,
            /* [in] */ DWORD dwBindFlags,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppUnk);
        
        END_INTERFACE
    } IRowVtbl;

    interface IRow
    {
        CONST_VTBL struct IRowVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define IRow_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define IRow_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define IRow_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define IRow_GetColumns(This,cColumns,rgColumns)	\
    (This)->lpVtbl -> GetColumns(This,cColumns,rgColumns)

#define IRow_GetSourceRowset(This,riid,ppRowset,phRow)	\
    (This)->lpVtbl -> GetSourceRowset(This,riid,ppRowset,phRow)

#define IRow_Open(This,pUnkOuter,pColumnID,rguidColumnType,dwBindFlags,riid,ppUnk)	\
    (This)->lpVtbl -> Open(This,pUnkOuter,pColumnID,rguidColumnType,dwBindFlags,riid,ppUnk)

#endif /* COBJMACROS */


#endif 	/* C style interface */



/* [local] */ HRESULT STDMETHODCALLTYPE IRow_GetColumns_Proxy( 
    IRow __RPC_FAR * This,
    /* [in] */ ULONG cColumns,
    /* [size_is][out][in] */ DBCOLUMNACCESS __RPC_FAR rgColumns[  ]);


void __RPC_STUB IRow_GetColumns_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


HRESULT STDMETHODCALLTYPE IRow_GetSourceRowset_Proxy( 
    IRow __RPC_FAR * This,
    /* [in] */ REFIID riid,
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset,
    /* [out] */ HROW __RPC_FAR *phRow);


void __RPC_STUB IRow_GetSourceRowset_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


HRESULT STDMETHODCALLTYPE IRow_Open_Proxy( 
    IRow __RPC_FAR * This,
    /* [unique][in] */ IUnknown __RPC_FAR *pUnkOuter,
    /* [in] */ DBID __RPC_FAR *pColumnID,
    /* [in] */ REFGUID rguidColumnType,
    /* [in] */ DWORD dwBindFlags,
    /* [in] */ REFIID riid,
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppUnk);


void __RPC_STUB IRow_Open_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __IRow_INTERFACE_DEFINED__ */


#ifndef __IRowChange_INTERFACE_DEFINED__
#define __IRowChange_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: IRowChange
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object][local] */ 



EXTERN_C const IID IID_IRowChange;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733ab5-2a1c-11ce-ade5-00aa0044773d")
    IRowChange : public IUnknown
    {
    public:
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE SetColumns( 
            /* [in] */ ULONG cColumns,
            /* [size_is][out][in] */ DBCOLUMNACCESS __RPC_FAR rgColumns[  ]) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct IRowChangeVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            IRowChange __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            IRowChange __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            IRowChange __RPC_FAR * This);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *SetColumns )( 
            IRowChange __RPC_FAR * This,
            /* [in] */ ULONG cColumns,
            /* [size_is][out][in] */ DBCOLUMNACCESS __RPC_FAR rgColumns[  ]);
        
        END_INTERFACE
    } IRowChangeVtbl;

    interface IRowChange
    {
        CONST_VTBL struct IRowChangeVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define IRowChange_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define IRowChange_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define IRowChange_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define IRowChange_SetColumns(This,cColumns,rgColumns)	\
    (This)->lpVtbl -> SetColumns(This,cColumns,rgColumns)

#endif /* COBJMACROS */


#endif 	/* C style interface */



/* [local] */ HRESULT STDMETHODCALLTYPE IRowChange_SetColumns_Proxy( 
    IRowChange __RPC_FAR * This,
    /* [in] */ ULONG cColumns,
    /* [size_is][out][in] */ DBCOLUMNACCESS __RPC_FAR rgColumns[  ]);


void __RPC_STUB IRowChange_SetColumns_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __IRowChange_INTERFACE_DEFINED__ */


#ifndef __IRowSchemaChange_INTERFACE_DEFINED__
#define __IRowSchemaChange_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: IRowSchemaChange
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object][local] */ 



EXTERN_C const IID IID_IRowSchemaChange;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733aae-2a1c-11ce-ade5-00aa0044773d")
    IRowSchemaChange : public IRowChange
    {
    public:
        virtual HRESULT STDMETHODCALLTYPE DeleteColumns( 
            /* [in] */ ULONG cColumns,
            /* [size_is][in] */ const DBID __RPC_FAR rgColumnIDs[  ],
            /* [size_is][out][in] */ DBSTATUS __RPC_FAR rgdwStatus[  ]) = 0;
        
        virtual HRESULT STDMETHODCALLTYPE AddColumns( 
            /* [in] */ ULONG cColumns,
            /* [size_is][in] */ const DBCOLUMNINFO __RPC_FAR rgNewColumnInfo[  ],
            /* [size_is][out][in] */ DBCOLUMNACCESS __RPC_FAR rgColumns[  ]) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct IRowSchemaChangeVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            IRowSchemaChange __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            IRowSchemaChange __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            IRowSchemaChange __RPC_FAR * This);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *SetColumns )( 
            IRowSchemaChange __RPC_FAR * This,
            /* [in] */ ULONG cColumns,
            /* [size_is][out][in] */ DBCOLUMNACCESS __RPC_FAR rgColumns[  ]);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *DeleteColumns )( 
            IRowSchemaChange __RPC_FAR * This,
            /* [in] */ ULONG cColumns,
            /* [size_is][in] */ const DBID __RPC_FAR rgColumnIDs[  ],
            /* [size_is][out][in] */ DBSTATUS __RPC_FAR rgdwStatus[  ]);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *AddColumns )( 
            IRowSchemaChange __RPC_FAR * This,
            /* [in] */ ULONG cColumns,
            /* [size_is][in] */ const DBCOLUMNINFO __RPC_FAR rgNewColumnInfo[  ],
            /* [size_is][out][in] */ DBCOLUMNACCESS __RPC_FAR rgColumns[  ]);
        
        END_INTERFACE
    } IRowSchemaChangeVtbl;

    interface IRowSchemaChange
    {
        CONST_VTBL struct IRowSchemaChangeVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define IRowSchemaChange_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define IRowSchemaChange_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define IRowSchemaChange_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define IRowSchemaChange_SetColumns(This,cColumns,rgColumns)	\
    (This)->lpVtbl -> SetColumns(This,cColumns,rgColumns)


#define IRowSchemaChange_DeleteColumns(This,cColumns,rgColumnIDs,rgdwStatus)	\
    (This)->lpVtbl -> DeleteColumns(This,cColumns,rgColumnIDs,rgdwStatus)

#define IRowSchemaChange_AddColumns(This,cColumns,rgNewColumnInfo,rgColumns)	\
    (This)->lpVtbl -> AddColumns(This,cColumns,rgNewColumnInfo,rgColumns)

#endif /* COBJMACROS */


#endif 	/* C style interface */



HRESULT STDMETHODCALLTYPE IRowSchemaChange_DeleteColumns_Proxy( 
    IRowSchemaChange __RPC_FAR * This,
    /* [in] */ ULONG cColumns,
    /* [size_is][in] */ const DBID __RPC_FAR rgColumnIDs[  ],
    /* [size_is][out][in] */ DBSTATUS __RPC_FAR rgdwStatus[  ]);


void __RPC_STUB IRowSchemaChange_DeleteColumns_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


HRESULT STDMETHODCALLTYPE IRowSchemaChange_AddColumns_Proxy( 
    IRowSchemaChange __RPC_FAR * This,
    /* [in] */ ULONG cColumns,
    /* [size_is][in] */ const DBCOLUMNINFO __RPC_FAR rgNewColumnInfo[  ],
    /* [size_is][out][in] */ DBCOLUMNACCESS __RPC_FAR rgColumns[  ]);


void __RPC_STUB IRowSchemaChange_AddColumns_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __IRowSchemaChange_INTERFACE_DEFINED__ */


#ifndef __IGetRow_INTERFACE_DEFINED__
#define __IGetRow_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: IGetRow
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object][local] */ 



EXTERN_C const IID IID_IGetRow;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733aaf-2a1c-11ce-ade5-00aa0044773d")
    IGetRow : public IUnknown
    {
    public:
        virtual HRESULT STDMETHODCALLTYPE GetRowFromHROW( 
            /* [unique][in] */ IUnknown __RPC_FAR *pUnkOuter,
            /* [in] */ HROW hRow,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppUnk) = 0;
        
        virtual HRESULT STDMETHODCALLTYPE GetURLFromHROW( 
            /* [in] */ HROW hRow,
            /* [out] */ LPOLESTR __RPC_FAR *ppwszURL) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct IGetRowVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            IGetRow __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            IGetRow __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            IGetRow __RPC_FAR * This);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetRowFromHROW )( 
            IGetRow __RPC_FAR * This,
            /* [unique][in] */ IUnknown __RPC_FAR *pUnkOuter,
            /* [in] */ HROW hRow,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppUnk);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetURLFromHROW )( 
            IGetRow __RPC_FAR * This,
            /* [in] */ HROW hRow,
            /* [out] */ LPOLESTR __RPC_FAR *ppwszURL);
        
        END_INTERFACE
    } IGetRowVtbl;

    interface IGetRow
    {
        CONST_VTBL struct IGetRowVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define IGetRow_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define IGetRow_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define IGetRow_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define IGetRow_GetRowFromHROW(This,pUnkOuter,hRow,riid,ppUnk)	\
    (This)->lpVtbl -> GetRowFromHROW(This,pUnkOuter,hRow,riid,ppUnk)

#define IGetRow_GetURLFromHROW(This,hRow,ppwszURL)	\
    (This)->lpVtbl -> GetURLFromHROW(This,hRow,ppwszURL)

#endif /* COBJMACROS */


#endif 	/* C style interface */



HRESULT STDMETHODCALLTYPE IGetRow_GetRowFromHROW_Proxy( 
    IGetRow __RPC_FAR * This,
    /* [unique][in] */ IUnknown __RPC_FAR *pUnkOuter,
    /* [in] */ HROW hRow,
    /* [in] */ REFIID riid,
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppUnk);


void __RPC_STUB IGetRow_GetRowFromHROW_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


HRESULT STDMETHODCALLTYPE IGetRow_GetURLFromHROW_Proxy( 
    IGetRow __RPC_FAR * This,
    /* [in] */ HROW hRow,
    /* [out] */ LPOLESTR __RPC_FAR *ppwszURL);


void __RPC_STUB IGetRow_GetURLFromHROW_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __IGetRow_INTERFACE_DEFINED__ */


#ifndef __IBindResource_INTERFACE_DEFINED__
#define __IBindResource_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: IBindResource
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object] */ 



EXTERN_C const IID IID_IBindResource;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733ab1-2a1c-11ce-ade5-00aa0044773d")
    IBindResource : public IUnknown
    {
    public:
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE Bind( 
            /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
            /* [in] */ LPCOLESTR pwszURL,
            /* [in] */ DBBINDURLFLAG dwBindURLFlags,
            /* [in] */ REFGUID rguid,
            /* [in] */ REFIID riid,
            /* [in] */ IAuthenticate __RPC_FAR *pAuthenticate,
            /* [unique][out][in] */ DBIMPLICITSESSION __RPC_FAR *pImplSession,
            /* [out] */ DBBINDURLSTATUS __RPC_FAR *pdwBindStatus,
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppUnk) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct IBindResourceVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            IBindResource __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            IBindResource __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            IBindResource __RPC_FAR * This);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Bind )( 
            IBindResource __RPC_FAR * This,
            /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
            /* [in] */ LPCOLESTR pwszURL,
            /* [in] */ DBBINDURLFLAG dwBindURLFlags,
            /* [in] */ REFGUID rguid,
            /* [in] */ REFIID riid,
            /* [in] */ IAuthenticate __RPC_FAR *pAuthenticate,
            /* [unique][out][in] */ DBIMPLICITSESSION __RPC_FAR *pImplSession,
            /* [out] */ DBBINDURLSTATUS __RPC_FAR *pdwBindStatus,
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppUnk);
        
        END_INTERFACE
    } IBindResourceVtbl;

    interface IBindResource
    {
        CONST_VTBL struct IBindResourceVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define IBindResource_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define IBindResource_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define IBindResource_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define IBindResource_Bind(This,pUnkOuter,pwszURL,dwBindURLFlags,rguid,riid,pAuthenticate,pImplSession,pdwBindStatus,ppUnk)	\
    (This)->lpVtbl -> Bind(This,pUnkOuter,pwszURL,dwBindURLFlags,rguid,riid,pAuthenticate,pImplSession,pdwBindStatus,ppUnk)

#endif /* COBJMACROS */


#endif 	/* C style interface */



/* [call_as] */ HRESULT STDMETHODCALLTYPE IBindResource_RemoteBind_Proxy( 
    IBindResource __RPC_FAR * This,
    /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
    /* [in] */ LPCOLESTR pwszURL,
    /* [in] */ DBBINDURLFLAG dwBindURLFlags,
    /* [in] */ REFGUID rguid,
    /* [in] */ REFIID riid,
    /* [in] */ IAuthenticate __RPC_FAR *pAuthenticate,
    /* [unique][out][in] */ DBIMPLICITSESSION __RPC_FAR *pImplSession,
    /* [out] */ DBBINDURLSTATUS __RPC_FAR *pdwBindStatus,
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppUnk);


void __RPC_STUB IBindResource_RemoteBind_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __IBindResource_INTERFACE_DEFINED__ */


#ifndef __IScopedOperations_INTERFACE_DEFINED__
#define __IScopedOperations_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: IScopedOperations
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object] */ 


typedef DWORD DBCOPYFLAGS;


enum DBCOPYFLAGSENUM
    {	DBCOPY_ASYNC	= 0x100,
	DBCOPY_REPLACE_EXISTING	= 0x200,
	DBCOPY_ALLOW_EMULATION	= 0x400,
	DBCOPY_NON_RECURSIVE	= 0x800,
	DBCOPY_ATOMIC	= 0x1000
    };
typedef DWORD DBMOVEFLAGS;


enum DBMOVEFLAGSENUM
    {	DBMOVE_REPLACE_EXISTING	= 0x1,
	DBMOVE_ASYNC	= 0x100,
	DBMOVE_DONT_UPDATE_LINKS	= 0x200,
	DBMOVE_ALLOW_EMULATION	= 0x400,
	DBMOVE_ATOMIC	= 0x1000
    };
typedef DWORD DBDELETEFLAGS;


enum DBDELETEFLAGSENUM
    {	DBDELETE_ASYNC	= 0x100,
	DBDELETE_ATOMIC	= 0x1000
    };

EXTERN_C const IID IID_IScopedOperations;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733ab0-2a1c-11ce-ade5-00aa0044773d")
    IScopedOperations : public IBindResource
    {
    public:
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE Copy( 
            /* [in] */ ULONG cRows,
            /* [size_is][in] */ LPCOLESTR __RPC_FAR rgpwszSourceURLs[  ],
            /* [size_is][in] */ LPCOLESTR __RPC_FAR rgpwszDestURLs[  ],
            /* [in] */ DWORD dwCopyFlags,
            /* [unique][in] */ IAuthenticate __RPC_FAR *pAuthenticate,
            /* [size_is][out][in] */ DBSTATUS __RPC_FAR rgdwStatus[  ],
            /* [size_is][out] */ LPOLESTR __RPC_FAR rgpwszNewURLs[  ],
            /* [out] */ OLECHAR __RPC_FAR *__RPC_FAR *ppStringsBuffer) = 0;
        
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE Move( 
            /* [in] */ ULONG cRows,
            /* [size_is][in] */ LPCOLESTR __RPC_FAR rgpwszSourceURLs[  ],
            /* [size_is][in] */ LPCOLESTR __RPC_FAR rgpwszDestURLs[  ],
            /* [in] */ DWORD dwMoveFlags,
            /* [unique][in] */ IAuthenticate __RPC_FAR *pAuthenticate,
            /* [size_is][out][in] */ DBSTATUS __RPC_FAR rgdwStatus[  ],
            /* [size_is][out] */ LPOLESTR __RPC_FAR rgpwszNewURLs[  ],
            /* [out] */ OLECHAR __RPC_FAR *__RPC_FAR *ppStringsBuffer) = 0;
        
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE Delete( 
            /* [in] */ ULONG cRows,
            /* [size_is][in] */ LPCOLESTR __RPC_FAR rgpwszURLs[  ],
            /* [in] */ DWORD dwDeleteFlags,
            /* [size_is][out][in] */ DBSTATUS __RPC_FAR rgdwStatus[  ]) = 0;
        
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE OpenRowset( 
            /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
            /* [unique][in] */ DBID __RPC_FAR *pTableID,
            /* [unique][in] */ DBID __RPC_FAR *pIndexID,
            /* [in] */ REFIID riid,
            /* [in] */ ULONG cPropertySets,
            /* [size_is][out][in] */ DBPROPSET __RPC_FAR rgPropertySets[  ],
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct IScopedOperationsVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            IScopedOperations __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            IScopedOperations __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            IScopedOperations __RPC_FAR * This);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Bind )( 
            IScopedOperations __RPC_FAR * This,
            /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
            /* [in] */ LPCOLESTR pwszURL,
            /* [in] */ DBBINDURLFLAG dwBindURLFlags,
            /* [in] */ REFGUID rguid,
            /* [in] */ REFIID riid,
            /* [in] */ IAuthenticate __RPC_FAR *pAuthenticate,
            /* [unique][out][in] */ DBIMPLICITSESSION __RPC_FAR *pImplSession,
            /* [out] */ DBBINDURLSTATUS __RPC_FAR *pdwBindStatus,
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppUnk);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Copy )( 
            IScopedOperations __RPC_FAR * This,
            /* [in] */ ULONG cRows,
            /* [size_is][in] */ LPCOLESTR __RPC_FAR rgpwszSourceURLs[  ],
            /* [size_is][in] */ LPCOLESTR __RPC_FAR rgpwszDestURLs[  ],
            /* [in] */ DWORD dwCopyFlags,
            /* [unique][in] */ IAuthenticate __RPC_FAR *pAuthenticate,
            /* [size_is][out][in] */ DBSTATUS __RPC_FAR rgdwStatus[  ],
            /* [size_is][out] */ LPOLESTR __RPC_FAR rgpwszNewURLs[  ],
            /* [out] */ OLECHAR __RPC_FAR *__RPC_FAR *ppStringsBuffer);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Move )( 
            IScopedOperations __RPC_FAR * This,
            /* [in] */ ULONG cRows,
            /* [size_is][in] */ LPCOLESTR __RPC_FAR rgpwszSourceURLs[  ],
            /* [size_is][in] */ LPCOLESTR __RPC_FAR rgpwszDestURLs[  ],
            /* [in] */ DWORD dwMoveFlags,
            /* [unique][in] */ IAuthenticate __RPC_FAR *pAuthenticate,
            /* [size_is][out][in] */ DBSTATUS __RPC_FAR rgdwStatus[  ],
            /* [size_is][out] */ LPOLESTR __RPC_FAR rgpwszNewURLs[  ],
            /* [out] */ OLECHAR __RPC_FAR *__RPC_FAR *ppStringsBuffer);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Delete )( 
            IScopedOperations __RPC_FAR * This,
            /* [in] */ ULONG cRows,
            /* [size_is][in] */ LPCOLESTR __RPC_FAR rgpwszURLs[  ],
            /* [in] */ DWORD dwDeleteFlags,
            /* [size_is][out][in] */ DBSTATUS __RPC_FAR rgdwStatus[  ]);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *OpenRowset )( 
            IScopedOperations __RPC_FAR * This,
            /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
            /* [unique][in] */ DBID __RPC_FAR *pTableID,
            /* [unique][in] */ DBID __RPC_FAR *pIndexID,
            /* [in] */ REFIID riid,
            /* [in] */ ULONG cPropertySets,
            /* [size_is][out][in] */ DBPROPSET __RPC_FAR rgPropertySets[  ],
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset);
        
        END_INTERFACE
    } IScopedOperationsVtbl;

    interface IScopedOperations
    {
        CONST_VTBL struct IScopedOperationsVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define IScopedOperations_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define IScopedOperations_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define IScopedOperations_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define IScopedOperations_Bind(This,pUnkOuter,pwszURL,dwBindURLFlags,rguid,riid,pAuthenticate,pImplSession,pdwBindStatus,ppUnk)	\
    (This)->lpVtbl -> Bind(This,pUnkOuter,pwszURL,dwBindURLFlags,rguid,riid,pAuthenticate,pImplSession,pdwBindStatus,ppUnk)


#define IScopedOperations_Copy(This,cRows,rgpwszSourceURLs,rgpwszDestURLs,dwCopyFlags,pAuthenticate,rgdwStatus,rgpwszNewURLs,ppStringsBuffer)	\
    (This)->lpVtbl -> Copy(This,cRows,rgpwszSourceURLs,rgpwszDestURLs,dwCopyFlags,pAuthenticate,rgdwStatus,rgpwszNewURLs,ppStringsBuffer)

#define IScopedOperations_Move(This,cRows,rgpwszSourceURLs,rgpwszDestURLs,dwMoveFlags,pAuthenticate,rgdwStatus,rgpwszNewURLs,ppStringsBuffer)	\
    (This)->lpVtbl -> Move(This,cRows,rgpwszSourceURLs,rgpwszDestURLs,dwMoveFlags,pAuthenticate,rgdwStatus,rgpwszNewURLs,ppStringsBuffer)

#define IScopedOperations_Delete(This,cRows,rgpwszURLs,dwDeleteFlags,rgdwStatus)	\
    (This)->lpVtbl -> Delete(This,cRows,rgpwszURLs,dwDeleteFlags,rgdwStatus)

#define IScopedOperations_OpenRowset(This,pUnkOuter,pTableID,pIndexID,riid,cPropertySets,rgPropertySets,ppRowset)	\
    (This)->lpVtbl -> OpenRowset(This,pUnkOuter,pTableID,pIndexID,riid,cPropertySets,rgPropertySets,ppRowset)

#endif /* COBJMACROS */


#endif 	/* C style interface */



/* [call_as] */ HRESULT STDMETHODCALLTYPE IScopedOperations_RemoteCopy_Proxy( 
    IScopedOperations __RPC_FAR * This,
    /* [in] */ ULONG cRows,
    /* [size_is][in] */ LPCOLESTR __RPC_FAR *rgpwszSourceURLs,
    /* [size_is][in] */ LPCOLESTR __RPC_FAR *rgpwszDestURLs,
    /* [in] */ DWORD dwCopyFlags,
    /* [in] */ IAuthenticate __RPC_FAR *pAuthenticate,
    /* [size_is][out] */ DBSTATUS __RPC_FAR *rgdwStatus,
    /* [size_is][size_is][out] */ ULONG __RPC_FAR *__RPC_FAR *prgulNewURLOffsets,
    /* [out][in] */ ULONG __RPC_FAR *pcbStringsBuffer,
    /* [size_is][size_is][unique][out][in] */ OLECHAR __RPC_FAR *__RPC_FAR *ppStringsBuffer);


void __RPC_STUB IScopedOperations_RemoteCopy_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IScopedOperations_RemoteMove_Proxy( 
    IScopedOperations __RPC_FAR * This,
    /* [in] */ ULONG cRows,
    /* [size_is][in] */ LPCOLESTR __RPC_FAR *rgpwszSourceURLs,
    /* [size_is][in] */ LPCOLESTR __RPC_FAR *rgpwszDestURLs,
    /* [in] */ DWORD dwMoveFlags,
    /* [in] */ IAuthenticate __RPC_FAR *pAuthenticate,
    /* [size_is][out] */ DBSTATUS __RPC_FAR *rgdwStatus,
    /* [size_is][size_is][out] */ ULONG __RPC_FAR *__RPC_FAR *prgulNewURLOffsets,
    /* [out][in] */ ULONG __RPC_FAR *pcbStringsBuffer,
    /* [size_is][size_is][unique][out][in] */ OLECHAR __RPC_FAR *__RPC_FAR *ppStringsBuffer);


void __RPC_STUB IScopedOperations_RemoteMove_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IScopedOperations_RemoteDelete_Proxy( 
    IScopedOperations __RPC_FAR * This,
    /* [in] */ ULONG cRows,
    /* [size_is][in] */ LPCOLESTR __RPC_FAR *rgpwszURLs,
    /* [in] */ DWORD dwDeleteFlags,
    /* [size_is][out] */ DBSTATUS __RPC_FAR *rgdwStatus);


void __RPC_STUB IScopedOperations_RemoteDelete_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IScopedOperations_RemoteOpenRowset_Proxy( 
    IScopedOperations __RPC_FAR * This,
    /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
    /* [unique][in] */ DBID __RPC_FAR *pTableID,
    /* [unique][in] */ DBID __RPC_FAR *pIndexID,
    /* [in] */ REFIID riid,
    /* [in] */ ULONG cPropertySets,
    /* [size_is][unique][in] */ DBPROPSET __RPC_FAR *rgPropertySets,
    /* [iid_is][unique][out][in] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset,
    /* [in] */ ULONG cTotalProps,
    /* [size_is][out] */ DBPROPSTATUS __RPC_FAR *rgPropStatus);


void __RPC_STUB IScopedOperations_RemoteOpenRowset_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __IScopedOperations_INTERFACE_DEFINED__ */


#ifndef __ICreateRow_INTERFACE_DEFINED__
#define __ICreateRow_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: ICreateRow
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object] */ 



EXTERN_C const IID IID_ICreateRow;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733ab2-2a1c-11ce-ade5-00aa0044773d")
    ICreateRow : public IUnknown
    {
    public:
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE CreateRow( 
            /* [unique][in] */ IUnknown __RPC_FAR *pUnkOuter,
            /* [in] */ LPCOLESTR pwszURL,
            /* [in] */ DBBINDURLFLAG dwBindURLFlags,
            /* [in] */ REFGUID rguid,
            /* [in] */ REFIID riid,
            /* [unique][in] */ IAuthenticate __RPC_FAR *pAuthenticate,
            /* [unique][out][in] */ DBIMPLICITSESSION __RPC_FAR *pImplSession,
            /* [out][in] */ DBBINDURLSTATUS __RPC_FAR *pdwBindStatus,
            /* [out] */ LPOLESTR __RPC_FAR *ppwszNewURL,
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppUnk) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct ICreateRowVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            ICreateRow __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            ICreateRow __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            ICreateRow __RPC_FAR * This);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *CreateRow )( 
            ICreateRow __RPC_FAR * This,
            /* [unique][in] */ IUnknown __RPC_FAR *pUnkOuter,
            /* [in] */ LPCOLESTR pwszURL,
            /* [in] */ DBBINDURLFLAG dwBindURLFlags,
            /* [in] */ REFGUID rguid,
            /* [in] */ REFIID riid,
            /* [unique][in] */ IAuthenticate __RPC_FAR *pAuthenticate,
            /* [unique][out][in] */ DBIMPLICITSESSION __RPC_FAR *pImplSession,
            /* [out][in] */ DBBINDURLSTATUS __RPC_FAR *pdwBindStatus,
            /* [out] */ LPOLESTR __RPC_FAR *ppwszNewURL,
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppUnk);
        
        END_INTERFACE
    } ICreateRowVtbl;

    interface ICreateRow
    {
        CONST_VTBL struct ICreateRowVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define ICreateRow_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define ICreateRow_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define ICreateRow_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define ICreateRow_CreateRow(This,pUnkOuter,pwszURL,dwBindURLFlags,rguid,riid,pAuthenticate,pImplSession,pdwBindStatus,ppwszNewURL,ppUnk)	\
    (This)->lpVtbl -> CreateRow(This,pUnkOuter,pwszURL,dwBindURLFlags,rguid,riid,pAuthenticate,pImplSession,pdwBindStatus,ppwszNewURL,ppUnk)

#endif /* COBJMACROS */


#endif 	/* C style interface */



/* [call_as] */ HRESULT STDMETHODCALLTYPE ICreateRow_RemoteCreateRow_Proxy( 
    ICreateRow __RPC_FAR * This,
    /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
    /* [in] */ LPCOLESTR pwszURL,
    /* [in] */ DBBINDURLFLAG dwBindURLFlags,
    /* [in] */ REFGUID rguid,
    /* [in] */ REFIID riid,
    /* [in] */ IAuthenticate __RPC_FAR *pAuthenticate,
    /* [unique][out][in] */ DBIMPLICITSESSION __RPC_FAR *pImplSession,
    /* [out] */ DBBINDURLSTATUS __RPC_FAR *pdwBindStatus,
    /* [unique][out][in] */ LPOLESTR __RPC_FAR *ppwszNewURL,
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppUnk);


void __RPC_STUB ICreateRow_RemoteCreateRow_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __ICreateRow_INTERFACE_DEFINED__ */


#ifndef __IDBBinderProperties_INTERFACE_DEFINED__
#define __IDBBinderProperties_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: IDBBinderProperties
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object] */ 



EXTERN_C const IID IID_IDBBinderProperties;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733ab3-2a1c-11ce-ade5-00aa0044773d")
    IDBBinderProperties : public IDBProperties
    {
    public:
        virtual HRESULT STDMETHODCALLTYPE Reset( void) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct IDBBinderPropertiesVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            IDBBinderProperties __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            IDBBinderProperties __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            IDBBinderProperties __RPC_FAR * This);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetProperties )( 
            IDBBinderProperties __RPC_FAR * This,
            /* [in] */ ULONG cPropertyIDSets,
            /* [size_is][in] */ const DBPROPIDSET __RPC_FAR rgPropertyIDSets[  ],
            /* [out][in] */ ULONG __RPC_FAR *pcPropertySets,
            /* [size_is][size_is][out] */ DBPROPSET __RPC_FAR *__RPC_FAR *prgPropertySets);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetPropertyInfo )( 
            IDBBinderProperties __RPC_FAR * This,
            /* [in] */ ULONG cPropertyIDSets,
            /* [size_is][in] */ const DBPROPIDSET __RPC_FAR rgPropertyIDSets[  ],
            /* [out][in] */ ULONG __RPC_FAR *pcPropertyInfoSets,
            /* [size_is][size_is][out] */ DBPROPINFOSET __RPC_FAR *__RPC_FAR *prgPropertyInfoSets,
            /* [out] */ OLECHAR __RPC_FAR *__RPC_FAR *ppDescBuffer);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *SetProperties )( 
            IDBBinderProperties __RPC_FAR * This,
            /* [in] */ ULONG cPropertySets,
            /* [size_is][out][in] */ DBPROPSET __RPC_FAR rgPropertySets[  ]);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Reset )( 
            IDBBinderProperties __RPC_FAR * This);
        
        END_INTERFACE
    } IDBBinderPropertiesVtbl;

    interface IDBBinderProperties
    {
        CONST_VTBL struct IDBBinderPropertiesVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define IDBBinderProperties_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define IDBBinderProperties_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define IDBBinderProperties_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define IDBBinderProperties_GetProperties(This,cPropertyIDSets,rgPropertyIDSets,pcPropertySets,prgPropertySets)	\
    (This)->lpVtbl -> GetProperties(This,cPropertyIDSets,rgPropertyIDSets,pcPropertySets,prgPropertySets)

#define IDBBinderProperties_GetPropertyInfo(This,cPropertyIDSets,rgPropertyIDSets,pcPropertyInfoSets,prgPropertyInfoSets,ppDescBuffer)	\
    (This)->lpVtbl -> GetPropertyInfo(This,cPropertyIDSets,rgPropertyIDSets,pcPropertyInfoSets,prgPropertyInfoSets,ppDescBuffer)

#define IDBBinderProperties_SetProperties(This,cPropertySets,rgPropertySets)	\
    (This)->lpVtbl -> SetProperties(This,cPropertySets,rgPropertySets)


#define IDBBinderProperties_Reset(This)	\
    (This)->lpVtbl -> Reset(This)

#endif /* COBJMACROS */


#endif 	/* C style interface */



HRESULT STDMETHODCALLTYPE IDBBinderProperties_Reset_Proxy( 
    IDBBinderProperties __RPC_FAR * This);


void __RPC_STUB IDBBinderProperties_Reset_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __IDBBinderProperties_INTERFACE_DEFINED__ */


#ifndef __IColumnsInfo2_INTERFACE_DEFINED__
#define __IColumnsInfo2_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: IColumnsInfo2
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object] */ 



EXTERN_C const IID IID_IColumnsInfo2;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733ab8-2a1c-11ce-ade5-00aa0044773d")
    IColumnsInfo2 : public IColumnsInfo
    {
    public:
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetRestrictedColumnInfo( 
            /* [in] */ ULONG cColumnIDMasks,
            /* [size_is][in] */ const DBID __RPC_FAR rgColumnIDMasks[  ],
            /* [in] */ DWORD dwFlags,
            /* [out][in] */ ULONG __RPC_FAR *pcColumns,
            /* [size_is][size_is][out] */ DBID __RPC_FAR *__RPC_FAR *prgColumnIDs,
            /* [size_is][size_is][out] */ DBCOLUMNINFO __RPC_FAR *__RPC_FAR *prgColumnInfo,
            /* [out] */ OLECHAR __RPC_FAR *__RPC_FAR *ppStringsBuffer) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct IColumnsInfo2Vtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            IColumnsInfo2 __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            IColumnsInfo2 __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            IColumnsInfo2 __RPC_FAR * This);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetColumnInfo )( 
            IColumnsInfo2 __RPC_FAR * This,
            /* [out][in] */ ULONG __RPC_FAR *pcColumns,
            /* [size_is][size_is][out] */ DBCOLUMNINFO __RPC_FAR *__RPC_FAR *prgInfo,
            /* [out] */ OLECHAR __RPC_FAR *__RPC_FAR *ppStringsBuffer);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *MapColumnIDs )( 
            IColumnsInfo2 __RPC_FAR * This,
            /* [in] */ ULONG cColumnIDs,
            /* [size_is][in] */ const DBID __RPC_FAR rgColumnIDs[  ],
            /* [size_is][out] */ ULONG __RPC_FAR rgColumns[  ]);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetRestrictedColumnInfo )( 
            IColumnsInfo2 __RPC_FAR * This,
            /* [in] */ ULONG cColumnIDMasks,
            /* [size_is][in] */ const DBID __RPC_FAR rgColumnIDMasks[  ],
            /* [in] */ DWORD dwFlags,
            /* [out][in] */ ULONG __RPC_FAR *pcColumns,
            /* [size_is][size_is][out] */ DBID __RPC_FAR *__RPC_FAR *prgColumnIDs,
            /* [size_is][size_is][out] */ DBCOLUMNINFO __RPC_FAR *__RPC_FAR *prgColumnInfo,
            /* [out] */ OLECHAR __RPC_FAR *__RPC_FAR *ppStringsBuffer);
        
        END_INTERFACE
    } IColumnsInfo2Vtbl;

    interface IColumnsInfo2
    {
        CONST_VTBL struct IColumnsInfo2Vtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define IColumnsInfo2_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define IColumnsInfo2_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define IColumnsInfo2_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define IColumnsInfo2_GetColumnInfo(This,pcColumns,prgInfo,ppStringsBuffer)	\
    (This)->lpVtbl -> GetColumnInfo(This,pcColumns,prgInfo,ppStringsBuffer)

#define IColumnsInfo2_MapColumnIDs(This,cColumnIDs,rgColumnIDs,rgColumns)	\
    (This)->lpVtbl -> MapColumnIDs(This,cColumnIDs,rgColumnIDs,rgColumns)


#define IColumnsInfo2_GetRestrictedColumnInfo(This,cColumnIDMasks,rgColumnIDMasks,dwFlags,pcColumns,prgColumnIDs,prgColumnInfo,ppStringsBuffer)	\
    (This)->lpVtbl -> GetRestrictedColumnInfo(This,cColumnIDMasks,rgColumnIDMasks,dwFlags,pcColumns,prgColumnIDs,prgColumnInfo,ppStringsBuffer)

#endif /* COBJMACROS */


#endif 	/* C style interface */



/* [call_as] */ HRESULT STDMETHODCALLTYPE IColumnsInfo2_RemoteGetRestrictedColumnInfo_Proxy( 
    IColumnsInfo2 __RPC_FAR * This,
    /* [in] */ ULONG cColumnIDMasks,
    /* [size_is][unique][in] */ const DBID __RPC_FAR *rgColumnIDMasks,
    /* [in] */ DWORD dwFlags,
    /* [out][in] */ ULONG __RPC_FAR *pcColumns,
    /* [size_is][size_is][unique][out][in] */ DBID __RPC_FAR *__RPC_FAR *prgColumnIDs,
    /* [size_is][size_is][unique][out][in] */ DBCOLUMNINFO __RPC_FAR *__RPC_FAR *prgColumnInfo,
    /* [size_is][size_is][out] */ ULONG __RPC_FAR *__RPC_FAR *prgNameOffsets,
    /* [size_is][size_is][out] */ ULONG __RPC_FAR *__RPC_FAR *prgcolumnidOffsets,
    /* [out][in] */ ULONG __RPC_FAR *pcbStringsBuffer,
    /* [size_is][size_is][unique][out][in] */ OLECHAR __RPC_FAR *__RPC_FAR *ppStringsBuffer);


void __RPC_STUB IColumnsInfo2_RemoteGetRestrictedColumnInfo_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __IColumnsInfo2_INTERFACE_DEFINED__ */


#ifndef __IRegisterProvider_INTERFACE_DEFINED__
#define __IRegisterProvider_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: IRegisterProvider
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object] */ 



EXTERN_C const IID IID_IRegisterProvider;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733ab9-2a1c-11ce-ade5-00aa0044773d")
    IRegisterProvider : public IUnknown
    {
    public:
        virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetURLMapping( 
            /* [in] */ LPCOLESTR pwszURL,
            /* [in] */ DWORD dwReserved,
            /* [out] */ CLSID __RPC_FAR *pclsidProvider) = 0;
        
        virtual HRESULT STDMETHODCALLTYPE SetURLMapping( 
            /* [unique][in] */ LPCOLESTR pwszURL,
            /* [in] */ DWORD dwReserved,
            /* [unique][in] */ REFCLSID rclsidProvider) = 0;
        
        virtual HRESULT STDMETHODCALLTYPE UnregisterProvider( 
            /* [unique][in] */ LPCOLESTR pwszURL,
            /* [in] */ DWORD dwReserved,
            /* [unique][in] */ REFCLSID rclsidProvider) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct IRegisterProviderVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            IRegisterProvider __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            IRegisterProvider __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            IRegisterProvider __RPC_FAR * This);
        
        /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetURLMapping )( 
            IRegisterProvider __RPC_FAR * This,
            /* [in] */ LPCOLESTR pwszURL,
            /* [in] */ DWORD dwReserved,
            /* [out] */ CLSID __RPC_FAR *pclsidProvider);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *SetURLMapping )( 
            IRegisterProvider __RPC_FAR * This,
            /* [unique][in] */ LPCOLESTR pwszURL,
            /* [in] */ DWORD dwReserved,
            /* [unique][in] */ REFCLSID rclsidProvider);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *UnregisterProvider )( 
            IRegisterProvider __RPC_FAR * This,
            /* [unique][in] */ LPCOLESTR pwszURL,
            /* [in] */ DWORD dwReserved,
            /* [unique][in] */ REFCLSID rclsidProvider);
        
        END_INTERFACE
    } IRegisterProviderVtbl;

    interface IRegisterProvider
    {
        CONST_VTBL struct IRegisterProviderVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define IRegisterProvider_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define IRegisterProvider_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define IRegisterProvider_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define IRegisterProvider_GetURLMapping(This,pwszURL,dwReserved,pclsidProvider)	\
    (This)->lpVtbl -> GetURLMapping(This,pwszURL,dwReserved,pclsidProvider)

#define IRegisterProvider_SetURLMapping(This,pwszURL,dwReserved,rclsidProvider)	\
    (This)->lpVtbl -> SetURLMapping(This,pwszURL,dwReserved,rclsidProvider)

#define IRegisterProvider_UnregisterProvider(This,pwszURL,dwReserved,rclsidProvider)	\
    (This)->lpVtbl -> UnregisterProvider(This,pwszURL,dwReserved,rclsidProvider)

#endif /* COBJMACROS */


#endif 	/* C style interface */



/* [call_as] */ HRESULT STDMETHODCALLTYPE IRegisterProvider_RemoteGetURLMapping_Proxy( 
    IRegisterProvider __RPC_FAR * This,
    /* [in] */ LPCOLESTR pwszURL,
    /* [in] */ DWORD dwReserved,
    /* [out] */ CLSID __RPC_FAR *pclsidProvider);


void __RPC_STUB IRegisterProvider_RemoteGetURLMapping_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


HRESULT STDMETHODCALLTYPE IRegisterProvider_SetURLMapping_Proxy( 
    IRegisterProvider __RPC_FAR * This,
    /* [unique][in] */ LPCOLESTR pwszURL,
    /* [in] */ DWORD dwReserved,
    /* [unique][in] */ REFCLSID rclsidProvider);


void __RPC_STUB IRegisterProvider_SetURLMapping_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


HRESULT STDMETHODCALLTYPE IRegisterProvider_UnregisterProvider_Proxy( 
    IRegisterProvider __RPC_FAR * This,
    /* [unique][in] */ LPCOLESTR pwszURL,
    /* [in] */ DWORD dwReserved,
    /* [unique][in] */ REFCLSID rclsidProvider);


void __RPC_STUB IRegisterProvider_UnregisterProvider_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __IRegisterProvider_INTERFACE_DEFINED__ */
#endif // UNDER_CE

#ifndef __IGetSession_INTERFACE_DEFINED__
#define __IGetSession_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: IGetSession
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object] */ 



EXTERN_C const IID IID_IGetSession;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733aba-2a1c-11ce-ade5-00aa0044773d")
    IGetSession : public IUnknown
    {
    public:
        virtual HRESULT STDMETHODCALLTYPE GetSession( 
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppSession) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct IGetSessionVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            IGetSession __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            IGetSession __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            IGetSession __RPC_FAR * This);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetSession )( 
            IGetSession __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppSession);
        
        END_INTERFACE
    } IGetSessionVtbl;

    interface IGetSession
    {
        CONST_VTBL struct IGetSessionVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define IGetSession_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define IGetSession_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define IGetSession_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define IGetSession_GetSession(This,riid,ppSession)	\
    (This)->lpVtbl -> GetSession(This,riid,ppSession)

#endif /* COBJMACROS */


#endif 	/* C style interface */



HRESULT STDMETHODCALLTYPE IGetSession_GetSession_Proxy( 
    IGetSession __RPC_FAR * This,
    /* [in] */ REFIID riid,
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppSession);


void __RPC_STUB IGetSession_GetSession_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __IGetSession_INTERFACE_DEFINED__ */


#ifndef __IGetSourceRow_INTERFACE_DEFINED__
#define __IGetSourceRow_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: IGetSourceRow
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object][local] */ 



EXTERN_C const IID IID_IGetSourceRow;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733abb-2a1c-11ce-ade5-00aa0044773d")
    IGetSourceRow : public IUnknown
    {
    public:
        virtual HRESULT STDMETHODCALLTYPE GetSourceRow( 
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppRow) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct IGetSourceRowVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            IGetSourceRow __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            IGetSourceRow __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            IGetSourceRow __RPC_FAR * This);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetSourceRow )( 
            IGetSourceRow __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppRow);
        
        END_INTERFACE
    } IGetSourceRowVtbl;

    interface IGetSourceRow
    {
        CONST_VTBL struct IGetSourceRowVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define IGetSourceRow_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define IGetSourceRow_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define IGetSourceRow_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define IGetSourceRow_GetSourceRow(This,riid,ppRow)	\
    (This)->lpVtbl -> GetSourceRow(This,riid,ppRow)

#endif /* COBJMACROS */


#endif 	/* C style interface */



HRESULT STDMETHODCALLTYPE IGetSourceRow_GetSourceRow_Proxy( 
    IGetSourceRow __RPC_FAR * This,
    /* [in] */ REFIID riid,
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppRow);


void __RPC_STUB IGetSourceRow_GetSourceRow_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __IGetSourceRow_INTERFACE_DEFINED__ */


#ifndef __IRowsetCurrentIndex_INTERFACE_DEFINED__
#define __IRowsetCurrentIndex_INTERFACE_DEFINED__

/****************************************
 * Generated header for interface: IRowsetCurrentIndex
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [unique][uuid][object][local] */ 



EXTERN_C const IID IID_IRowsetCurrentIndex;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    interface DECLSPEC_UUID("0c733abd-2a1c-11ce-ade5-00aa0044773d")
    IRowsetCurrentIndex : public IRowsetIndex
    {
    public:
        virtual HRESULT STDMETHODCALLTYPE GetIndex( 
            /* [out] */ DBID __RPC_FAR *__RPC_FAR *ppIndexID) = 0;
        
        virtual HRESULT STDMETHODCALLTYPE SetIndex( 
            /* [in] */ DBID __RPC_FAR *pIndexID) = 0;
        
    };
    
#else 	/* C style interface */

    typedef struct IRowsetCurrentIndexVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 
            IRowsetCurrentIndex __RPC_FAR * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 
            IRowsetCurrentIndex __RPC_FAR * This);
        
        ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 
            IRowsetCurrentIndex __RPC_FAR * This);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetIndexInfo )( 
            IRowsetCurrentIndex __RPC_FAR * This,
            /* [out][in] */ ULONG __RPC_FAR *pcKeyColumns,
            /* [size_is][size_is][out] */ DBINDEXCOLUMNDESC __RPC_FAR *__RPC_FAR *prgIndexColumnDesc,
            /* [out][in] */ ULONG __RPC_FAR *pcIndexProperties,
            /* [size_is][size_is][out] */ DBPROPSET __RPC_FAR *__RPC_FAR *prgIndexProperties);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Seek )( 
            IRowsetCurrentIndex __RPC_FAR * This,
            /* [in] */ HACCESSOR hAccessor,
            /* [in] */ ULONG cKeyValues,
            /* [in] */ void __RPC_FAR *pData,
            /* [in] */ DBSEEK dwSeekOptions);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *SetRange )( 
            IRowsetCurrentIndex __RPC_FAR * This,
            /* [in] */ HACCESSOR hAccessor,
            /* [in] */ ULONG cStartKeyColumns,
            /* [in] */ void __RPC_FAR *pStartData,
            /* [in] */ ULONG cEndKeyColumns,
            /* [in] */ void __RPC_FAR *pEndData,
            /* [in] */ DBRANGE dwRangeOptions);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetIndex )( 
            IRowsetCurrentIndex __RPC_FAR * This,
            /* [out] */ DBID __RPC_FAR *__RPC_FAR *ppIndexID);
        
        HRESULT ( STDMETHODCALLTYPE __RPC_FAR *SetIndex )( 
            IRowsetCurrentIndex __RPC_FAR * This,
            /* [in] */ DBID __RPC_FAR *pIndexID);
        
        END_INTERFACE
    } IRowsetCurrentIndexVtbl;

    interface IRowsetCurrentIndex
    {
        CONST_VTBL struct IRowsetCurrentIndexVtbl __RPC_FAR *lpVtbl;
    };

    

#ifdef COBJMACROS


#define IRowsetCurrentIndex_QueryInterface(This,riid,ppvObject)	\
    (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

#define IRowsetCurrentIndex_AddRef(This)	\
    (This)->lpVtbl -> AddRef(This)

#define IRowsetCurrentIndex_Release(This)	\
    (This)->lpVtbl -> Release(This)


#define IRowsetCurrentIndex_GetIndexInfo(This,pcKeyColumns,prgIndexColumnDesc,pcIndexProperties,prgIndexProperties)	\
    (This)->lpVtbl -> GetIndexInfo(This,pcKeyColumns,prgIndexColumnDesc,pcIndexProperties,prgIndexProperties)

#define IRowsetCurrentIndex_Seek(This,hAccessor,cKeyValues,pData,dwSeekOptions)	\
    (This)->lpVtbl -> Seek(This,hAccessor,cKeyValues,pData,dwSeekOptions)

#define IRowsetCurrentIndex_SetRange(This,hAccessor,cStartKeyColumns,pStartData,cEndKeyColumns,pEndData,dwRangeOptions)	\
    (This)->lpVtbl -> SetRange(This,hAccessor,cStartKeyColumns,pStartData,cEndKeyColumns,pEndData,dwRangeOptions)


#define IRowsetCurrentIndex_GetIndex(This,ppIndexID)	\
    (This)->lpVtbl -> GetIndex(This,ppIndexID)

#define IRowsetCurrentIndex_SetIndex(This,pIndexID)	\
    (This)->lpVtbl -> SetIndex(This,pIndexID)

#endif /* COBJMACROS */


#endif 	/* C style interface */



HRESULT STDMETHODCALLTYPE IRowsetCurrentIndex_GetIndex_Proxy( 
    IRowsetCurrentIndex __RPC_FAR * This,
    /* [out] */ DBID __RPC_FAR *__RPC_FAR *ppIndexID);


void __RPC_STUB IRowsetCurrentIndex_GetIndex_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);


HRESULT STDMETHODCALLTYPE IRowsetCurrentIndex_SetIndex_Proxy( 
    IRowsetCurrentIndex __RPC_FAR * This,
    /* [in] */ DBID __RPC_FAR *pIndexID);


void __RPC_STUB IRowsetCurrentIndex_SetIndex_Stub(
    IRpcStubBuffer *This,
    IRpcChannelBuffer *_pRpcChannelBuffer,
    PRPC_MESSAGE _pRpcMessage,
    DWORD *_pdwStubPhase);



#endif 	/* __IRowsetCurrentIndex_INTERFACE_DEFINED__ */


/****************************************
 * Generated header for interface: __MIDL_itf_oledb_0242
 * at Thu Nov 12 23:35:28 1998
 * using MIDL 3.01.75
 ****************************************/
/* [local] */ 


//
// IID values
//

// IID_IAccessor                 = {0x0c733a8c,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
// IID_IRowset                   = {0x0c733a7c,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
// IID_IRowsetInfo               = {0x0c733a55,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
// IID_IRowsetLocate             = {0x0c733a7d,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
// IID_IRowsetResynch            = {0x0c733a84,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
// IID_IRowsetScroll             = {0x0c733a7e,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
// IID_IRowsetChange             = {0x0c733a05,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
// IID_IRowsetUpdate             = {0x0c733a6d,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
// IID_IRowsetIdentity           = {0x0c733a09,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
// IID_IRowsetNotify             = {0x0c733a83,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
// IID_IRowsetIndex              = {0x0c733a82,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
// IID_ICommand                  = {0x0c733a63,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
// IID_IMultipleResults          = {0x0c733a90,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
// IID_IConvertType              = {0x0c733a88,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
// IID_ICommandPrepare           = {0x0c733a26,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
// IID_ICommandProperties        = {0x0c733a79,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
// IID_ICommandText              = {0x0c733a27,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
// IID_ICommandWithParameters    = {0x0c733a64,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
// IID_IColumnsRowset            = {0x0c733a10,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
// IID_IColumnsInfo              = {0x0c733a11,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
// IID_IDBCreateCommand          = {0x0c733a1d,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
// IID_IDBCreateSession          = {0x0c733a5d,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
// IID_ISourcesRowset            = {0x0c733a1e,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
// IID_IDBProperties             = {0x0c733a8a,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
// IID_IDBInitialize             = {0x0c733a8b,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
// IID_IDBInfo                   = {0x0c733a89,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
// IID_IDBDataSourceAdmin        = {0x0c733a7a,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
// IID_ISessionProperties        = {0x0c733a85,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
// IID_IIndexDefinition          = {0x0c733a68,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
// IID_ITableDefinition          = {0x0c733a86,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
// IID_IOpenRowset               = {0x0c733a69,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
// IID_IDBSchemaRowset           = {0x0c733a7b,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
// IID_IErrorRecords             = {0x0c733a67,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
// IID_IErrorLookup              = {0x0c733a66,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
// IID_ISQLErrorInfo             = {0x0c733a74,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
// IID_IGetDataSource            = {0x0c733a75,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
// IID_ITransactionLocal         = {0x0c733a5f,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
// IID_ITransactionJoin          = {0x0c733a5e,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
// IID_ITransactionObject        = {0x0c733a60,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}

//IID_IChapteredRowset           = {0x0c733a93,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
//IID_IDBAsynchNotify            = {0x0c733a96,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
//IID_IDBAsynchStatus            = {0x0c733a95,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
//IID_IRowsetFind                = {0x0c733a9d,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
//IID_IRowPosition               = {0x0c733a94,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
//IID_IRowPositionChange         = {0x0997a571,0x126e,0x11d0,{0x9f,0x8a,0x00,0xa0,0xc9,0xa0,0x63,0x1e}}
//IID_IViewRowset                = {0x0c733a97,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
//IID_IViewChapter               = {0x0c733a98,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
//IID_IViewSort                  = {0x0c733a9a,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
//IID_IViewFilter                = {0x0c733a9b,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
//IID_IRowsetView                = {0x0c733a99,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}

// IID_IMDDataset                = {0xa07cccd1,0x8148,0x11d0,{0x87,0xbb,0x00,0xc0,0x4f,0xc3,0x39,0x42}}
// IID_IMDFind                   = {0xa07cccd2,0x8148,0x11d0,{0x87,0xbb,0x00,0xc0,0x4f,0xc3,0x39,0x42}}
// IID_IMDRangeRowset            = {0x0c733aa0,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
// IID_IAlterTable               = {0x0c733aa5,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
// IID_IAlterIndex               = {0x0c733aa6,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
// IID_ICommandPersist           = {0x0c733aa7,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
// IID_IRowsetChapterMember      = {0x0c733aa8,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
// IID_IRowsetRefresh            = {0x0c733aa9,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
// IID_IParentRowset             = {0x0c733aaa,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}

// IID_ITrusteeAdmin				= {0c733aa1,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
// IID_ITrusteeGroupAdmin		= {0c733aa2,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
// IID_IObjectAccessControl		= {0c733aa3,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
// IID_ISecurityInfo				= {0c733aa4,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
// IID_IRow						= {0c733ab4,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
// IID_IRowChange				= {0c733ab5,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
// IID_IRowSchemaChange			= {0c733aae,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
// IID_IGetRow					= {0c733aaf,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
// IID_IScopedOperations			= {0c733ab0,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
// IID_IBindResource				= {0c733ab1,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
// IID_ICreateRow				= {0c733ab2,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
// IID_IDBResetProperties		= {0c733ab3,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
// IID_IColumnsInfo2				= {0c733ab8,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
// IID_IRegisterProvider 		= {0c733ab9,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
// IID_IGetSession		 		= {0c733aba,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
// IID_IGetSourceRow		 		= {0c733abb,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
// IID_ITableCreation	 		= {0c733abc,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}
// IID_IRowsetCurrentIndex 		= {0c733abd,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}}

extern const OLEDBDECLSPEC IID IID_IAccessor = {0x0c733a8c,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_IRowset = {0x0c733a7c,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_IRowsetInfo = {0x0c733a55,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_IRowsetLocate = {0x0c733a7d,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_IRowsetResynch = {0x0c733a84,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_IRowsetScroll = {0x0c733a7e,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_IChapteredRowset = {0x0c733a93,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_IRowsetFind = {0x0c733a9d,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_IRowPosition = {0x0c733a94,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_IRowPositionChange = {0x0997a571,0x126e,0x11d0,{0x9f,0x8a,0x00,0xa0,0xc9,0xa0,0x63,0x1e}};
extern const OLEDBDECLSPEC IID IID_IViewRowset = {0x0c733a97,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_IViewChapter = {0x0c733a98,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_IViewSort = {0x0c733a9a,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_IViewFilter = {0x0c733a9b,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_IRowsetView = {0x0c733a99,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_IRowsetExactScroll = {0x0c733a7f,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_IRowsetChange = {0x0c733a05,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_IRowsetUpdate = {0x0c733a6d,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_IRowsetIdentity = {0x0c733a09,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_IRowsetNotify = {0x0c733a83,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_IRowsetIndex = {0x0c733a82,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_ICommand = {0x0c733a63,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_IMultipleResults = {0x0c733a90,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_IConvertType = {0x0c733a88,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_ICommandPrepare = {0x0c733a26,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_ICommandProperties = {0x0c733a79,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_ICommandText = {0x0c733a27,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_ICommandWithParameters = {0x0c733a64,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_IColumnsRowset = {0x0c733a10,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_IColumnsInfo = {0x0c733a11,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_IDBCreateCommand = {0x0c733a1d,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_IDBCreateSession = {0x0c733a5d,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_ISourcesRowset = {0x0c733a1e,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_IDBProperties = {0x0c733a8a,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_IDBInitialize = {0x0c733a8b,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_IDBInfo = {0x0c733a89,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_IDBDataSourceAdmin = {0x0c733a7a,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_IDBAsynchNotify = {0x0c733a96,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_IDBAsynchStatus = {0x0c733a95,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_ISessionProperties = {0x0c733a85,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_IIndexDefinition = {0x0c733a68,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_ITableDefinition = {0x0c733a86,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_IOpenRowset = {0x0c733a69,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_IDBSchemaRowset = {0x0c733a7b,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_IMDDataset = {0xa07cccd1,0x8148,0x11d0,{0x87,0xbb,0x00,0xc0,0x4f,0xc3,0x39,0x42}};
extern const OLEDBDECLSPEC IID IID_IMDFind = {0xa07cccd2,0x8148,0x11d0,{0x87,0xbb,0x00,0xc0,0x4f,0xc3,0x39,0x42}};
extern const OLEDBDECLSPEC IID IID_IMDRangeRowset = {0x0c733aa0,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_IAlterTable = {0x0c733aa5,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_IAlterIndex = {0x0c733aa6,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_IRowsetChapterMember = {0x0c733aa8,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_ICommandPersist = {0x0c733aa7,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_IRowsetRefresh = {0x0c733aa9,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_IParentRowset = {0x0c733aaa,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_IErrorRecords = {0x0c733a67,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_IErrorLookup = {0x0c733a66,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_ISQLErrorInfo = {0x0c733a74,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_IGetDataSource = {0x0c733a75,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_ITransactionLocal = {0x0c733a5f,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_ITransactionJoin = {0x0c733a5e,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_ITransactionObject = {0x0c733a60,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_ITrusteeAdmin = {0x0c733aa1,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_ITrusteeGroupAdmin = {0x0c733aa2,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_IObjectAccessControl = {0x0c733aa3,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_ISecurityInfo = {0x0c733aa4,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_ITableCreation = {0x0c733abc,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_ITableDefinitionWithConstraints = {0x0c733aab,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_IRow = {0x0c733ab4,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_IRowChange = {0x0c733ab5,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_IRowSchemaChange = {0x0c733aae,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_IGetRow = {0x0c733aaf,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_IBindResource = {0x0c733ab1,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_IScopedOperations = {0x0c733ab0,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_ICreateRow = {0x0c733ab2,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_IDBBinderProperties = {0x0c733ab3,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_IColumnsInfo2 = {0x0c733ab8,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_IRegisterProvider = {0x0c733ab9,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_IGetSession = {0x0c733aba,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_IGetSourceRow = {0x0c733abb,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
extern const OLEDBDECLSPEC IID IID_IRowsetCurrentIndex = {0x0c733abd,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};

#include <poppack.h>     // restore original structure packing


extern RPC_IF_HANDLE __MIDL_itf_oledb_0242_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_oledb_0242_v0_0_s_ifspec;

#ifdef OLEDBPROXY
/* Additional Prototypes for ALL interfaces */

unsigned long             __RPC_USER  BSTR_UserSize(     unsigned long __RPC_FAR *, unsigned long            , BSTR __RPC_FAR * ); 
unsigned char __RPC_FAR * __RPC_USER  BSTR_UserMarshal(  unsigned long __RPC_FAR *, unsigned char __RPC_FAR *, BSTR __RPC_FAR * ); 
unsigned char __RPC_FAR * __RPC_USER  BSTR_UserUnmarshal(unsigned long __RPC_FAR *, unsigned char __RPC_FAR *, BSTR __RPC_FAR * ); 
void                      __RPC_USER  BSTR_UserFree(     unsigned long __RPC_FAR *, BSTR __RPC_FAR * ); 

unsigned long             __RPC_USER  VARIANT_UserSize(     unsigned long __RPC_FAR *, unsigned long            , VARIANT __RPC_FAR * ); 
unsigned char __RPC_FAR * __RPC_USER  VARIANT_UserMarshal(  unsigned long __RPC_FAR *, unsigned char __RPC_FAR *, VARIANT __RPC_FAR * ); 
unsigned char __RPC_FAR * __RPC_USER  VARIANT_UserUnmarshal(unsigned long __RPC_FAR *, unsigned char __RPC_FAR *, VARIANT __RPC_FAR * ); 
void                      __RPC_USER  VARIANT_UserFree(     unsigned long __RPC_FAR *, VARIANT __RPC_FAR * ); 

/* [local] */ HRESULT STDMETHODCALLTYPE IAccessor_AddRefAccessor_Proxy( 
    IAccessor __RPC_FAR * This,
    /* [in] */ HACCESSOR hAccessor,
    /* [unique][out][in] */ ULONG __RPC_FAR *pcRefCount);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IAccessor_AddRefAccessor_Stub( 
    IAccessor __RPC_FAR * This,
    /* [in] */ HACCESSOR hAccessor,
    /* [unique][out][in] */ ULONG __RPC_FAR *pcRefCount,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IAccessor_CreateAccessor_Proxy( 
    IAccessor __RPC_FAR * This,
    /* [in] */ DBACCESSORFLAGS dwAccessorFlags,
    /* [in] */ ULONG cBindings,
    /* [size_is][in] */ const DBBINDING __RPC_FAR rgBindings[  ],
    /* [in] */ ULONG cbRowSize,
    /* [out] */ HACCESSOR __RPC_FAR *phAccessor,
    /* [size_is][out] */ DBBINDSTATUS __RPC_FAR rgStatus[  ]);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IAccessor_CreateAccessor_Stub( 
    IAccessor __RPC_FAR * This,
    /* [in] */ DBACCESSORFLAGS dwAccessorFlags,
    /* [in] */ ULONG cBindings,
    /* [size_is][unique][in] */ DBBINDING __RPC_FAR *rgBindings,
    /* [in] */ ULONG cbRowSize,
    /* [out] */ HACCESSOR __RPC_FAR *phAccessor,
    /* [size_is][unique][out][in] */ DBBINDSTATUS __RPC_FAR *rgStatus,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IAccessor_GetBindings_Proxy( 
    IAccessor __RPC_FAR * This,
    /* [in] */ HACCESSOR hAccessor,
    /* [out] */ DBACCESSORFLAGS __RPC_FAR *pdwAccessorFlags,
    /* [out][in] */ ULONG __RPC_FAR *pcBindings,
    /* [size_is][size_is][out] */ DBBINDING __RPC_FAR *__RPC_FAR *prgBindings);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IAccessor_GetBindings_Stub( 
    IAccessor __RPC_FAR * This,
    /* [in] */ HACCESSOR hAccessor,
    /* [out] */ DBACCESSORFLAGS __RPC_FAR *pdwAccessorFlags,
    /* [out][in] */ ULONG __RPC_FAR *pcBindings,
    /* [size_is][size_is][out] */ DBBINDING __RPC_FAR *__RPC_FAR *prgBindings,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IAccessor_ReleaseAccessor_Proxy( 
    IAccessor __RPC_FAR * This,
    /* [in] */ HACCESSOR hAccessor,
    /* [unique][out][in] */ ULONG __RPC_FAR *pcRefCount);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IAccessor_ReleaseAccessor_Stub( 
    IAccessor __RPC_FAR * This,
    /* [in] */ HACCESSOR hAccessor,
    /* [unique][out][in] */ ULONG __RPC_FAR *pcRefCount,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IRowsetInfo_GetProperties_Proxy( 
    IRowsetInfo __RPC_FAR * This,
    /* [in] */ const ULONG cPropertyIDSets,
    /* [size_is][in] */ const DBPROPIDSET __RPC_FAR rgPropertyIDSets[  ],
    /* [out][in] */ ULONG __RPC_FAR *pcPropertySets,
    /* [size_is][size_is][out] */ DBPROPSET __RPC_FAR *__RPC_FAR *prgPropertySets);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IRowsetInfo_GetProperties_Stub( 
    IRowsetInfo __RPC_FAR * This,
    /* [in] */ ULONG cPropertyIDSets,
    /* [size_is][unique][in] */ const DBPROPIDSET __RPC_FAR *rgPropertyIDSets,
    /* [out][in] */ ULONG __RPC_FAR *pcPropertySets,
    /* [size_is][size_is][out] */ DBPROPSET __RPC_FAR *__RPC_FAR *prgPropertySets,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IRowsetInfo_GetReferencedRowset_Proxy( 
    IRowsetInfo __RPC_FAR * This,
    /* [in] */ ULONG iOrdinal,
    /* [in] */ REFIID riid,
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppReferencedRowset);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IRowsetInfo_GetReferencedRowset_Stub( 
    IRowsetInfo __RPC_FAR * This,
    /* [in] */ ULONG iOrdinal,
    /* [in] */ REFIID riid,
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppReferencedRowset,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IRowsetInfo_GetSpecification_Proxy( 
    IRowsetInfo __RPC_FAR * This,
    /* [in] */ REFIID riid,
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppSpecification);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IRowsetInfo_GetSpecification_Stub( 
    IRowsetInfo __RPC_FAR * This,
    /* [in] */ REFIID riid,
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppSpecification,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IChapteredRowset_AddRefChapter_Proxy( 
    IChapteredRowset __RPC_FAR * This,
    /* [in] */ HCHAPTER hChapter,
    /* [out] */ ULONG __RPC_FAR *pcRefCount);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IChapteredRowset_AddRefChapter_Stub( 
    IChapteredRowset __RPC_FAR * This,
    /* [in] */ HCHAPTER hChapter,
    /* [out] */ ULONG __RPC_FAR *pcRefCount,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IChapteredRowset_ReleaseChapter_Proxy( 
    IChapteredRowset __RPC_FAR * This,
    /* [in] */ HCHAPTER hChapter,
    /* [out] */ ULONG __RPC_FAR *pcRefCount);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IChapteredRowset_ReleaseChapter_Stub( 
    IChapteredRowset __RPC_FAR * This,
    /* [in] */ HCHAPTER hChapter,
    /* [out] */ ULONG __RPC_FAR *pcRefCount,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IRowPosition_ClearRowPosition_Proxy( 
    IRowPosition __RPC_FAR * This);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IRowPosition_ClearRowPosition_Stub( 
    IRowPosition __RPC_FAR * This,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IRowPosition_GetRowPosition_Proxy( 
    IRowPosition __RPC_FAR * This,
    /* [out] */ HCHAPTER __RPC_FAR *phChapter,
    /* [out] */ HROW __RPC_FAR *phRow,
    /* [out] */ DBPOSITIONFLAGS __RPC_FAR *pdwPositionFlags);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IRowPosition_GetRowPosition_Stub( 
    IRowPosition __RPC_FAR * This,
    /* [out] */ HCHAPTER __RPC_FAR *phChapter,
    /* [out] */ HROW __RPC_FAR *phRow,
    /* [out] */ DBPOSITIONFLAGS __RPC_FAR *pdwPositionFlags,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IRowPosition_GetRowset_Proxy( 
    IRowPosition __RPC_FAR * This,
    /* [in] */ REFIID riid,
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IRowPosition_GetRowset_Stub( 
    IRowPosition __RPC_FAR * This,
    /* [in] */ REFIID riid,
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IRowPosition_Initialize_Proxy( 
    IRowPosition __RPC_FAR * This,
    /* [in] */ IUnknown __RPC_FAR *pRowset);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IRowPosition_Initialize_Stub( 
    IRowPosition __RPC_FAR * This,
    /* [in] */ IUnknown __RPC_FAR *pRowset,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IRowPosition_SetRowPosition_Proxy( 
    IRowPosition __RPC_FAR * This,
    /* [in] */ HCHAPTER hChapter,
    /* [in] */ HROW hRow,
    /* [in] */ DBPOSITIONFLAGS dwPositionFlags);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IRowPosition_SetRowPosition_Stub( 
    IRowPosition __RPC_FAR * This,
    /* [in] */ HCHAPTER hChapter,
    /* [in] */ HROW hRow,
    /* [in] */ DBPOSITIONFLAGS dwPositionFlags,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IRowPositionChange_OnRowPositionChange_Proxy( 
    IRowPositionChange __RPC_FAR * This,
    /* [in] */ DBREASON eReason,
    /* [in] */ DBEVENTPHASE ePhase,
    /* [in] */ BOOL fCantDeny);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IRowPositionChange_OnRowPositionChange_Stub( 
    IRowPositionChange __RPC_FAR * This,
    /* [in] */ DBREASON eReason,
    /* [in] */ DBEVENTPHASE ePhase,
    /* [in] */ BOOL fCantDeny,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IViewRowset_GetSpecification_Proxy( 
    IViewRowset __RPC_FAR * This,
    /* [in] */ REFIID riid,
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppObject);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IViewRowset_GetSpecification_Stub( 
    IViewRowset __RPC_FAR * This,
    /* [in] */ REFIID riid,
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppObject,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IViewRowset_OpenViewRowset_Proxy( 
    IViewRowset __RPC_FAR * This,
    /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
    /* [in] */ REFIID riid,
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IViewRowset_OpenViewRowset_Stub( 
    IViewRowset __RPC_FAR * This,
    /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
    /* [in] */ REFIID riid,
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IViewChapter_GetSpecification_Proxy( 
    IViewChapter __RPC_FAR * This,
    /* [in] */ REFIID riid,
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IViewChapter_GetSpecification_Stub( 
    IViewChapter __RPC_FAR * This,
    /* [in] */ REFIID riid,
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IViewChapter_OpenViewChapter_Proxy( 
    IViewChapter __RPC_FAR * This,
    /* [in] */ HCHAPTER hSource,
    /* [out] */ HCHAPTER __RPC_FAR *phViewChapter);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IViewChapter_OpenViewChapter_Stub( 
    IViewChapter __RPC_FAR * This,
    /* [in] */ HCHAPTER hSource,
    /* [out] */ HCHAPTER __RPC_FAR *phViewChapter,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IViewSort_GetSortOrder_Proxy( 
    IViewSort __RPC_FAR * This,
    /* [out] */ ULONG __RPC_FAR *pcValues,
    /* [out] */ ULONG __RPC_FAR *__RPC_FAR prgColumns[  ],
    /* [out] */ DBSORT __RPC_FAR *__RPC_FAR prgOrders[  ]);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IViewSort_GetSortOrder_Stub( 
    IViewSort __RPC_FAR * This,
    /* [out][in] */ ULONG __RPC_FAR *pcValues,
    /* [size_is][size_is][out] */ ULONG __RPC_FAR *__RPC_FAR *prgColumns,
    /* [size_is][size_is][out] */ ULONG __RPC_FAR *__RPC_FAR *prgOrders,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IViewSort_SetSortOrder_Proxy( 
    IViewSort __RPC_FAR * This,
    /* [in] */ ULONG cValues,
    /* [size_is][in] */ const ULONG __RPC_FAR rgColumns[  ],
    /* [size_is][in] */ const DBSORT __RPC_FAR rgOrders[  ]);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IViewSort_SetSortOrder_Stub( 
    IViewSort __RPC_FAR * This,
    /* [in] */ ULONG cValues,
    /* [size_is][in] */ const ULONG __RPC_FAR *rgColumns,
    /* [size_is][in] */ const DBSORT __RPC_FAR *rgOrders,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IViewFilter_GetFilterBindings_Proxy( 
    IViewFilter __RPC_FAR * This,
    /* [out] */ ULONG __RPC_FAR *pcBindings,
    /* [out] */ DBBINDING __RPC_FAR *__RPC_FAR *prgBindings);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IViewFilter_GetFilterBindings_Stub( 
    IViewFilter __RPC_FAR * This,
    /* [out][in] */ ULONG __RPC_FAR *pcBindings,
    /* [size_is][size_is][out] */ DBBINDING __RPC_FAR *__RPC_FAR *prgBindings,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IRowsetView_CreateView_Proxy( 
    IRowsetView __RPC_FAR * This,
    /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
    /* [in] */ REFIID riid,
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppView);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IRowsetView_CreateView_Stub( 
    IRowsetView __RPC_FAR * This,
    /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
    /* [in] */ REFIID riid,
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppView,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IRowsetView_GetView_Proxy( 
    IRowsetView __RPC_FAR * This,
    /* [in] */ HCHAPTER hChapter,
    /* [in] */ REFIID riid,
    /* [out] */ HCHAPTER __RPC_FAR *phChapterSource,
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppView);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IRowsetView_GetView_Stub( 
    IRowsetView __RPC_FAR * This,
    /* [in] */ HCHAPTER hChapter,
    /* [in] */ REFIID riid,
    /* [out] */ HCHAPTER __RPC_FAR *phChapterSource,
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppView,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IRowsetIdentity_IsSameRow_Proxy( 
    IRowsetIdentity __RPC_FAR * This,
    /* [in] */ HROW hThisRow,
    /* [in] */ HROW hThatRow);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IRowsetIdentity_IsSameRow_Stub( 
    IRowsetIdentity __RPC_FAR * This,
    /* [in] */ HROW hThisRow,
    /* [in] */ HROW hThatRow,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IRowsetNotify_OnFieldChange_Proxy( 
    IRowsetNotify __RPC_FAR * This,
    /* [in] */ IRowset __RPC_FAR *pRowset,
    /* [in] */ HROW hRow,
    /* [in] */ ULONG cColumns,
    /* [size_is][in] */ ULONG __RPC_FAR rgColumns[  ],
    /* [in] */ DBREASON eReason,
    /* [in] */ DBEVENTPHASE ePhase,
    /* [in] */ BOOL fCantDeny);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IRowsetNotify_OnFieldChange_Stub( 
    IRowsetNotify __RPC_FAR * This,
    /* [in] */ IRowset __RPC_FAR *pRowset,
    /* [in] */ HROW hRow,
    /* [in] */ ULONG cColumns,
    /* [size_is][in] */ ULONG __RPC_FAR *rgColumns,
    /* [in] */ DBREASON eReason,
    /* [in] */ DBEVENTPHASE ePhase,
    /* [in] */ BOOL fCantDeny,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IRowsetNotify_OnRowChange_Proxy( 
    IRowsetNotify __RPC_FAR * This,
    /* [in] */ IRowset __RPC_FAR *pRowset,
    /* [in] */ ULONG cRows,
    /* [size_is][in] */ const HROW __RPC_FAR rghRows[  ],
    /* [in] */ DBREASON eReason,
    /* [in] */ DBEVENTPHASE ePhase,
    /* [in] */ BOOL fCantDeny);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IRowsetNotify_OnRowChange_Stub( 
    IRowsetNotify __RPC_FAR * This,
    /* [in] */ IRowset __RPC_FAR *pRowset,
    /* [in] */ ULONG cRows,
    /* [size_is][in] */ const HROW __RPC_FAR *rghRows,
    /* [in] */ DBREASON eReason,
    /* [in] */ DBEVENTPHASE ePhase,
    /* [in] */ BOOL fCantDeny,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IRowsetNotify_OnRowsetChange_Proxy( 
    IRowsetNotify __RPC_FAR * This,
    /* [in] */ IRowset __RPC_FAR *pRowset,
    /* [in] */ DBREASON eReason,
    /* [in] */ DBEVENTPHASE ePhase,
    /* [in] */ BOOL fCantDeny);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IRowsetNotify_OnRowsetChange_Stub( 
    IRowsetNotify __RPC_FAR * This,
    /* [in] */ IRowset __RPC_FAR *pRowset,
    /* [in] */ DBREASON eReason,
    /* [in] */ DBEVENTPHASE ePhase,
    /* [in] */ BOOL fCantDeny,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE ICommand_Cancel_Proxy( 
    ICommand __RPC_FAR * This);


/* [call_as] */ HRESULT STDMETHODCALLTYPE ICommand_Cancel_Stub( 
    ICommand __RPC_FAR * This,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE ICommand_Execute_Proxy( 
    ICommand __RPC_FAR * This,
    /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
    /* [in] */ REFIID riid,
    /* [out][in] */ DBPARAMS __RPC_FAR *pParams,
    /* [out] */ LONG __RPC_FAR *pcRowsAffected,
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset);


/* [call_as] */ HRESULT STDMETHODCALLTYPE ICommand_Execute_Stub( 
    ICommand __RPC_FAR * This,
    /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
    /* [in] */ REFIID riid,
    /* [in] */ HACCESSOR hAccessor,
    /* [in] */ ULONG cParamSets,
    /* [in] */ ULONG cbData,
    /* [size_is][unique][out][in] */ BYTE __RPC_FAR *pbData,
    /* [unique][out][in] */ LONG __RPC_FAR *pcRowsAffected,
    /* [iid_is][unique][out][in] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE ICommand_GetDBSession_Proxy( 
    ICommand __RPC_FAR * This,
    /* [in] */ REFIID riid,
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppSession);


/* [call_as] */ HRESULT STDMETHODCALLTYPE ICommand_GetDBSession_Stub( 
    ICommand __RPC_FAR * This,
    /* [in] */ REFIID riid,
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppSession,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IMultipleResults_GetResult_Proxy( 
    IMultipleResults __RPC_FAR * This,
    /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
    /* [in] */ LONG reserved,
    /* [in] */ REFIID riid,
    /* [out] */ LONG __RPC_FAR *pcRowsAffected,
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IMultipleResults_GetResult_Stub( 
    IMultipleResults __RPC_FAR * This,
    /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
    /* [in] */ LONG reserved,
    /* [in] */ REFIID riid,
    /* [unique][out][in] */ LONG __RPC_FAR *pcRowsAffected,
    /* [iid_is][unique][out][in] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IConvertType_CanConvert_Proxy( 
    IConvertType __RPC_FAR * This,
    /* [in] */ DBTYPE wFromType,
    /* [in] */ DBTYPE wToType,
    /* [in] */ DBCONVERTFLAGS dwConvertFlags);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IConvertType_CanConvert_Stub( 
    IConvertType __RPC_FAR * This,
    /* [in] */ DBTYPE wFromType,
    /* [in] */ DBTYPE wToType,
    /* [in] */ DBCONVERTFLAGS dwConvertFlags,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE ICommandPrepare_Prepare_Proxy( 
    ICommandPrepare __RPC_FAR * This,
    /* [in] */ ULONG cExpectedRuns);


/* [call_as] */ HRESULT STDMETHODCALLTYPE ICommandPrepare_Prepare_Stub( 
    ICommandPrepare __RPC_FAR * This,
    /* [in] */ ULONG cExpectedRuns,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE ICommandPrepare_Unprepare_Proxy( 
    ICommandPrepare __RPC_FAR * This);


/* [call_as] */ HRESULT STDMETHODCALLTYPE ICommandPrepare_Unprepare_Stub( 
    ICommandPrepare __RPC_FAR * This,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE ICommandProperties_GetProperties_Proxy( 
    ICommandProperties __RPC_FAR * This,
    /* [in] */ const ULONG cPropertyIDSets,
    /* [size_is][in] */ const DBPROPIDSET __RPC_FAR rgPropertyIDSets[  ],
    /* [out][in] */ ULONG __RPC_FAR *pcPropertySets,
    /* [size_is][size_is][out] */ DBPROPSET __RPC_FAR *__RPC_FAR *prgPropertySets);


/* [call_as] */ HRESULT STDMETHODCALLTYPE ICommandProperties_GetProperties_Stub( 
    ICommandProperties __RPC_FAR * This,
    /* [in] */ const ULONG cPropertyIDSets,
    /* [size_is][unique][in] */ const DBPROPIDSET __RPC_FAR *rgPropertyIDSets,
    /* [out][in] */ ULONG __RPC_FAR *pcPropertySets,
    /* [size_is][size_is][out] */ DBPROPSET __RPC_FAR *__RPC_FAR *prgPropertySets,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE ICommandProperties_SetProperties_Proxy( 
    ICommandProperties __RPC_FAR * This,
    /* [in] */ ULONG cPropertySets,
    /* [size_is][unique][out][in] */ DBPROPSET __RPC_FAR rgPropertySets[  ]);


/* [call_as] */ HRESULT STDMETHODCALLTYPE ICommandProperties_SetProperties_Stub( 
    ICommandProperties __RPC_FAR * This,
    /* [in] */ ULONG cPropertySets,
    /* [size_is][unique][in] */ DBPROPSET __RPC_FAR *rgPropertySets,
    /* [in] */ ULONG cTotalProps,
    /* [size_is][out] */ DBPROPSTATUS __RPC_FAR *rgPropStatus,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE ICommandText_GetCommandText_Proxy( 
    ICommandText __RPC_FAR * This,
    /* [out][in] */ GUID __RPC_FAR *pguidDialect,
    /* [out] */ LPOLESTR __RPC_FAR *ppwszCommand);


/* [call_as] */ HRESULT STDMETHODCALLTYPE ICommandText_GetCommandText_Stub( 
    ICommandText __RPC_FAR * This,
    /* [unique][out][in] */ GUID __RPC_FAR *pguidDialect,
    /* [out] */ LPOLESTR __RPC_FAR *ppwszCommand,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE ICommandText_SetCommandText_Proxy( 
    ICommandText __RPC_FAR * This,
    /* [in] */ REFGUID rguidDialect,
    /* [unique][in] */ LPCOLESTR pwszCommand);


/* [call_as] */ HRESULT STDMETHODCALLTYPE ICommandText_SetCommandText_Stub( 
    ICommandText __RPC_FAR * This,
    /* [in] */ REFGUID rguidDialect,
    /* [unique][in] */ LPCOLESTR pwszCommand,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE ICommandWithParameters_GetParameterInfo_Proxy( 
    ICommandWithParameters __RPC_FAR * This,
    /* [out][in] */ ULONG __RPC_FAR *pcParams,
    /* [size_is][size_is][out] */ DBPARAMINFO __RPC_FAR *__RPC_FAR *prgParamInfo,
    /* [out] */ OLECHAR __RPC_FAR *__RPC_FAR *ppNamesBuffer);


/* [call_as] */ HRESULT STDMETHODCALLTYPE ICommandWithParameters_GetParameterInfo_Stub( 
    ICommandWithParameters __RPC_FAR * This,
    /* [out][in] */ ULONG __RPC_FAR *pcParams,
    /* [size_is][size_is][out] */ DBPARAMINFO __RPC_FAR *__RPC_FAR *prgParamInfo,
    /* [size_is][size_is][out] */ ULONG __RPC_FAR *__RPC_FAR *prgNameOffsets,
    /* [out][in] */ ULONG __RPC_FAR *pcbNamesBuffer,
    /* [size_is][size_is][unique][out][in] */ OLECHAR __RPC_FAR *__RPC_FAR *ppNamesBuffer,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE ICommandWithParameters_MapParameterNames_Proxy( 
    ICommandWithParameters __RPC_FAR * This,
    /* [in] */ ULONG cParamNames,
    /* [size_is][in] */ const OLECHAR __RPC_FAR *__RPC_FAR rgParamNames[  ],
    /* [size_is][out] */ LONG __RPC_FAR rgParamOrdinals[  ]);


/* [call_as] */ HRESULT STDMETHODCALLTYPE ICommandWithParameters_MapParameterNames_Stub( 
    ICommandWithParameters __RPC_FAR * This,
    /* [in] */ ULONG cParamNames,
    /* [size_is][in] */ LPCOLESTR __RPC_FAR *rgParamNames,
    /* [size_is][out] */ LONG __RPC_FAR *rgParamOrdinals,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE ICommandWithParameters_SetParameterInfo_Proxy( 
    ICommandWithParameters __RPC_FAR * This,
    /* [in] */ ULONG cParams,
    /* [size_is][unique][in] */ const ULONG __RPC_FAR rgParamOrdinals[  ],
    /* [size_is][unique][in] */ const DBPARAMBINDINFO __RPC_FAR rgParamBindInfo[  ]);


/* [call_as] */ HRESULT STDMETHODCALLTYPE ICommandWithParameters_SetParameterInfo_Stub( 
    ICommandWithParameters __RPC_FAR * This,
    /* [in] */ ULONG cParams,
    /* [size_is][unique][in] */ const ULONG __RPC_FAR *rgParamOrdinals,
    /* [size_is][unique][in] */ const DBPARAMBINDINFO __RPC_FAR *rgParamBindInfo,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IColumnsRowset_GetAvailableColumns_Proxy( 
    IColumnsRowset __RPC_FAR * This,
    /* [out][in] */ ULONG __RPC_FAR *pcOptColumns,
    /* [size_is][size_is][out] */ DBID __RPC_FAR *__RPC_FAR *prgOptColumns);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IColumnsRowset_GetAvailableColumns_Stub( 
    IColumnsRowset __RPC_FAR * This,
    /* [out][in] */ ULONG __RPC_FAR *pcOptColumns,
    /* [size_is][size_is][out] */ DBID __RPC_FAR *__RPC_FAR *prgOptColumns,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IColumnsRowset_GetColumnsRowset_Proxy( 
    IColumnsRowset __RPC_FAR * This,
    /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
    /* [in] */ ULONG cOptColumns,
    /* [size_is][in] */ const DBID __RPC_FAR rgOptColumns[  ],
    /* [in] */ REFIID riid,
    /* [in] */ ULONG cPropertySets,
    /* [size_is][out][in] */ DBPROPSET __RPC_FAR rgPropertySets[  ],
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppColRowset);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IColumnsRowset_GetColumnsRowset_Stub( 
    IColumnsRowset __RPC_FAR * This,
    /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
    /* [in] */ ULONG cOptColumns,
    /* [size_is][unique][in] */ const DBID __RPC_FAR *rgOptColumns,
    /* [in] */ REFIID riid,
    /* [in] */ ULONG cPropertySets,
    /* [size_is][unique][in] */ DBPROPSET __RPC_FAR *rgPropertySets,
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppColRowset,
    /* [in] */ ULONG cTotalProps,
    /* [size_is][out] */ DBPROPSTATUS __RPC_FAR *rgPropStatus,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IColumnsInfo_GetColumnInfo_Proxy( 
    IColumnsInfo __RPC_FAR * This,
    /* [out][in] */ ULONG __RPC_FAR *pcColumns,
    /* [size_is][size_is][out] */ DBCOLUMNINFO __RPC_FAR *__RPC_FAR *prgInfo,
    /* [out] */ OLECHAR __RPC_FAR *__RPC_FAR *ppStringsBuffer);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IColumnsInfo_GetColumnInfo_Stub( 
    IColumnsInfo __RPC_FAR * This,
    /* [out][in] */ ULONG __RPC_FAR *pcColumns,
    /* [size_is][size_is][out] */ DBCOLUMNINFO __RPC_FAR *__RPC_FAR *prgInfo,
    /* [size_is][size_is][out] */ ULONG __RPC_FAR *__RPC_FAR *prgNameOffsets,
    /* [size_is][size_is][out] */ ULONG __RPC_FAR *__RPC_FAR *prgcolumnidOffsets,
    /* [out][in] */ ULONG __RPC_FAR *pcbStringsBuffer,
    /* [size_is][size_is][unique][out][in] */ OLECHAR __RPC_FAR *__RPC_FAR *ppStringsBuffer,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IColumnsInfo_MapColumnIDs_Proxy( 
    IColumnsInfo __RPC_FAR * This,
    /* [in] */ ULONG cColumnIDs,
    /* [size_is][in] */ const DBID __RPC_FAR rgColumnIDs[  ],
    /* [size_is][out] */ ULONG __RPC_FAR rgColumns[  ]);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IColumnsInfo_MapColumnIDs_Stub( 
    IColumnsInfo __RPC_FAR * This,
    /* [in] */ ULONG cColumnIDs,
    /* [size_is][in] */ const DBID __RPC_FAR *rgColumnIDs,
    /* [size_is][out] */ ULONG __RPC_FAR *rgColumns,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IDBCreateCommand_CreateCommand_Proxy( 
    IDBCreateCommand __RPC_FAR * This,
    /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
    /* [in] */ REFIID riid,
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppCommand);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IDBCreateCommand_CreateCommand_Stub( 
    IDBCreateCommand __RPC_FAR * This,
    /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
    /* [in] */ REFIID riid,
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppCommand,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IDBCreateSession_CreateSession_Proxy( 
    IDBCreateSession __RPC_FAR * This,
    /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
    /* [in] */ REFIID riid,
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppDBSession);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IDBCreateSession_CreateSession_Stub( 
    IDBCreateSession __RPC_FAR * This,
    /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
    /* [in] */ REFIID riid,
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppDBSession,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE ISourcesRowset_GetSourcesRowset_Proxy( 
    ISourcesRowset __RPC_FAR * This,
    /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
    /* [in] */ REFIID riid,
    /* [in] */ ULONG cPropertySets,
    /* [size_is][unique][out][in] */ DBPROPSET __RPC_FAR rgProperties[  ],
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppSourcesRowset);


/* [call_as] */ HRESULT STDMETHODCALLTYPE ISourcesRowset_GetSourcesRowset_Stub( 
    ISourcesRowset __RPC_FAR * This,
    /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
    /* [in] */ REFIID riid,
    /* [in] */ ULONG cPropertySets,
    /* [size_is][unique][in] */ DBPROPSET __RPC_FAR *rgProperties,
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppSourcesRowset,
    /* [in] */ ULONG cTotalProps,
    /* [size_is][out] */ DBPROPSTATUS __RPC_FAR *rgPropStatus,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IDBProperties_GetProperties_Proxy( 
    IDBProperties __RPC_FAR * This,
    /* [in] */ ULONG cPropertyIDSets,
    /* [size_is][in] */ const DBPROPIDSET __RPC_FAR rgPropertyIDSets[  ],
    /* [out][in] */ ULONG __RPC_FAR *pcPropertySets,
    /* [size_is][size_is][out] */ DBPROPSET __RPC_FAR *__RPC_FAR *prgPropertySets);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IDBProperties_GetProperties_Stub( 
    IDBProperties __RPC_FAR * This,
    /* [in] */ ULONG cPropertyIDSets,
    /* [size_is][unique][in] */ const DBPROPIDSET __RPC_FAR *rgPropertyIDSets,
    /* [out][in] */ ULONG __RPC_FAR *pcPropertySets,
    /* [size_is][size_is][out] */ DBPROPSET __RPC_FAR *__RPC_FAR *prgPropertySets,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IDBProperties_GetPropertyInfo_Proxy( 
    IDBProperties __RPC_FAR * This,
    /* [in] */ ULONG cPropertyIDSets,
    /* [size_is][in] */ const DBPROPIDSET __RPC_FAR rgPropertyIDSets[  ],
    /* [out][in] */ ULONG __RPC_FAR *pcPropertyInfoSets,
    /* [size_is][size_is][out] */ DBPROPINFOSET __RPC_FAR *__RPC_FAR *prgPropertyInfoSets,
    /* [out] */ OLECHAR __RPC_FAR *__RPC_FAR *ppDescBuffer);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IDBProperties_GetPropertyInfo_Stub( 
    IDBProperties __RPC_FAR * This,
    /* [in] */ ULONG cPropertyIDSets,
    /* [size_is][unique][in] */ const DBPROPIDSET __RPC_FAR *rgPropertyIDSets,
    /* [out][in] */ ULONG __RPC_FAR *pcPropertyInfoSets,
    /* [size_is][size_is][out] */ DBPROPINFOSET __RPC_FAR *__RPC_FAR *prgPropertyInfoSets,
    /* [out][in] */ ULONG __RPC_FAR *pcOffsets,
    /* [size_is][size_is][out] */ ULONG __RPC_FAR *__RPC_FAR *prgDescOffsets,
    /* [out][in] */ ULONG __RPC_FAR *pcbDescBuffer,
    /* [size_is][size_is][unique][out][in] */ OLECHAR __RPC_FAR *__RPC_FAR *ppDescBuffer,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IDBProperties_SetProperties_Proxy( 
    IDBProperties __RPC_FAR * This,
    /* [in] */ ULONG cPropertySets,
    /* [size_is][out][in] */ DBPROPSET __RPC_FAR rgPropertySets[  ]);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IDBProperties_SetProperties_Stub( 
    IDBProperties __RPC_FAR * This,
    /* [in] */ ULONG cPropertySets,
    /* [size_is][unique][in] */ DBPROPSET __RPC_FAR *rgPropertySets,
    /* [in] */ ULONG cTotalProps,
    /* [size_is][out] */ DBPROPSTATUS __RPC_FAR *rgPropStatus,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IDBInitialize_Initialize_Proxy( 
    IDBInitialize __RPC_FAR * This);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IDBInitialize_Initialize_Stub( 
    IDBInitialize __RPC_FAR * This,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IDBInitialize_Uninitialize_Proxy( 
    IDBInitialize __RPC_FAR * This);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IDBInitialize_Uninitialize_Stub( 
    IDBInitialize __RPC_FAR * This,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IDBInfo_GetKeywords_Proxy( 
    IDBInfo __RPC_FAR * This,
    /* [out] */ LPOLESTR __RPC_FAR *ppwszKeywords);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IDBInfo_GetKeywords_Stub( 
    IDBInfo __RPC_FAR * This,
    /* [unique][out][in] */ LPOLESTR __RPC_FAR *ppwszKeywords,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IDBInfo_GetLiteralInfo_Proxy( 
    IDBInfo __RPC_FAR * This,
    /* [in] */ ULONG cLiterals,
    /* [size_is][in] */ const DBLITERAL __RPC_FAR rgLiterals[  ],
    /* [out][in] */ ULONG __RPC_FAR *pcLiteralInfo,
    /* [size_is][size_is][out] */ DBLITERALINFO __RPC_FAR *__RPC_FAR *prgLiteralInfo,
    /* [out] */ OLECHAR __RPC_FAR *__RPC_FAR *ppCharBuffer);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IDBInfo_GetLiteralInfo_Stub( 
    IDBInfo __RPC_FAR * This,
    /* [in] */ ULONG cLiterals,
    /* [size_is][unique][in] */ const DBLITERAL __RPC_FAR *rgLiterals,
    /* [out][in] */ ULONG __RPC_FAR *pcLiteralInfo,
    /* [size_is][size_is][out] */ DBLITERALINFO __RPC_FAR *__RPC_FAR *prgLiteralInfo,
    /* [size_is][size_is][out] */ ULONG __RPC_FAR *__RPC_FAR *prgLVOffsets,
    /* [size_is][size_is][out] */ ULONG __RPC_FAR *__RPC_FAR *prgICOffsets,
    /* [size_is][size_is][out] */ ULONG __RPC_FAR *__RPC_FAR *prgISCOffsets,
    /* [out][in] */ ULONG __RPC_FAR *pcbCharBuffer,
    /* [size_is][size_is][unique][out][in] */ OLECHAR __RPC_FAR *__RPC_FAR *ppCharBuffer,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IDBDataSourceAdmin_CreateDataSource_Proxy( 
    IDBDataSourceAdmin __RPC_FAR * This,
    /* [in] */ ULONG cPropertySets,
    /* [size_is][out][in] */ DBPROPSET __RPC_FAR rgPropertySets[  ],
    /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
    /* [in] */ REFIID riid,
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppDBSession);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IDBDataSourceAdmin_CreateDataSource_Stub( 
    IDBDataSourceAdmin __RPC_FAR * This,
    /* [in] */ ULONG cPropertySets,
    /* [size_is][unique][in] */ DBPROPSET __RPC_FAR *rgPropertySets,
    /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
    /* [in] */ REFIID riid,
    /* [iid_is][unique][out][in] */ IUnknown __RPC_FAR *__RPC_FAR *ppDBSession,
    /* [in] */ ULONG cTotalProps,
    /* [size_is][out] */ DBPROPSTATUS __RPC_FAR *rgPropStatus,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IDBDataSourceAdmin_DestroyDataSource_Proxy( 
    IDBDataSourceAdmin __RPC_FAR * This);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IDBDataSourceAdmin_DestroyDataSource_Stub( 
    IDBDataSourceAdmin __RPC_FAR * This,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IDBDataSourceAdmin_GetCreationProperties_Proxy( 
    IDBDataSourceAdmin __RPC_FAR * This,
    /* [in] */ ULONG cPropertyIDSets,
    /* [size_is][in] */ const DBPROPIDSET __RPC_FAR rgPropertyIDSets[  ],
    /* [out][in] */ ULONG __RPC_FAR *pcPropertyInfoSets,
    /* [size_is][size_is][out] */ DBPROPINFOSET __RPC_FAR *__RPC_FAR *prgPropertyInfoSets,
    /* [out] */ OLECHAR __RPC_FAR *__RPC_FAR *ppDescBuffer);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IDBDataSourceAdmin_GetCreationProperties_Stub( 
    IDBDataSourceAdmin __RPC_FAR * This,
    /* [in] */ ULONG cPropertyIDSets,
    /* [size_is][unique][in] */ const DBPROPIDSET __RPC_FAR *rgPropertyIDSets,
    /* [out][in] */ ULONG __RPC_FAR *pcPropertyInfoSets,
    /* [size_is][size_is][out] */ DBPROPINFOSET __RPC_FAR *__RPC_FAR *prgPropertyInfoSets,
    /* [out][in] */ ULONG __RPC_FAR *pcOffsets,
    /* [size_is][size_is][out] */ ULONG __RPC_FAR *__RPC_FAR *prgDescOffsets,
    /* [out][in] */ ULONG __RPC_FAR *pcbDescBuffer,
    /* [size_is][size_is][unique][out][in] */ OLECHAR __RPC_FAR *__RPC_FAR *ppDescBuffer,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IDBDataSourceAdmin_ModifyDataSource_Proxy( 
    IDBDataSourceAdmin __RPC_FAR * This,
    /* [in] */ ULONG cPropertySets,
    /* [size_is][in] */ DBPROPSET __RPC_FAR rgPropertySets[  ]);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IDBDataSourceAdmin_ModifyDataSource_Stub( 
    IDBDataSourceAdmin __RPC_FAR * This,
    /* [in] */ ULONG cPropertySets,
    /* [size_is][in] */ DBPROPSET __RPC_FAR *rgPropertySets,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IDBAsynchNotify_OnLowResource_Proxy( 
    IDBAsynchNotify __RPC_FAR * This,
    /* [in] */ DWORD dwReserved);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IDBAsynchNotify_OnLowResource_Stub( 
    IDBAsynchNotify __RPC_FAR * This,
    /* [in] */ DWORD dwReserved,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IDBAsynchNotify_OnProgress_Proxy( 
    IDBAsynchNotify __RPC_FAR * This,
    /* [in] */ HCHAPTER hChapter,
    /* [in] */ DBASYNCHOP eOperation,
    /* [in] */ ULONG ulProgress,
    /* [in] */ ULONG ulProgressMax,
    /* [in] */ DBASYNCHPHASE eAsynchPhase,
    /* [in] */ LPOLESTR pwszStatusText);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IDBAsynchNotify_OnProgress_Stub( 
    IDBAsynchNotify __RPC_FAR * This,
    /* [in] */ HCHAPTER hChapter,
    /* [in] */ DBASYNCHOP eOperation,
    /* [in] */ ULONG ulProgress,
    /* [in] */ ULONG ulProgressMax,
    /* [in] */ DBASYNCHPHASE eAsynchPhase,
    /* [in] */ LPOLESTR pwszStatusText,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IDBAsynchNotify_OnStop_Proxy( 
    IDBAsynchNotify __RPC_FAR * This,
    /* [in] */ HCHAPTER hChapter,
    /* [in] */ DBASYNCHOP eOperation,
    /* [in] */ HRESULT hrStatus,
    /* [in] */ LPOLESTR pwszStatusText);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IDBAsynchNotify_OnStop_Stub( 
    IDBAsynchNotify __RPC_FAR * This,
    /* [in] */ HCHAPTER hChapter,
    /* [in] */ DBASYNCHOP eOperation,
    /* [in] */ HRESULT hrStatus,
    /* [in] */ LPOLESTR pwszStatusText,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IDBAsynchStatus_Abort_Proxy( 
    IDBAsynchStatus __RPC_FAR * This,
    /* [in] */ HCHAPTER hChapter,
    /* [in] */ DBASYNCHOP eOperation);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IDBAsynchStatus_Abort_Stub( 
    IDBAsynchStatus __RPC_FAR * This,
    /* [in] */ HCHAPTER hChapter,
    /* [in] */ DBASYNCHOP eOperation,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IDBAsynchStatus_GetStatus_Proxy( 
    IDBAsynchStatus __RPC_FAR * This,
    /* [in] */ HCHAPTER hChapter,
    /* [in] */ DBASYNCHOP eOperation,
    /* [out] */ ULONG __RPC_FAR *pulProgress,
    /* [out] */ ULONG __RPC_FAR *pulProgressMax,
    /* [out] */ DBASYNCHPHASE __RPC_FAR *peAsynchPhase,
    /* [out] */ LPOLESTR __RPC_FAR *ppwszStatusText);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IDBAsynchStatus_GetStatus_Stub( 
    IDBAsynchStatus __RPC_FAR * This,
    /* [in] */ HCHAPTER hChapter,
    /* [in] */ DBASYNCHOP eOperation,
    /* [out] */ ULONG __RPC_FAR *pulProgress,
    /* [out] */ ULONG __RPC_FAR *pulProgressMax,
    /* [out] */ DBASYNCHPHASE __RPC_FAR *peAsynchPhase,
    /* [out] */ LPOLESTR __RPC_FAR *ppwszStatusText,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE ISessionProperties_GetProperties_Proxy( 
    ISessionProperties __RPC_FAR * This,
    /* [in] */ ULONG cPropertyIDSets,
    /* [size_is][in] */ const DBPROPIDSET __RPC_FAR rgPropertyIDSets[  ],
    /* [out][in] */ ULONG __RPC_FAR *pcPropertySets,
    /* [size_is][size_is][out] */ DBPROPSET __RPC_FAR *__RPC_FAR *prgPropertySets);


/* [call_as] */ HRESULT STDMETHODCALLTYPE ISessionProperties_GetProperties_Stub( 
    ISessionProperties __RPC_FAR * This,
    /* [in] */ ULONG cPropertyIDSets,
    /* [size_is][unique][in] */ const DBPROPIDSET __RPC_FAR *rgPropertyIDSets,
    /* [out][in] */ ULONG __RPC_FAR *pcPropertySets,
    /* [size_is][size_is][out] */ DBPROPSET __RPC_FAR *__RPC_FAR *prgPropertySets,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE ISessionProperties_SetProperties_Proxy( 
    ISessionProperties __RPC_FAR * This,
    /* [in] */ ULONG cPropertySets,
    /* [size_is][unique][out][in] */ DBPROPSET __RPC_FAR rgPropertySets[  ]);


/* [call_as] */ HRESULT STDMETHODCALLTYPE ISessionProperties_SetProperties_Stub( 
    ISessionProperties __RPC_FAR * This,
    /* [in] */ ULONG cPropertySets,
    /* [size_is][unique][in] */ DBPROPSET __RPC_FAR *rgPropertySets,
    /* [in] */ ULONG cTotalProps,
    /* [size_is][out] */ DBPROPSTATUS __RPC_FAR *rgPropStatus,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IIndexDefinition_CreateIndex_Proxy( 
    IIndexDefinition __RPC_FAR * This,
    /* [in] */ DBID __RPC_FAR *pTableID,
    /* [in] */ DBID __RPC_FAR *pIndexID,
    /* [in] */ ULONG cIndexColumnDescs,
    /* [size_is][in] */ const DBINDEXCOLUMNDESC __RPC_FAR rgIndexColumnDescs[  ],
    /* [in] */ ULONG cPropertySets,
    /* [size_is][out][in] */ DBPROPSET __RPC_FAR rgPropertySets[  ],
    /* [out] */ DBID __RPC_FAR *__RPC_FAR *ppIndexID);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IIndexDefinition_CreateIndex_Stub( 
    IIndexDefinition __RPC_FAR * This,
    /* [in] */ DBID __RPC_FAR *pTableID,
    /* [unique][in] */ DBID __RPC_FAR *pIndexID,
    /* [in] */ ULONG cIndexColumnDescs,
    /* [size_is][in] */ const DBINDEXCOLUMNDESC __RPC_FAR *rgIndexColumnDescs,
    /* [in] */ ULONG cPropertySets,
    /* [size_is][unique][in] */ DBPROPSET __RPC_FAR *rgPropertySets,
    /* [unique][out][in] */ DBID __RPC_FAR *__RPC_FAR *ppIndexID,
    /* [in] */ ULONG cTotalProps,
    /* [size_is][out] */ DBPROPSTATUS __RPC_FAR *rgPropStatus,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IIndexDefinition_DropIndex_Proxy( 
    IIndexDefinition __RPC_FAR * This,
    /* [unique][in] */ DBID __RPC_FAR *pTableID,
    /* [unique][in] */ DBID __RPC_FAR *pIndexID);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IIndexDefinition_DropIndex_Stub( 
    IIndexDefinition __RPC_FAR * This,
    /* [unique][in] */ DBID __RPC_FAR *pTableID,
    /* [unique][in] */ DBID __RPC_FAR *pIndexID,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE ITableDefinition_CreateTable_Proxy( 
    ITableDefinition __RPC_FAR * This,
    /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
    /* [in] */ DBID __RPC_FAR *pTableID,
    /* [in] */ ULONG cColumnDescs,
    /* [size_is][in] */ const DBCOLUMNDESC __RPC_FAR rgColumnDescs[  ],
    /* [in] */ REFIID riid,
    /* [in] */ ULONG cPropertySets,
    /* [size_is][out][in] */ DBPROPSET __RPC_FAR rgPropertySets[  ],
    /* [out] */ DBID __RPC_FAR *__RPC_FAR *ppTableID,
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset);


/* [call_as] */ HRESULT STDMETHODCALLTYPE ITableDefinition_CreateTable_Stub( 
    ITableDefinition __RPC_FAR * This,
    /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
    /* [unique][in] */ DBID __RPC_FAR *pTableID,
    /* [in] */ ULONG cColumnDescs,
    /* [size_is][in] */ const DBCOLUMNDESC __RPC_FAR *rgColumnDescs,
    /* [in] */ REFIID riid,
    /* [in] */ ULONG cPropertySets,
    /* [size_is][unique][in] */ DBPROPSET __RPC_FAR *rgPropertySets,
    /* [unique][out][in] */ DBID __RPC_FAR *__RPC_FAR *ppTableID,
    /* [iid_is][unique][out][in] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset,
    /* [in] */ ULONG cTotalProps,
    /* [size_is][out] */ DBPROPSTATUS __RPC_FAR *rgPropStatus,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE ITableDefinition_DropTable_Proxy( 
    ITableDefinition __RPC_FAR * This,
    /* [unique][in] */ DBID __RPC_FAR *pTableID);


/* [call_as] */ HRESULT STDMETHODCALLTYPE ITableDefinition_DropTable_Stub( 
    ITableDefinition __RPC_FAR * This,
    /* [unique][in] */ DBID __RPC_FAR *pTableID,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE ITableDefinition_AddColumn_Proxy( 
    ITableDefinition __RPC_FAR * This,
    /* [in] */ DBID __RPC_FAR *pTableID,
    /* [out][in] */ DBCOLUMNDESC __RPC_FAR *pColumnDesc,
    /* [out] */ DBID __RPC_FAR *__RPC_FAR *ppColumnID);


/* [call_as] */ HRESULT STDMETHODCALLTYPE ITableDefinition_AddColumn_Stub( 
    ITableDefinition __RPC_FAR * This,
    /* [in] */ DBID __RPC_FAR *pTableID,
    /* [in] */ DBCOLUMNDESC __RPC_FAR *pColumnDesc,
    /* [unique][out][in] */ DBID __RPC_FAR *__RPC_FAR *ppColumnID,
    /* [in] */ ULONG cTotalProps,
    /* [size_is][out] */ DBPROPSTATUS __RPC_FAR *rgPropStatus,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE ITableDefinition_DropColumn_Proxy( 
    ITableDefinition __RPC_FAR * This,
    /* [unique][in] */ DBID __RPC_FAR *pTableID,
    /* [unique][in] */ DBID __RPC_FAR *pColumnID);


/* [call_as] */ HRESULT STDMETHODCALLTYPE ITableDefinition_DropColumn_Stub( 
    ITableDefinition __RPC_FAR * This,
    /* [unique][in] */ DBID __RPC_FAR *pTableID,
    /* [unique][in] */ DBID __RPC_FAR *pColumnID,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IOpenRowset_OpenRowset_Proxy( 
    IOpenRowset __RPC_FAR * This,
    /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
    /* [unique][in] */ DBID __RPC_FAR *pTableID,
    /* [unique][in] */ DBID __RPC_FAR *pIndexID,
    /* [in] */ REFIID riid,
    /* [in] */ ULONG cPropertySets,
    /* [size_is][out][in] */ DBPROPSET __RPC_FAR rgPropertySets[  ],
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IOpenRowset_OpenRowset_Stub( 
    IOpenRowset __RPC_FAR * This,
    /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
    /* [unique][in] */ DBID __RPC_FAR *pTableID,
    /* [unique][in] */ DBID __RPC_FAR *pIndexID,
    /* [in] */ REFIID riid,
    /* [in] */ ULONG cPropertySets,
    /* [size_is][unique][in] */ DBPROPSET __RPC_FAR *rgPropertySets,
    /* [iid_is][unique][out][in] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset,
    /* [in] */ ULONG cTotalProps,
    /* [size_is][out] */ DBPROPSTATUS __RPC_FAR *rgPropStatus,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IDBSchemaRowset_GetRowset_Proxy( 
    IDBSchemaRowset __RPC_FAR * This,
    /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
    /* [in] */ REFGUID rguidSchema,
    /* [in] */ ULONG cRestrictions,
    /* [size_is][in] */ const VARIANT __RPC_FAR rgRestrictions[  ],
    /* [in] */ REFIID riid,
    /* [in] */ ULONG cPropertySets,
    /* [size_is][unique][out][in] */ DBPROPSET __RPC_FAR rgPropertySets[  ],
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IDBSchemaRowset_GetRowset_Stub( 
    IDBSchemaRowset __RPC_FAR * This,
    /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
    /* [in] */ REFGUID rguidSchema,
    /* [in] */ ULONG cRestrictions,
    /* [size_is][unique][in] */ const VARIANT __RPC_FAR *rgRestrictions,
    /* [in] */ REFIID riid,
    /* [in] */ ULONG cPropertySets,
    /* [size_is][unique][in] */ DBPROPSET __RPC_FAR *rgPropertySets,
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset,
    /* [in] */ ULONG cTotalProps,
    /* [size_is][out] */ DBPROPSTATUS __RPC_FAR *rgPropStatus,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IDBSchemaRowset_GetSchemas_Proxy( 
    IDBSchemaRowset __RPC_FAR * This,
    /* [out][in] */ ULONG __RPC_FAR *pcSchemas,
    /* [size_is][size_is][out] */ GUID __RPC_FAR *__RPC_FAR *prgSchemas,
    /* [size_is][size_is][out] */ ULONG __RPC_FAR *__RPC_FAR *prgRestrictionSupport);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IDBSchemaRowset_GetSchemas_Stub( 
    IDBSchemaRowset __RPC_FAR * This,
    /* [out][in] */ ULONG __RPC_FAR *pcSchemas,
    /* [size_is][size_is][out] */ GUID __RPC_FAR *__RPC_FAR *prgSchemas,
    /* [size_is][size_is][out] */ ULONG __RPC_FAR *__RPC_FAR *prgRestrictionSupport,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IErrorRecords_AddErrorRecord_Proxy( 
    IErrorRecords __RPC_FAR * This,
    /* [in] */ ERRORINFO __RPC_FAR *pErrorInfo,
    /* [in] */ DWORD dwLookupID,
    /* [in] */ DISPPARAMS __RPC_FAR *pdispparams,
    /* [in] */ IUnknown __RPC_FAR *punkCustomError,
    /* [in] */ DWORD dwDynamicErrorID);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IErrorRecords_AddErrorRecord_Stub( 
    IErrorRecords __RPC_FAR * This,
    /* [in] */ ERRORINFO __RPC_FAR *pErrorInfo,
    /* [in] */ DWORD dwLookupID,
    /* [in] */ DISPPARAMS __RPC_FAR *pdispparams,
    /* [in] */ IUnknown __RPC_FAR *punkCustomError,
    /* [in] */ DWORD dwDynamicErrorID,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IErrorRecords_GetBasicErrorInfo_Proxy( 
    IErrorRecords __RPC_FAR * This,
    /* [in] */ ULONG ulRecordNum,
    /* [out] */ ERRORINFO __RPC_FAR *pErrorInfo);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IErrorRecords_GetBasicErrorInfo_Stub( 
    IErrorRecords __RPC_FAR * This,
    /* [in] */ ULONG ulRecordNum,
    /* [out] */ ERRORINFO __RPC_FAR *pErrorInfo,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IErrorRecords_GetCustomErrorObject_Proxy( 
    IErrorRecords __RPC_FAR * This,
    /* [in] */ ULONG ulRecordNum,
    /* [in] */ REFIID riid,
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppObject);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IErrorRecords_GetCustomErrorObject_Stub( 
    IErrorRecords __RPC_FAR * This,
    /* [in] */ ULONG ulRecordNum,
    /* [in] */ REFIID riid,
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppObject,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IErrorRecords_GetErrorInfo_Proxy( 
    IErrorRecords __RPC_FAR * This,
    /* [in] */ ULONG ulRecordNum,
    /* [in] */ LCID lcid,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfo);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IErrorRecords_GetErrorInfo_Stub( 
    IErrorRecords __RPC_FAR * This,
    /* [in] */ ULONG ulRecordNum,
    /* [in] */ LCID lcid,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfo,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IErrorRecords_GetErrorParameters_Proxy( 
    IErrorRecords __RPC_FAR * This,
    /* [in] */ ULONG ulRecordNum,
    /* [out] */ DISPPARAMS __RPC_FAR *pdispparams);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IErrorRecords_GetErrorParameters_Stub( 
    IErrorRecords __RPC_FAR * This,
    /* [in] */ ULONG ulRecordNum,
    /* [out] */ DISPPARAMS __RPC_FAR *pdispparams,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IErrorRecords_GetRecordCount_Proxy( 
    IErrorRecords __RPC_FAR * This,
    /* [out] */ ULONG __RPC_FAR *pcRecords);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IErrorRecords_GetRecordCount_Stub( 
    IErrorRecords __RPC_FAR * This,
    /* [out] */ ULONG __RPC_FAR *pcRecords,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IErrorLookup_GetErrorDescription_Proxy( 
    IErrorLookup __RPC_FAR * This,
    /* [in] */ HRESULT hrError,
    /* [in] */ DWORD dwLookupID,
    /* [in] */ DISPPARAMS __RPC_FAR *pdispparams,
    /* [in] */ LCID lcid,
    /* [out] */ BSTR __RPC_FAR *pbstrSource,
    /* [out] */ BSTR __RPC_FAR *pbstrDescription);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IErrorLookup_GetErrorDescription_Stub( 
    IErrorLookup __RPC_FAR * This,
    /* [in] */ HRESULT hrError,
    /* [in] */ DWORD dwLookupID,
    /* [in] */ DISPPARAMS __RPC_FAR *pdispparams,
    /* [in] */ LCID lcid,
    /* [out] */ BSTR __RPC_FAR *pbstrSource,
    /* [out] */ BSTR __RPC_FAR *pbstrDescription,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IErrorLookup_GetHelpInfo_Proxy( 
    IErrorLookup __RPC_FAR * This,
    /* [in] */ HRESULT hrError,
    /* [in] */ DWORD dwLookupID,
    /* [in] */ LCID lcid,
    /* [out] */ BSTR __RPC_FAR *pbstrHelpFile,
    /* [out] */ DWORD __RPC_FAR *pdwHelpContext);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IErrorLookup_GetHelpInfo_Stub( 
    IErrorLookup __RPC_FAR * This,
    /* [in] */ HRESULT hrError,
    /* [in] */ DWORD dwLookupID,
    /* [in] */ LCID lcid,
    /* [out] */ BSTR __RPC_FAR *pbstrHelpFile,
    /* [out] */ DWORD __RPC_FAR *pdwHelpContext,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IErrorLookup_ReleaseErrors_Proxy( 
    IErrorLookup __RPC_FAR * This,
    /* [in] */ const DWORD dwDynamicErrorID);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IErrorLookup_ReleaseErrors_Stub( 
    IErrorLookup __RPC_FAR * This,
    /* [in] */ const DWORD dwDynamicErrorID,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE ISQLErrorInfo_GetSQLInfo_Proxy( 
    ISQLErrorInfo __RPC_FAR * This,
    /* [out] */ BSTR __RPC_FAR *pbstrSQLState,
    /* [out] */ LONG __RPC_FAR *plNativeError);


/* [call_as] */ HRESULT STDMETHODCALLTYPE ISQLErrorInfo_GetSQLInfo_Stub( 
    ISQLErrorInfo __RPC_FAR * This,
    /* [out] */ BSTR __RPC_FAR *pbstrSQLState,
    /* [out] */ LONG __RPC_FAR *plNativeError,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IGetDataSource_GetDataSource_Proxy( 
    IGetDataSource __RPC_FAR * This,
    /* [in] */ REFIID riid,
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppDataSource);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IGetDataSource_GetDataSource_Stub( 
    IGetDataSource __RPC_FAR * This,
    /* [in] */ REFIID riid,
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppDataSource,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE ITransactionLocal_GetOptionsObject_Proxy( 
    ITransactionLocal __RPC_FAR * This,
    /* [out] */ ITransactionOptions __RPC_FAR *__RPC_FAR *ppOptions);


/* [call_as] */ HRESULT STDMETHODCALLTYPE ITransactionLocal_GetOptionsObject_Stub( 
    ITransactionLocal __RPC_FAR * This,
    /* [out] */ ITransactionOptions __RPC_FAR *__RPC_FAR *ppOptions,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE ITransactionLocal_StartTransaction_Proxy( 
    ITransactionLocal __RPC_FAR * This,
    /* [in] */ ISOLEVEL isoLevel,
    /* [in] */ ULONG isoFlags,
    /* [in] */ ITransactionOptions __RPC_FAR *pOtherOptions,
    /* [out] */ ULONG __RPC_FAR *pulTransactionLevel);


/* [call_as] */ HRESULT STDMETHODCALLTYPE ITransactionLocal_StartTransaction_Stub( 
    ITransactionLocal __RPC_FAR * This,
    /* [in] */ ISOLEVEL isoLevel,
    /* [in] */ ULONG isoFlags,
    /* [in] */ ITransactionOptions __RPC_FAR *pOtherOptions,
    /* [unique][out][in] */ ULONG __RPC_FAR *pulTransactionLevel,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE ITransactionJoin_GetOptionsObject_Proxy( 
    ITransactionJoin __RPC_FAR * This,
    /* [out] */ ITransactionOptions __RPC_FAR *__RPC_FAR *ppOptions);


/* [call_as] */ HRESULT STDMETHODCALLTYPE ITransactionJoin_GetOptionsObject_Stub( 
    ITransactionJoin __RPC_FAR * This,
    /* [out] */ ITransactionOptions __RPC_FAR *__RPC_FAR *ppOptions,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE ITransactionJoin_JoinTransaction_Proxy( 
    ITransactionJoin __RPC_FAR * This,
    /* [in] */ IUnknown __RPC_FAR *punkTransactionCoord,
    /* [in] */ ISOLEVEL isoLevel,
    /* [in] */ ULONG isoFlags,
    /* [in] */ ITransactionOptions __RPC_FAR *pOtherOptions);


/* [call_as] */ HRESULT STDMETHODCALLTYPE ITransactionJoin_JoinTransaction_Stub( 
    ITransactionJoin __RPC_FAR * This,
    /* [in] */ IUnknown __RPC_FAR *punkTransactionCoord,
    /* [in] */ ISOLEVEL isoLevel,
    /* [in] */ ULONG isoFlags,
    /* [in] */ ITransactionOptions __RPC_FAR *pOtherOptions,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE ITransactionObject_GetTransactionObject_Proxy( 
    ITransactionObject __RPC_FAR * This,
    /* [in] */ ULONG ulTransactionLevel,
    /* [out] */ ITransaction __RPC_FAR *__RPC_FAR *ppTransactionObject);


/* [call_as] */ HRESULT STDMETHODCALLTYPE ITransactionObject_GetTransactionObject_Stub( 
    ITransactionObject __RPC_FAR * This,
    /* [in] */ ULONG ulTransactionLevel,
    /* [out] */ ITransaction __RPC_FAR *__RPC_FAR *ppTransactionObject,
    /* [out] */ IErrorInfo __RPC_FAR *__RPC_FAR *ppErrorInfoRem);

/* [local] */ HRESULT STDMETHODCALLTYPE IScopedOperations_Copy_Proxy( 
    IScopedOperations __RPC_FAR * This,
    /* [in] */ ULONG cRows,
    /* [size_is][in] */ LPCOLESTR __RPC_FAR rgpwszSourceURLs[  ],
    /* [size_is][in] */ LPCOLESTR __RPC_FAR rgpwszDestURLs[  ],
    /* [in] */ DWORD dwCopyFlags,
    /* [unique][in] */ IAuthenticate __RPC_FAR *pAuthenticate,
    /* [size_is][out][in] */ DBSTATUS __RPC_FAR rgdwStatus[  ],
    /* [size_is][out] */ LPOLESTR __RPC_FAR rgpwszNewURLs[  ],
    /* [out] */ OLECHAR __RPC_FAR *__RPC_FAR *ppStringsBuffer);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IScopedOperations_Copy_Stub( 
    IScopedOperations __RPC_FAR * This,
    /* [in] */ ULONG cRows,
    /* [size_is][in] */ LPCOLESTR __RPC_FAR *rgpwszSourceURLs,
    /* [size_is][in] */ LPCOLESTR __RPC_FAR *rgpwszDestURLs,
    /* [in] */ DWORD dwCopyFlags,
    /* [in] */ IAuthenticate __RPC_FAR *pAuthenticate,
    /* [size_is][out] */ DBSTATUS __RPC_FAR *rgdwStatus,
    /* [size_is][size_is][out] */ ULONG __RPC_FAR *__RPC_FAR *prgulNewURLOffsets,
    /* [out][in] */ ULONG __RPC_FAR *pcbStringsBuffer,
    /* [size_is][size_is][unique][out][in] */ OLECHAR __RPC_FAR *__RPC_FAR *ppStringsBuffer);

/* [local] */ HRESULT STDMETHODCALLTYPE IScopedOperations_Move_Proxy( 
    IScopedOperations __RPC_FAR * This,
    /* [in] */ ULONG cRows,
    /* [size_is][in] */ LPCOLESTR __RPC_FAR rgpwszSourceURLs[  ],
    /* [size_is][in] */ LPCOLESTR __RPC_FAR rgpwszDestURLs[  ],
    /* [in] */ DWORD dwMoveFlags,
    /* [unique][in] */ IAuthenticate __RPC_FAR *pAuthenticate,
    /* [size_is][out][in] */ DBSTATUS __RPC_FAR rgdwStatus[  ],
    /* [size_is][out] */ LPOLESTR __RPC_FAR rgpwszNewURLs[  ],
    /* [out] */ OLECHAR __RPC_FAR *__RPC_FAR *ppStringsBuffer);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IScopedOperations_Move_Stub( 
    IScopedOperations __RPC_FAR * This,
    /* [in] */ ULONG cRows,
    /* [size_is][in] */ LPCOLESTR __RPC_FAR *rgpwszSourceURLs,
    /* [size_is][in] */ LPCOLESTR __RPC_FAR *rgpwszDestURLs,
    /* [in] */ DWORD dwMoveFlags,
    /* [in] */ IAuthenticate __RPC_FAR *pAuthenticate,
    /* [size_is][out] */ DBSTATUS __RPC_FAR *rgdwStatus,
    /* [size_is][size_is][out] */ ULONG __RPC_FAR *__RPC_FAR *prgulNewURLOffsets,
    /* [out][in] */ ULONG __RPC_FAR *pcbStringsBuffer,
    /* [size_is][size_is][unique][out][in] */ OLECHAR __RPC_FAR *__RPC_FAR *ppStringsBuffer);

/* [local] */ HRESULT STDMETHODCALLTYPE IScopedOperations_Delete_Proxy( 
    IScopedOperations __RPC_FAR * This,
    /* [in] */ ULONG cRows,
    /* [size_is][in] */ LPCOLESTR __RPC_FAR rgpwszURLs[  ],
    /* [in] */ DWORD dwDeleteFlags,
    /* [size_is][out][in] */ DBSTATUS __RPC_FAR rgdwStatus[  ]);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IScopedOperations_Delete_Stub( 
    IScopedOperations __RPC_FAR * This,
    /* [in] */ ULONG cRows,
    /* [size_is][in] */ LPCOLESTR __RPC_FAR *rgpwszURLs,
    /* [in] */ DWORD dwDeleteFlags,
    /* [size_is][out] */ DBSTATUS __RPC_FAR *rgdwStatus);

/* [local] */ HRESULT STDMETHODCALLTYPE IScopedOperations_OpenRowset_Proxy( 
    IScopedOperations __RPC_FAR * This,
    /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
    /* [unique][in] */ DBID __RPC_FAR *pTableID,
    /* [unique][in] */ DBID __RPC_FAR *pIndexID,
    /* [in] */ REFIID riid,
    /* [in] */ ULONG cPropertySets,
    /* [size_is][out][in] */ DBPROPSET __RPC_FAR rgPropertySets[  ],
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IScopedOperations_OpenRowset_Stub( 
    IScopedOperations __RPC_FAR * This,
    /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
    /* [unique][in] */ DBID __RPC_FAR *pTableID,
    /* [unique][in] */ DBID __RPC_FAR *pIndexID,
    /* [in] */ REFIID riid,
    /* [in] */ ULONG cPropertySets,
    /* [size_is][unique][in] */ DBPROPSET __RPC_FAR *rgPropertySets,
    /* [iid_is][unique][out][in] */ IUnknown __RPC_FAR *__RPC_FAR *ppRowset,
    /* [in] */ ULONG cTotalProps,
    /* [size_is][out] */ DBPROPSTATUS __RPC_FAR *rgPropStatus);

/* [local] */ HRESULT STDMETHODCALLTYPE IBindResource_Bind_Proxy( 
    IBindResource __RPC_FAR * This,
    /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
    /* [in] */ LPCOLESTR pwszURL,
    /* [in] */ DBBINDURLFLAG dwBindURLFlags,
    /* [in] */ REFGUID rguid,
    /* [in] */ REFIID riid,
    /* [in] */ IAuthenticate __RPC_FAR *pAuthenticate,
    /* [unique][out][in] */ DBIMPLICITSESSION __RPC_FAR *pImplSession,
    /* [out] */ DBBINDURLSTATUS __RPC_FAR *pdwBindStatus,
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppUnk);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IBindResource_Bind_Stub( 
    IBindResource __RPC_FAR * This,
    /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
    /* [in] */ LPCOLESTR pwszURL,
    /* [in] */ DBBINDURLFLAG dwBindURLFlags,
    /* [in] */ REFGUID rguid,
    /* [in] */ REFIID riid,
    /* [in] */ IAuthenticate __RPC_FAR *pAuthenticate,
    /* [unique][out][in] */ DBIMPLICITSESSION __RPC_FAR *pImplSession,
    /* [out] */ DBBINDURLSTATUS __RPC_FAR *pdwBindStatus,
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppUnk);

/* [local] */ HRESULT STDMETHODCALLTYPE ICreateRow_CreateRow_Proxy( 
    ICreateRow __RPC_FAR * This,
    /* [unique][in] */ IUnknown __RPC_FAR *pUnkOuter,
    /* [in] */ LPCOLESTR pwszURL,
    /* [in] */ DBBINDURLFLAG dwBindURLFlags,
    /* [in] */ REFGUID rguid,
    /* [in] */ REFIID riid,
    /* [unique][in] */ IAuthenticate __RPC_FAR *pAuthenticate,
    /* [unique][out][in] */ DBIMPLICITSESSION __RPC_FAR *pImplSession,
    /* [out][in] */ DBBINDURLSTATUS __RPC_FAR *pdwBindStatus,
    /* [out] */ LPOLESTR __RPC_FAR *ppwszNewURL,
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppUnk);


/* [call_as] */ HRESULT STDMETHODCALLTYPE ICreateRow_CreateRow_Stub( 
    ICreateRow __RPC_FAR * This,
    /* [in] */ IUnknown __RPC_FAR *pUnkOuter,
    /* [in] */ LPCOLESTR pwszURL,
    /* [in] */ DBBINDURLFLAG dwBindURLFlags,
    /* [in] */ REFGUID rguid,
    /* [in] */ REFIID riid,
    /* [in] */ IAuthenticate __RPC_FAR *pAuthenticate,
    /* [unique][out][in] */ DBIMPLICITSESSION __RPC_FAR *pImplSession,
    /* [out] */ DBBINDURLSTATUS __RPC_FAR *pdwBindStatus,
    /* [unique][out][in] */ LPOLESTR __RPC_FAR *ppwszNewURL,
    /* [iid_is][out] */ IUnknown __RPC_FAR *__RPC_FAR *ppUnk);

/* [local] */ HRESULT STDMETHODCALLTYPE IColumnsInfo2_GetRestrictedColumnInfo_Proxy( 
    IColumnsInfo2 __RPC_FAR * This,
    /* [in] */ ULONG cColumnIDMasks,
    /* [size_is][in] */ const DBID __RPC_FAR rgColumnIDMasks[  ],
    /* [in] */ DWORD dwFlags,
    /* [out][in] */ ULONG __RPC_FAR *pcColumns,
    /* [size_is][size_is][out] */ DBID __RPC_FAR *__RPC_FAR *prgColumnIDs,
    /* [size_is][size_is][out] */ DBCOLUMNINFO __RPC_FAR *__RPC_FAR *prgColumnInfo,
    /* [out] */ OLECHAR __RPC_FAR *__RPC_FAR *ppStringsBuffer);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IColumnsInfo2_GetRestrictedColumnInfo_Stub( 
    IColumnsInfo2 __RPC_FAR * This,
    /* [in] */ ULONG cColumnIDMasks,
    /* [size_is][unique][in] */ const DBID __RPC_FAR *rgColumnIDMasks,
    /* [in] */ DWORD dwFlags,
    /* [out][in] */ ULONG __RPC_FAR *pcColumns,
    /* [size_is][size_is][unique][out][in] */ DBID __RPC_FAR *__RPC_FAR *prgColumnIDs,
    /* [size_is][size_is][unique][out][in] */ DBCOLUMNINFO __RPC_FAR *__RPC_FAR *prgColumnInfo,
    /* [size_is][size_is][out] */ ULONG __RPC_FAR *__RPC_FAR *prgNameOffsets,
    /* [size_is][size_is][out] */ ULONG __RPC_FAR *__RPC_FAR *prgcolumnidOffsets,
    /* [out][in] */ ULONG __RPC_FAR *pcbStringsBuffer,
    /* [size_is][size_is][unique][out][in] */ OLECHAR __RPC_FAR *__RPC_FAR *ppStringsBuffer);

/* [local] */ HRESULT STDMETHODCALLTYPE IRegisterProvider_GetURLMapping_Proxy( 
    IRegisterProvider __RPC_FAR * This,
    /* [in] */ LPCOLESTR pwszURL,
    /* [in] */ DWORD dwReserved,
    /* [out] */ CLSID __RPC_FAR *pclsidProvider);


/* [call_as] */ HRESULT STDMETHODCALLTYPE IRegisterProvider_GetURLMapping_Stub( 
    IRegisterProvider __RPC_FAR * This,
    /* [in] */ LPCOLESTR pwszURL,
    /* [in] */ DWORD dwReserved,
    /* [out] */ CLSID __RPC_FAR *pclsidProvider);



#endif // OLEDBPROXY
/* end of Additional Prototypes */

/***************************************************************************
****************************************************************************
        SQL CE specific GUIDS, interfaces and properties
***************************************************************************
***************************************************************************/

#else // GUIDS_ONLY

#ifndef OLEDBDECLSPEC
#define OLEDBDECLSPEC
#endif

#endif //GUIDS_ONLY

/***************************************************************************
****************************************************************************
        SQL CE specific GUIDS
***************************************************************************
***************************************************************************/


// Microsoft SQL Server Lite for Windows 3.5 Provider (Microsoft.SQLSERVER.CE.OLEDB.3.5)
//
// {F49C559D-E9E5-467C-8C18-3326AAE4EBCC}
//
extern const OLEDBDECLSPEC GUID CLSID_SQLSERVERCE_3_5 = {0xf49c559d, 0xe9e5, 0x467c, {0x8c, 0x18, 0x33, 0x26, 0xaa, 0xe4, 0xeb, 0xcc}};
#define CLSID_SQLSERVERCE  CLSID_SQLSERVERCE_3_5


// PUBLISHED: Provider Specific Property Sets
//
// Provider-Specific DBInit Property Set
// {2B9AB5BA-4F6C-4ddd-BF18-24DD4BD41848}
//
extern const OLEDBDECLSPEC GUID DBPROPSET_SSCE_DBINIT = {0x2b9ab5ba, 0x4f6c, 0x4ddd, {0xbf, 0x18, 0x24, 0xdd, 0x4b, 0xd4, 0x18, 0x48}};

// Provider-Specific Column Property Set
// {352CC8D5-9181-11d3-B27B-00C04F68DBFF}
//
extern const OLEDBDECLSPEC GUID DBPROPSET_SSCE_COLUMN = {0x352cc8d5, 0x9181, 0x11d3, {0xb2, 0x7b, 0x0, 0xc0, 0x4f, 0x68, 0xdb, 0xff}};

// Provider-Specific Rowset Property Set
// {5C17C602-A107-11d3-B27B-00C04F68DBFF}
//
extern const OLEDBDECLSPEC GUID DBPROPSET_SSCE_ROWSET = {0x5c17c602, 0xa107, 0x11d3, {0xb2, 0x7b, 0x0, 0xc0, 0x4f, 0x68, 0xdb, 0xff}};

// Provider-Specific Session Property Set
// {22FE7D33-5E5C-4a45-B723-8BED2374A06B}
//
extern const OLEDBDECLSPEC GUID DBPROPSET_SSCE_SESSION = {0x22fe7d33, 0x5e5c, 0x4a45, {0xb7, 0x23, 0x8b, 0xed, 0x23, 0x74, 0xa0, 0x6b}};

#ifndef GUIDS_ONLY
// PUBLISHED Provider specific properties
//
#define DBPROP_SSCE_COL_ROWGUID                     0x1F9L      // SSCE_COLUMN
#define DBPROP_SSCE_MAXBUFFERSIZE                   0x1FAL      // SSCE_DBINIT
#define DBPROP_SSCE_DBPASSWORD                      0x1FBL      // SSCE_DBINIT
#define DBPROP_SSCE_ENCRYPTDATABASE                 0x1FCL      // SSCE_DBINIT
#define DBPROP_SSCE_DEFAULT_LOCK_ESCALATION         0x1FDL      // SSCE_DBINIT
#define DBPROP_SSCE_TEMPFILE_DIRECTORY              0x1FEL      // SSCE_DBINIT
#define DBPROP_SSCE_DEFAULT_LOCK_TIMEOUT            0x1FFL      // SSCE_DBINIT
#define DBPROP_SSCE_TRANSACTION_COMMIT_MODE         0x200L      // SSCE_SESSION
#define DBPROP_SSCE_LOCK_TIMEOUT                    0x201L      // SSCE_SESSION
#define DBPROP_SSCE_AUTO_SHRINK_THRESHOLD           0x202L      // SSCE_DBINIT
#define DBPROP_SSCE_FLUSH_INTERVAL                  0x206L      // SSCE_DBINIT
#define DBPROP_SSCE_MAX_DATABASE_SIZE               0x20BL      // SSCE_DBINIT
#define DBPROP_SSCE_LOCK_ESCALATION                 0x20CL      // SSCE_SESSION
#define DBPROP_SSCE_LOCK_HINT                       0x20DL      // SSCE_ROWSET
#define DBPROP_SSCE_TEMPFILE_MAX_SIZE               0x20EL      // SSCE_DBINIT
#define DBPROP_SSCE_ENCRYPTIONMODE                  0x20FL      // SSCE_DBINIT

// Enumeration values for DBPROP_SSCE_LOCK_HINT:
//
#define DBPROPVAL_SSCE_LH_ROWLOCK                   0x0001L     // Row-level locking
#define DBPROPVAL_SSCE_LH_PAGLOCK                   0x0002L     // Page-level locking
#define DBPROPVAL_SSCE_LH_TABLOCK                   0x0004L     // Table-level locking
#define DBPROPVAL_SSCE_LH_DBLOCK                    0x0008L     // Database-level locking
#define DBPROPVAL_SSCE_LH_NOLOCK                    0x0010L     // No lock option
#define DBPROPVAL_SSCE_LH_HOLDLOCK                  0x0020L     // Hold lock option
#define DBPROPVAL_SSCE_LH_UPDLOCK                   0x0040L     // Update lock type
#define DBPROPVAL_SSCE_LH_XLOCK                     0x0080L     // Exclusive lock type

// Enumeration values for DBPROP_SSCE_TRANSACTION_COMMIT_MODE:
//
#define DBPROPVAL_SSCE_TCM_DEFAULT                  0x0000L    // Asynchronously commit transactions to disk
#define DBPROPVAL_SSCE_TCM_FLUSH                    0x0001L    // Synchronously commit transactions to disk

// Enumeration values for DBPROP_SSCE_DBENCRYPTIONMODE
//
#define DBPROPVAL_SSCE_EM_INVALID                   0x0000L
#define DBPROPVAL_SSCE_EM_PLATFORM_DEFAULT          0x0001L    // (Default) Best algorithm available on the platform
#define DBPROPVAL_SSCE_EM_ENGINE_DEFAULT            0x0002L    // AES128/SHA1
#define DBPROPVAL_SSCE_EM_PPC2003_COMPAT            0x0003L    // 3DES/SHA1

// Bit mask specifying which properties in DBPROPSET_SSCE_DBINIT 
// were not honored when creating / opening the data source. This
// bit mask is returned as the first parameter in the error object 
// if the minor error code is SSCE_M_INITPROPCONFLICT
//
#define SSCE_DBINIT_CONFLICT_MAXBUFFERSIZE          (0x00000001)
#define SSCE_DBINIT_CONFLICT_AUTO_SHRINK_THRESHOLD  (0x00000004)
#define SSCE_DBINIT_CONFLICT_FLUSH_INTERVAL         (0x00000008)
#define SSCE_DBINIT_CONFLICT_MAX_DATABASE_SIZE      (0x00000020)
#define SSCE_DBINIT_CONFLICT_TEMPFILE_DIRECTORY     (0x00000040)
#define SSCE_DBINIT_CONFLICT_DEFAULTESCALATION      (0x00000080)
#define SSCE_DBINIT_CONFLICT_DEFAULTTIMEOUT         (0x00000100)
#define SSCE_DBINIT_CONFLICT_MAX_TMPDB_SIZE         (0x00000200)

// PUBLISHED: Provider Specific Interfaces
//
// IID_ISSCECompact
//
// NOTE: removed as per raid 9395
//
#if 0
extern const OLEDBDECLSPEC GUID IID_ISSCECompact     = {0x35437031,0x85a0,0x11d3,{0x88,0xc4,0x00,0xc0,0x4f,0xd9,0x37,0xf0}};
class ISSCECompact : public IUnknown
{
public:
    virtual HRESULT STDMETHODCALLTYPE Compact( 
        /* [in] */ ULONG cPropertySets,
        /* [size_is][out][in] */ DBPROPSET __RPC_FAR rgPropertySets[  ]) = 0;
};
#endif

// PUBLISHED: OLEDB 2.6 Specific Properties
//
#define DBPROP_COL_SEED                             0x11AL  
#define DBPROP_COL_INCREMENT                        0x11BL
#define DBPROP_IRowsetBookmark                      0x124L

// PUBLISHED: OLEDB 2.6 Defined Rowset Interfaces
//
// Interface: IRowsetBookmark
//
extern const OLEDBDECLSPEC IID IID_IRowsetBookmark = {0x0c733ac2,0x2a1c,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
class IRowsetBookmark : public IUnknown
{
public:
    virtual /* [local] */ HRESULT STDMETHODCALLTYPE PositionOnBookmark( 
            /* [in] */ HCHAPTER hChapter,
            /* [in] */ ULONG cbBookmark,
            /* [size_is][in] */ const BYTE __RPC_FAR *pBookmark) = 0;
};

// Interface: IRowsetPosition
//
extern const OLEDBDECLSPEC IID IID_IRowsetPosition = {0xc19f4b47,0xab5e,0x49a9,{0x9f,0x2e,0xab,0x7a,0xb5,0xc5,0x59,0x14}};
class IRowsetPosition : public IUnknown
{
public:
    virtual HRESULT STDMETHODCALLTYPE GetRecordCount( 
        /* [in] */ HCHAPTER hChapter,
        /* [out] */ ULONG * pcRows) = 0;

    virtual HRESULT STDMETHODCALLTYPE GetCurrentPosition( 
        /* [in] */ HCHAPTER hChapter,
        /* [out] */ ULONG * pulPosition) = 0;
};

/*********************************************************************/

#ifdef __cplusplus
}
#endif

#endif // GUIDS_ONLY

#endif // of ! __SQLCE_OLEDB_H__

<file_sep>/7-Zip/CPP/7zip/Archive/XarHandler.cpp
// XarHandler.cpp

#include "StdAfx.h"

#include "../../../C/CpuArch.h"

#include "Common/ComTry.h"
#include "Common/MyXml.h"
#include "Common/StringToInt.h"
#include "Common/UTFConvert.h"

#include "Windows/PropVariant.h"
#include "Windows/Time.h"

#include "../Common/LimitedStreams.h"
#include "../Common/ProgressUtils.h"
#include "../Common/RegisterArc.h"
#include "../Common/StreamObjects.h"
#include "../Common/StreamUtils.h"

#include "../Compress/BZip2Decoder.h"
#include "../Compress/CopyCoder.h"
#include "../Compress/ZlibDecoder.h"

#include "Common/OutStreamWithSha1.h"

#define XAR_SHOW_RAW

#define Get16(p) GetBe16(p)
#define Get32(p) GetBe32(p)
#define Get64(p) GetBe64(p)

namespace NArchive {
namespace NXar {

struct CFile
{
  AString Name;
  AString Method;
  UInt64 Size;
  UInt64 PackSize;
  UInt64 Offset;
  
  // UInt32 mode;
  UInt64 CTime;
  UInt64 MTime;
  UInt64 ATime;
  
  bool IsDir;
  bool HasData;

  bool Sha1IsDefined;
  Byte Sha1[20];
  // bool packSha1IsDefined;
  // Byte packSha1[20];

  int Parent;

  CFile(): IsDir(false), HasData(false), Sha1IsDefined(false),
    /* packSha1IsDefined(false), */
    Parent(-1), Size(0), PackSize(0), CTime(0), MTime(0), ATime(0) {}
};

class CHandler:
  public IInArchive,
  public CMyUnknownImp
{
  UInt64 _dataStartPos;
  CMyComPtr<IInStream> _inStream;
  AString _xml;
  CObjectVector<CFile> _files;

  HRESULT Open2(IInStream *stream);
  HRESULT Extract(IInStream *stream);
public:
  MY_UNKNOWN_IMP1(IInArchive)
  INTERFACE_IInArchive(;)
};

const UInt32 kXmlSizeMax = ((UInt32)1 << 30) - (1 << 14);

STATPROPSTG kProps[] =
{
  { NULL, kpidPath, VT_BSTR},
  { NULL, kpidSize, VT_UI8},
  { NULL, kpidPackSize, VT_UI8},
  { NULL, kpidMTime, VT_FILETIME},
  { NULL, kpidCTime, VT_FILETIME},
  { NULL, kpidATime, VT_FILETIME},
  { NULL, kpidMethod, VT_BSTR}
};

IMP_IInArchive_Props
IMP_IInArchive_ArcProps_NO

static bool ParseNumber(const char *s, int size, UInt32 &res)
{
  const char *end;
  res = (UInt32)ConvertStringToUInt64(s, &end);
  return (end - s == size);
}

static bool ParseUInt64(const CXmlItem &item, const char *name, UInt64 &res)
{
  AString s = item.GetSubStringForTag(name);
  const char *end;
  res = ConvertStringToUInt64(s, &end);
  return (end - (const char *)s == s.Length());
}

static UInt64 ParseTime(const CXmlItem &item, const char *name)
{
  AString s = item.GetSubStringForTag(name);
  if (s.Length() < 20)
    return 0;
  const char *p = s;
  if (p[ 4] != '-' || p[ 7] != '-' || p[10] != 'T' ||
      p[13] != ':' || p[16] != ':' || p[19] != 'Z')
    return 0;
  UInt32 year, month, day, hour, min, sec;
  if (!ParseNumber(p,      4, year )) return 0;
  if (!ParseNumber(p + 5,  2, month)) return 0;
  if (!ParseNumber(p + 8,  2, day  )) return 0;
  if (!ParseNumber(p + 11, 2, hour )) return 0;
  if (!ParseNumber(p + 14, 2, min  )) return 0;
  if (!ParseNumber(p + 17, 2, sec  )) return 0;
  
  UInt64 numSecs;
  if (!NWindows::NTime::GetSecondsSince1601(year, month, day, hour, min, sec, numSecs))
    return 0;
  return numSecs * 10000000;
}

static bool HexToByte(char c, Byte &res)
{
  if      (c >= '0' && c <= '9') res = c - '0';
  else if (c >= 'A' && c <= 'F') res = c - 'A' + 10;
  else if (c >= 'a' && c <= 'f') res = c - 'a' + 10;
  else return false;
  return true;
}

#define METHOD_NAME_ZLIB "zlib"

static bool ParseSha1(const CXmlItem &item, const char *name, Byte *digest)
{
  int index = item.FindSubTag(name);
  if (index  < 0)
    return false;
  const CXmlItem &checkItem = item.SubItems[index];
  AString style = checkItem.GetPropertyValue("style");
  if (style == "SHA1")
  {
    AString s = checkItem.GetSubString();
    if (s.Length() != 40)
      return false;
    for (int i = 0; i < s.Length(); i += 2)
    {
      Byte b0, b1;
      if (!HexToByte(s[i], b0) || !HexToByte(s[i + 1], b1))
        return false;
      digest[i / 2] = (b0 << 4) | b1;
    }
    return true;
  }
  return false;
}

static bool AddItem(const CXmlItem &item, CObjectVector<CFile> &files, int parent)
{
  if (!item.IsTag)
    return true;
  if (item.Name == "file")
  {
    CFile file;
    file.Parent = parent;
    parent = files.Size();
    file.Name = item.GetSubStringForTag("name");
    AString type = item.GetSubStringForTag("type");
    if (type == "directory")
      file.IsDir = true;
    else if (type == "file")
      file.IsDir = false;
    else
      return false;

    int dataIndex = item.FindSubTag("data");
    if (dataIndex >= 0 && !file.IsDir)
    {
      file.HasData = true;
      const CXmlItem &dataItem = item.SubItems[dataIndex];
      if (!ParseUInt64(dataItem, "size", file.Size))
        return false;
      if (!ParseUInt64(dataItem, "length", file.PackSize))
        return false;
      if (!ParseUInt64(dataItem, "offset", file.Offset))
        return false;
      file.Sha1IsDefined = ParseSha1(dataItem, "extracted-checksum", file.Sha1);
      // file.packSha1IsDefined = ParseSha1(dataItem, "archived-checksum",  file.packSha1);
      int encodingIndex = dataItem.FindSubTag("encoding");
      if (encodingIndex >= 0)
      {
        const CXmlItem &encodingItem = dataItem.SubItems[encodingIndex];
        if (encodingItem.IsTag)
        {
          AString s = encodingItem.GetPropertyValue("style");
          if (s.Length() >= 0)
          {
            AString appl = "application/";
            if (s.Left(appl.Length()) == appl)
            {
              s = s.Mid(appl.Length());
              AString xx = "x-";
              if (s.Left(xx.Length()) == xx)
              {
                s = s.Mid(xx.Length());
                if (s == "gzip")
                  s = METHOD_NAME_ZLIB;
              }
            }
            file.Method = s;
          }
        }
      }
    }

    file.CTime = ParseTime(item, "ctime");
    file.MTime = ParseTime(item, "mtime");
    file.ATime = ParseTime(item, "atime");
    files.Add(file);
  }
  for (int i = 0; i < item.SubItems.Size(); i++)
    if (!AddItem(item.SubItems[i], files, parent))
      return false;
  return true;
}

HRESULT CHandler::Open2(IInStream *stream)
{
  UInt64 archiveStartPos;
  RINOK(stream->Seek(0, STREAM_SEEK_SET, &archiveStartPos));

  const UInt32 kHeaderSize = 0x1C;
  Byte buf[kHeaderSize];
  RINOK(ReadStream_FALSE(stream, buf, kHeaderSize));

  UInt32 size = Get16(buf + 4);
  // UInt32 ver = Get16(buf + 6); // == 0
  if (Get32(buf) != 0x78617221 || size != kHeaderSize)
    return S_FALSE;

  UInt64 packSize = Get64(buf + 8);
  UInt64 unpackSize = Get64(buf + 0x10);
  // UInt32 checkSumAlogo = Get32(buf + 0x18);

  if (unpackSize >= kXmlSizeMax)
    return S_FALSE;

  _dataStartPos = archiveStartPos + kHeaderSize + packSize;

  char *ss = _xml.GetBuffer((int)unpackSize + 1);

  NCompress::NZlib::CDecoder *zlibCoderSpec = new NCompress::NZlib::CDecoder();
  CMyComPtr<ICompressCoder> zlibCoder = zlibCoderSpec;

  CLimitedSequentialInStream *inStreamLimSpec = new CLimitedSequentialInStream;
  CMyComPtr<ISequentialInStream> inStreamLim(inStreamLimSpec);
  inStreamLimSpec->SetStream(stream);
  inStreamLimSpec->Init(packSize);

  CSequentialOutStreamImp2 *outStreamLimSpec = new CSequentialOutStreamImp2;
  CMyComPtr<ISequentialOutStream> outStreamLim(outStreamLimSpec);
  outStreamLimSpec->Init((Byte *)ss, (size_t)unpackSize);

  RINOK(zlibCoder->Code(inStreamLim, outStreamLim, NULL, NULL, NULL));

  if (outStreamLimSpec->GetPos() != (size_t)unpackSize)
    return S_FALSE;

  ss[(size_t)unpackSize] = 0;
  _xml.ReleaseBuffer();

  CXml xml;
  if (!xml.Parse(_xml))
    return S_FALSE;
  
  if (!xml.Root.IsTagged("xar") || xml.Root.SubItems.Size() != 1)
    return S_FALSE;
  const CXmlItem &toc = xml.Root.SubItems[0];
  if (!toc.IsTagged("toc"))
    return S_FALSE;
  if (!AddItem(toc, _files, -1))
    return S_FALSE;
  return S_OK;
}

STDMETHODIMP CHandler::Open(IInStream *stream,
    const UInt64 * /* maxCheckStartPosition */,
    IArchiveOpenCallback * /* openArchiveCallback */)
{
  COM_TRY_BEGIN
  {
    Close();
    if (Open2(stream) != S_OK)
      return S_FALSE;
    _inStream = stream;
  }
  return S_OK;
  COM_TRY_END
}

STDMETHODIMP CHandler::Close()
{
  _inStream.Release();
  _files.Clear();
  _xml.Empty();
  return S_OK;
}

STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
{
  *numItems = _files.Size()
    #ifdef XAR_SHOW_RAW
    + 1
    #endif
  ;
  return S_OK;
}

static void TimeToProp(UInt64 t, NWindows::NCOM::CPropVariant &prop)
{
  if (t != 0)
  {
    FILETIME ft;
    ft.dwLowDateTime = (UInt32)(t);
    ft.dwHighDateTime = (UInt32)(t >> 32);
    prop = ft;
  }
}

STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
{
  COM_TRY_BEGIN
  NWindows::NCOM::CPropVariant prop;
  
  #ifdef XAR_SHOW_RAW
  if ((int)index == _files.Size())
  {
    switch(propID)
    {
      case kpidPath: prop = L"[TOC].xml"; break;
      case kpidSize:
      case kpidPackSize: prop = (UInt64)_xml.Length(); break;
    }
  }
  else
  #endif
  {
    const CFile &item = _files[index];
    switch(propID)
    {
      case kpidMethod:
      {
        UString name;
        if (!item.Method.IsEmpty() && ConvertUTF8ToUnicode(item.Method, name))
          prop = name;
        break;
      }
      case kpidPath:
      {
        AString path;
        int cur = index;
        do
        {
          const CFile &item = _files[cur];
          AString s = item.Name;
          if (s.IsEmpty())
            s = "unknown";
          if (path.IsEmpty())
            path = s;
          else
            path = s + CHAR_PATH_SEPARATOR + path;
          cur = item.Parent;
        }
        while (cur >= 0);

        UString name;
        if (ConvertUTF8ToUnicode(path, name))
          prop = name;
        break;
      }
      
      case kpidIsDir:  prop = item.IsDir; break;
      case kpidSize:      if (!item.IsDir) prop = item.Size; break;
      case kpidPackSize:  if (!item.IsDir) prop = item.PackSize; break;
      
      case kpidMTime:  TimeToProp(item.MTime, prop); break;
      case kpidCTime:  TimeToProp(item.CTime, prop); break;
      case kpidATime:  TimeToProp(item.ATime, prop); break;
    }
  }
  prop.Detach(value);
  return S_OK;
  COM_TRY_END
}

STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
    Int32 testMode, IArchiveExtractCallback *extractCallback)
{
  COM_TRY_BEGIN
  bool allFilesMode = (numItems == (UInt32)-1);
  if (allFilesMode)
    numItems = _files.Size();
  if (numItems == 0)
    return S_OK;
  UInt64 totalSize = 0;
  UInt32 i;
  for (i = 0; i < numItems; i++)
  {
    int index = (int)(allFilesMode ? i : indices[i]);
    #ifdef XAR_SHOW_RAW
    if (index == _files.Size())
      totalSize += _xml.Length();
    else
    #endif
      totalSize += _files[index].Size;
  }
  extractCallback->SetTotal(totalSize);

  UInt64 currentPackTotal = 0;
  UInt64 currentUnpTotal = 0;
  UInt64 currentPackSize = 0;
  UInt64 currentUnpSize = 0;

  const UInt32 kZeroBufSize = (1 << 14);
  CByteBuffer zeroBuf;
  zeroBuf.SetCapacity(kZeroBufSize);
  memset(zeroBuf, 0, kZeroBufSize);
  
  NCompress::CCopyCoder *copyCoderSpec = new NCompress::CCopyCoder();
  CMyComPtr<ICompressCoder> copyCoder = copyCoderSpec;

  NCompress::NZlib::CDecoder *zlibCoderSpec = new NCompress::NZlib::CDecoder();
  CMyComPtr<ICompressCoder> zlibCoder = zlibCoderSpec;
  
  NCompress::NBZip2::CDecoder *bzip2CoderSpec = new NCompress::NBZip2::CDecoder();
  CMyComPtr<ICompressCoder> bzip2Coder = bzip2CoderSpec;

  NCompress::NDeflate::NDecoder::CCOMCoder *deflateCoderSpec = new NCompress::NDeflate::NDecoder::CCOMCoder();
  CMyComPtr<ICompressCoder> deflateCoder = deflateCoderSpec;

  CLocalProgress *lps = new CLocalProgress;
  CMyComPtr<ICompressProgressInfo> progress = lps;
  lps->Init(extractCallback, false);

  CLimitedSequentialInStream *inStreamSpec = new CLimitedSequentialInStream;
  CMyComPtr<ISequentialInStream> inStream(inStreamSpec);
  inStreamSpec->SetStream(_inStream);

  
  CLimitedSequentialOutStream *outStreamLimSpec = new CLimitedSequentialOutStream;
  CMyComPtr<ISequentialOutStream> outStream(outStreamLimSpec);

  COutStreamWithSha1 *outStreamSha1Spec = new COutStreamWithSha1;
  {
    CMyComPtr<ISequentialOutStream> outStreamSha1(outStreamSha1Spec);
    outStreamLimSpec->SetStream(outStreamSha1);
  }

  for (i = 0; i < numItems; i++, currentPackTotal += currentPackSize, currentUnpTotal += currentUnpSize)
  {
    lps->InSize = currentPackTotal;
    lps->OutSize = currentUnpTotal;
    currentPackSize = 0;
    currentUnpSize = 0;
    RINOK(lps->SetCur());
    CMyComPtr<ISequentialOutStream> realOutStream;
    Int32 askMode = testMode ?
        NExtract::NAskMode::kTest :
        NExtract::NAskMode::kExtract;
    Int32 index = allFilesMode ? i : indices[i];
    RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
    
    if (index < _files.Size())
    {
      const CFile &item = _files[index];
      if (item.IsDir)
      {
        RINOK(extractCallback->PrepareOperation(askMode));
        RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kOK));
        continue;
      }
    }

    if (!testMode && !realOutStream)
      continue;
    RINOK(extractCallback->PrepareOperation(askMode));

    outStreamSha1Spec->SetStream(realOutStream);
    realOutStream.Release();

    Int32 opRes = NExtract::NOperationResult::kOK;
    #ifdef XAR_SHOW_RAW
    if (index == _files.Size())
    {
      outStreamSha1Spec->Init(false);
      outStreamLimSpec->Init(_xml.Length());
      RINOK(WriteStream(outStream, (const char *)_xml, _xml.Length()));
      currentPackSize = currentUnpSize = _xml.Length();
    }
    else
    #endif
    {
      const CFile &item = _files[index];
      if (item.HasData)
      {
        currentPackSize = item.PackSize;
        currentUnpSize = item.Size;
        
        RINOK(_inStream->Seek(_dataStartPos + item.Offset, STREAM_SEEK_SET, NULL));
        inStreamSpec->Init(item.PackSize);
        outStreamSha1Spec->Init(item.Sha1IsDefined);
        outStreamLimSpec->Init(item.Size);
        HRESULT res = S_OK;
        
        ICompressCoder *coder = NULL;
        if (item.Method.IsEmpty() || item.Method == "octet-stream")
          if (item.PackSize == item.Size)
            coder = copyCoder;
          else
            opRes = NExtract::NOperationResult::kUnSupportedMethod;
        else if (item.Method == METHOD_NAME_ZLIB)
          coder = zlibCoder;
        else if (item.Method == "bzip2")
          coder = bzip2Coder;
        else
          opRes = NExtract::NOperationResult::kUnSupportedMethod;
        
        if (coder)
          res = coder->Code(inStream, outStream, NULL, NULL, progress);
        
        if (res != S_OK)
        {
          if (!outStreamLimSpec->IsFinishedOK())
            opRes = NExtract::NOperationResult::kDataError;
          else if (res != S_FALSE)
            return res;
          if (opRes == NExtract::NOperationResult::kOK)
            opRes = NExtract::NOperationResult::kDataError;
        }

        if (opRes == NExtract::NOperationResult::kOK)
        {
          if (outStreamLimSpec->IsFinishedOK() &&
              outStreamSha1Spec->GetSize() == item.Size)
          {
            if (!outStreamLimSpec->IsFinishedOK())
            {
              opRes = NExtract::NOperationResult::kDataError;
            }
            else if (item.Sha1IsDefined)
            {
              Byte digest[NCrypto::NSha1::kDigestSize];
              outStreamSha1Spec->Final(digest);
              if (memcmp(digest, item.Sha1, NCrypto::NSha1::kDigestSize) != 0)
                opRes = NExtract::NOperationResult::kCRCError;
            }
          }
          else
            opRes = NExtract::NOperationResult::kDataError;
        }
      }
    }
    outStreamSha1Spec->ReleaseStream();
    RINOK(extractCallback->SetOperationResult(opRes));
  }
  return S_OK;
  COM_TRY_END
}

static IInArchive *CreateArc() { return new NArchive::NXar::CHandler; }

static CArcInfo g_ArcInfo =
  { L"Xar", L"xar", 0, 0xE1, { 'x', 'a', 'r', '!', 0, 0x1C }, 6, false, CreateArc, 0 };

REGISTER_ARC(Xar)

}}
<file_sep>/FingerSuite/Common/atlcplapplet.h
#ifndef __ATLCPLAPPLET_H__
#define __ATLCPLAPPLET_H__

/////////////////////////////////////////////////////////////////////////////
// atlcplapplet.h - Control Panel applet
//
// Written by <NAME> (<EMAIL>)
// Copyright (c) 2007 <NAME>.
//
// This code may be used in compiled form in any way you desire. This
// source file may be redistributed by any means PROVIDING it is 
// not sold for profit without the authors written consent, and 
// providing that this notice and the authors name is included. 
//
// This file is provided "as is" with no expressed or implied warranty.
// The author accepts no liability if it causes any damage to you or your
// computer whatsoever. It's free, so don't hassle me about it.
//
// Beware of bugs.
//

#pragma once

#ifndef __cplusplus
   #error ATL requires C++ compilation (use a .cpp suffix)
#endif

#ifndef __ATLAPP_H__
   #error atlcplapplet.h requires atlapp.h to be included first
#endif


#include <cpl.h>


typedef struct tagATLCPLAPPLETREG
{
   int iIndex;
   BOOL bOnlyCurrentUser;
   DWORD dwCategory;
   DWORD dwRunLevel;
   UINT uTaskRegID;
} ATLCPLAPPLETREG;


#define DECLARE_APPLET_CATEGORY(x)  enum { APPLET_CATEGORY = x };

#define DECLARE_APPLET_RUNLEVEL(x)  enum { APPLET_RUNLEVEL = x };

#define DECLARE_APPLET_RESOURCEID(x)  enum { APPLET_TASK_REGISTRYID = x };


typedef struct tagATLCPLAPPLETINFO
{
   LPCTSTR pstrCanonicalName;
   UINT uNameRes;
   UINT uInfoRes;
   UINT uTaskRes;
   UINT uKeywordsRes;
   UINT uIconRes;
   BOOL bDynamic;
   DWORD dwFlags;
   ULONG_PTR lData;
   DWORD dwHelpContext;
   HRESULT (*pfnUpdateRegistry)(int iIndex, BOOL bRegister);
   BOOL (*pfnCreateInstance)(HWND hWnd, LONG_PTR lData, LPCTSTR pstrData);
   VOID (*pfnGetAppletInfo)(int iLevel, tagATLCPLAPPLETINFO* pInfo);
} ATLCPLAPPLETINFO;

extern ATLCPLAPPLETINFO _pAtlApplets[];


#define BEGIN_CPLAPPLET_MAP()  \
   ATLCPLAPPLETINFO _pAtlApplets[] = {

#define CPLAPPLET_ENTRY(applclass, cname, name)  \
   { _T(cname), IDS_##name, IDS_Description_##name, IDS_Task_##name, IDS_Keywords_##name, IDI_##name, FALSE, 0, 0L, 0, &applclass::UpdateRegistry, &applclass::CreateInstance, &applclass::GetAppletInfo },

#define CPLAPPLET_ENTRY_EX(applclass, cname, name, info, task, keywords, icon, flags, data, helpctx)  \
   { _T(cname), name, info, task, keywords, icon, TRUE, flags, data, helpctx, &applclass::UpdateRegistry, &applclass::CreateInstance, &applclass::GetAppletInfo },

#define CPLAPPLET_ENTRY_CLASS(applclass)  \
   { NULL, CPL_DYNAMIC_RES, CPL_DYNAMIC_RES, 0, 0, CPL_DYNAMIC_RES, TRUE, 0, 0L, 0, &applclass::UpdateRegistry, &applclass::CreateInstance, &applclass::GetAppletInfo },

#define END_CPLAPPLET_MAP()  \
   { 0 } };


typedef enum CPLAPPLETINFO
{
   CPLINFO_NAME = 1,
   CPLINFO_INFO,
   CPLINFO_ICON,
   CPLINFO_DATA,
   CPLINFO_HELPCONTEXT,
};


template< class T >
class CCPlAppletBase
{
public:
   enum { APPLET_CATEGORY = 0x05 };
   enum { APPLET_RUNLEVEL = 0x00 };
   enum { APPLET_TASK_REGISTRYID = 0 };



   static HRESULT UpdateRegistry(int iIndex, BOOL bRegister)
   {
      ATLCPLAPPLETREG RegInfo = { iIndex, FALSE, T::APPLET_CATEGORY, T::APPLET_RUNLEVEL, T::APPLET_TASK_REGISTRYID };
      return _Applets.UpdateRegistry(bRegister, &RegInfo);
   }


   static BOOL CreateInstance(HWND hWnd, LONG_PTR lData, LPCTSTR pstrData)
   {
      T* pObject = new T();
      if( pObject == NULL ) return FALSE;
      BOOL bRes = pObject->ShowApplet(hWnd, lData, pstrData);
      delete pObject;
      return bRes;
   }

   static VOID GetAppletInfo(int /*iLevel*/, ATLCPLAPPLETINFO* /*pInfo*/)
   {
   }
};


class CCPlAppletModule
{
public:
   HWND m_hwndCPl;

   CCPlAppletModule() : m_hwndCPl(NULL)
   {
   }

   LONG CPlApplet(HWND hwndCPl, UINT msg, LPARAM lParam1, LPARAM lParam2)
   {
      m_hwndCPl = hwndCPl;
      switch( msg ) {
      case CPL_INIT:
         CPlApplet_Init();
         return 1;
      case CPL_EXIT:
         CPlApplet_Exit();
         return 0;
      case CPL_GETCOUNT:         
         return CPlApplet_GetCount();
      case CPL_DBLCLK:
         CPlApplet_DblClick((int) lParam1, hwndCPl);
         return 0;
#ifndef _WIN32_WCE
      case CPL_INQUIRE:
         CPlApplet_Inquire((int) lParam1, (CPLINFO*) lParam2);
         return 0;
#endif // !_WIN32_WCE
      case CPL_NEWINQUIRE:
         CPlApplet_NewInquire((int) lParam1, (NEWCPLINFO*) lParam2);
         return 0;
#ifndef _WIN32_WCE
#if (WINVER >= 0x0400)
      case CPL_STARTWPARMSA:
         {
#ifdef _UNICODE
            WCHAR wszCommand[100] = { 0 };
            ::MultiByteToWideChar(CP_ACP, 0, (LPCSTR) lParam2, -1, wszCommand, (sizeof(wszCommand) / sizeof(WCHAR)) -1);
            LPCWSTR pstrCommand = wszCommand;
#else
            LPCSTR pstrCommand = (LPCSTR) lParam2;
#endif  // _UNICODE
            return (LONG) CPlApplet_StartWithParams((int) lParam1, hwndCPl, pstrCommand);
         }
      case CPL_STARTWPARMSW:
         {
#ifdef _UNICODE
            LPCWSTR pstrCommand = (LPCWSTR) lParam2;
#else
            CHAR szCommand[200] = { 0 };
            ::WideCharToMultiByte(CP_ACP, 0, (LPCWSTR) lParam2, -1, szCommand, sizeof(szCommand) - 1, NULL, NULL);
            LPCSTR pstrCommand = szCommand;
#endif // _UNICODE
            return (LONG) CPlApplet_StartWithParams((int) lParam1, hwndCPl, pstrCommand);
         }
#endif // (WINVER >= 0x0400)
#endif // !_WIN32_WCE
      case CPL_STOP:
         CPlApplet_Stop((int) lParam1);
         return 0;
      }
      return 0;
   }

   HRESULT RegisterApplets()
   {
      HRESULT Hr = S_OK;
#ifndef _WIN32_WCE
      int iIndex = 0;
      for( const ATLCPLAPPLETINFO* pObjects = _pAtlApplets; (*pObjects).pfnCreateInstance != NULL; pObjects++ ) {
         if( FAILED( Hr = pObjects->pfnUpdateRegistry(iIndex++, TRUE) ) ) return Hr;
      }
#endif // !_WIN32_WCE
      return Hr;
   }

   HRESULT UnregisterApplets()
   {
      HRESULT Hr = S_OK, HrRes = S_OK;
#ifndef _WIN32_WCE
      int iIndex = 0;
      for( const ATLCPLAPPLETINFO* pObjects = _pAtlApplets; (*pObjects).pfnCreateInstance != NULL; pObjects++ ) {
         if( FAILED( Hr = pObjects->pfnUpdateRegistry(iIndex++, FALSE) ) ) HrRes = Hr;
      }
#endif // !_WIN32_WCE
      return HrRes;
   }

   HWND GetOwnerHWND()
   {
      return m_hwndCPl;
   }

   BOOL ChangeAppletInfo(int iIndex, CPLAPPLETINFO Type, UINT uResID)
   {
      ATLASSERT(iIndex>=0 && iIndex<CPlApplet_GetCount());
      if( iIndex < 0 || iIndex >= CPlApplet_GetCount() ) return FALSE;
      switch( Type ) {
      case CPLINFO_NAME:         _pAtlApplets[iIndex].uNameRes = uResID; break;
      case CPLINFO_INFO:         _pAtlApplets[iIndex].uInfoRes = uResID; break;
      case CPLINFO_ICON:         _pAtlApplets[iIndex].uIconRes = uResID; break;
      case CPLINFO_DATA:         _pAtlApplets[iIndex].lData = (LONG_PTR) uResID; break;
      case CPLINFO_HELPCONTEXT:  _pAtlApplets[iIndex].dwHelpContext = uResID; break;
      default: return FALSE;
      }
      _pAtlApplets[iIndex].bDynamic = TRUE;
      return TRUE;     
   }

   HRESULT UpdateRegistry(BOOL bRegister, ATLCPLAPPLETREG* pRegInfo)
   {
#ifndef _WIN32_WCE
      OSVERSIONINFO osvi = { 0 };;
      osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
      ::GetVersionEx(&osvi);
      bool bIsVista = (osvi.dwMajorVersion >= 6);
      bool bIsWin98 = ((osvi.dwPlatformId != VER_PLATFORM_WIN32_WINDOWS && osvi.dwMajorVersion >= 5) || (osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS && (osvi.dwMinorVersion >= 90 || osvi.dwMajorVersion > 4)));
      bool bIsWinXP = ((osvi.dwPlatformId != VER_PLATFORM_WIN32_WINDOWS) && ((osvi.dwMajorVersion > 5) || ((osvi.dwMajorVersion == 5) && (osvi.dwMinorVersion >= 1))));

      TCHAR szDllFile[MAX_PATH] = { 0 };
      ::GetModuleFileName(ModuleHelper::GetModuleInstance(), szDllFile, MAX_PATH);

      ATLCPLAPPLETINFO Info = _pAtlApplets[pRegInfo->iIndex];
      _pAtlApplets[pRegInfo->iIndex].pfnGetAppletInfo(1, &Info);

      // Create a friendly name for the dll filename. No spaces and funny characters.
      LPCTSTR pSep = _FindLastOf(szDllFile, '\\');
      if( pSep == NULL ) return E_FAIL;
      TCHAR szDllName[MAX_PATH] = { 0 };
      ::lstrcpy(szDllName, pSep + 1);
      TCHAR szFriendlyName[MAX_PATH] = { 0 };
      ::lstrcpy(szFriendlyName, pSep + 1);
      for( LPTSTR p = szFriendlyName; *p != '\0'; p = ::CharNext(p) ) {
         if( *p == '.' ) { *p = '\0'; break; }
         if( !IsCharAlphaNumeric(*p) ) *p = '_';
      }

      HRESULT Hr = S_OK;
      if( bIsVista )
      {
         HKEY hKeyRoot = HKEY_LOCAL_MACHINE;
         if( pRegInfo->bOnlyCurrentUser ) hKeyRoot = HKEY_CURRENT_USER;
         CRegKey reg;         
         LONG lRes = reg.Create(hKeyRoot, _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Control Panel\\Cpls"));
         if( lRes != ERROR_SUCCESS ) return HRESULT_FROM_WIN32(lRes);
         if( bRegister ) {
            ::RegSetValueEx(reg, szFriendlyName, NULL, REG_EXPAND_SZ, (CONST BYTE*) szDllFile, (lstrlen(szDllFile) + 1) * sizeof(TCHAR));
            if( pRegInfo->dwRunLevel > 0 ) {
               CRegKey regSub;
               if( regSub.Create(reg, szDllName) == ERROR_SUCCESS ) {
                  ::RegSetValueEx(regSub, _T("RunLevel"), NULL, REG_DWORD, (CONST BYTE*) &pRegInfo->dwRunLevel, sizeof(DWORD));
                  regSub.Close();
               }
            }
         }
         else {
            reg.DeleteValue(szFriendlyName);
            reg.DeleteSubKey(szDllName);
         }
         reg.Close();
         
         // Register canonical name
         lRes = reg.Open(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Control Panel\\Extended Properties\\System.ApplicationName"), KEY_ALL_ACCESS);
         if( lRes != ERROR_SUCCESS ) return HRESULT_FROM_WIN32(lRes);
         if( bRegister ) {
              ::RegSetValueEx(reg, szDllFile, NULL, REG_SZ, (CONST BYTE*) Info.pstrCanonicalName, (lstrlen(Info.pstrCanonicalName) + 1) * sizeof(TCHAR));
         }
         else {
            reg.DeleteValue(szDllFile);
         }
         reg.Close();

         TCHAR szGUID[50] = { 0 };
         DWORD dwCategory = pRegInfo->dwCategory;
         TCHAR szTaskFileUrl[MAX_PATH + 20] = { 0 };

         if( pRegInfo->uTaskRegID == 0 )
         {
            GUID AppGUID, TaskGUID;
            ::CoCreateGuid(&AppGUID);
            ::CoCreateGuid(&TaskGUID);
            WCHAR wszGUID[50], wszTaskGUID[50];
            ::StringFromGUID2(AppGUID, wszGUID, 50);
            ::StringFromGUID2(TaskGUID, wszTaskGUID, 50);
            WCHAR wszBuffer[1025] = { 0 };
            ::wsprintfW(wszBuffer, 
               L"\xfeff<?xml version=\"1.0\" encoding=\"UTF-16\" ?>\n"
               L"<applications xmlns=\"http://schemas.microsoft.com/windows/cpltasks/v1\" xmlns:sh=\"http://schemas.microsoft.com/windows/tasks/v1\">"
               L"<application id=\"%s\">"
               L"<sh:task id=\"%s\" needsElevation=\"%s\">"
#ifdef _UNICODE
               L"<sh:name>@%s,-%ld</sh:name>"
               L"<sh:keywords>@%s,-%ld</sh:keywords>"
               L"<sh:command>%%systemroot%%\\system32\\control.exe /name %s</sh:command>"
#else
               L"<sh:name>@%hs,-%ld</sh:name>"
               L"<sh:keywords>@%hs,-%ld</sh:keywords>"
               L"<sh:command>%%systemroot%%\\system32\\control.exe /name %hs</sh:command>"
#endif // _UNICODE
               L"</sh:task>"
               L"<category id=\"%ld\">"
               L"<sh:task idref=\"%s\"/>"
               L"</category>"
               L"</application>"
               L"</applications>",
               wszGUID,
               wszTaskGUID,
               pRegInfo->dwRunLevel == 0 ? L"false" : L"true",
               szDllName, Info.uTaskRes,
               szDllName, Info.uKeywordsRes,
               Info.pstrCanonicalName,
               pRegInfo->dwCategory,
               wszTaskGUID);
            ::wsprintf(szGUID, _T("%ws"), wszGUID);
            ::lstrcpy(szTaskFileUrl, szDllFile);
            ::wsprintf(_FindLastOf(szTaskFileUrl, '.'), _T("_cpl%d.xml"), pRegInfo->iIndex + 1);
            if( bRegister ) {
               HANDLE hFile = ::CreateFile(szTaskFileUrl, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
               if( hFile == INVALID_HANDLE_VALUE ) return HRESULT_FROM_WIN32(::GetLastError());
               DWORD dwWritten = 0;
               ::WriteFile(hFile, wszBuffer, lstrlenW(wszBuffer) * sizeof(WCHAR), &dwWritten, NULL);
               ::CloseHandle(hFile);
            }
            else {
               ::DeleteFile(szTaskFileUrl);
            }
         }
         else
         {
            // Load the XML resource.
            // Here we assume it is UTF-8 encoded (or latin-1) and embedded in the "XML" resource
            // type section.
            HRSRC hResource = ::FindResource(ModuleHelper::GetResourceInstance(), MAKEINTRESOURCE(pRegInfo->uTaskRegID), _T("XML"));
            if( hResource == NULL ) return TYPE_E_FIELDNOTFOUND;
            HGLOBAL hGlobal = ::LoadResource(ModuleHelper::GetResourceInstance(), hResource);
            if( hGlobal == NULL ) return E_OUTOFMEMORY;
            DWORD dwSize = ::SizeofResource(ModuleHelper::GetResourceInstance(), hResource);
            LPVOID pVoid = ::LockResource(hGlobal);
            LPSTR pstr = (LPSTR) malloc(dwSize + 1);
            memcpy(pstr, pVoid, dwSize);
            FreeResource(hGlobal);
            pstr[dwSize] = '\0';
            LPSTR pstrCategory = strstr(pstr, "<category id=\"");
            if( pstrCategory != NULL ) dwCategory = (DWORD) atol(pstrCategory + 14);
            LPSTR pstrGUID = strstr(pstr, "<application id=\"");
            if( pstrGUID == NULL ) return TYPE_E_ELEMENTNOTFOUND;
            BYTE bGUID[50] = { 0 };
            memcpy(bGUID, pstrGUID + 17, 38);
            ::wsprintf(szGUID, _T("%hs"), bGUID);
            ::wsprintf(szTaskFileUrl, _T("%s,-%ld"), szDllFile, pRegInfo->uTaskRegID);
            free(pstr);
         }

         // Set the ApplicationName (canonical name)
         lRes = reg.Open(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Control Panel\\Extended Properties\\System.Software.AppId"), KEY_ALL_ACCESS);
         if( lRes != ERROR_SUCCESS ) return HRESULT_FROM_WIN32(lRes);
         if( bRegister ) {
              ::RegSetValueEx(reg, szDllFile, NULL, REG_SZ, (CONST BYTE*) szGUID, (lstrlen(szGUID) + 1) * sizeof(TCHAR));
         }
         else {
            reg.DeleteValue(szDllFile);
         }
         reg.Close();
         
         // Set the TaskFileUrl
         lRes = reg.Open(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Control Panel\\Extended Properties\\System.Software.TasksFileUrl"), KEY_ALL_ACCESS);
         if( lRes != ERROR_SUCCESS ) return HRESULT_FROM_WIN32(lRes);
         if( bRegister ) {
              ::RegSetValueEx(reg, szDllFile, NULL, REG_SZ, (CONST BYTE*) szTaskFileUrl, (lstrlen(szTaskFileUrl) + 1) * sizeof(TCHAR));
         }
         else {
            reg.DeleteValue(szDllFile);
         }
         reg.Close();

         // Set the Category
         lRes = reg.Open(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Control Panel\\Extended Properties\\System.ControlPanel.Category"), KEY_ALL_ACCESS);
         if( lRes != ERROR_SUCCESS ) return HRESULT_FROM_WIN32(lRes);
         if( bRegister ) {
            ::RegSetValueEx(reg, szDllFile, NULL, REG_DWORD, (CONST BYTE*) &dwCategory, sizeof(DWORD));
         }
         else {
            reg.DeleteValue(szDllFile);
         }
         reg.Close();
      }
      else if( bIsWin98 )
      {
         HKEY hKeyRoot = HKEY_LOCAL_MACHINE;
         if( pRegInfo->bOnlyCurrentUser ) hKeyRoot = HKEY_CURRENT_USER;
         CRegKey reg;
         LONG lRes = reg.Create(hKeyRoot, _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Control Panel\\Cpls"));
         if( lRes != ERROR_SUCCESS ) return HRESULT_FROM_WIN32(lRes);
         if( bRegister ) {
            ::RegSetValueEx(reg, szFriendlyName, NULL, REG_EXPAND_SZ, (CONST BYTE*) szDllFile, (lstrlen(szDllFile) + 1) * sizeof(TCHAR));
         }
         else {
            reg.DeleteValue(szFriendlyName);
         }
         reg.Close();

         // Set the Category on Windows XP
         if( bIsWinXP ) {
            lRes = reg.Create(HKEY_LOCAL_MACHINE, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Control Panel\\Extended Properties\\{305CA226-D286-468e-B848-2B2E8E697B74} 2"));
            if( lRes == ERROR_SUCCESS ) {
               if( bRegister ) {
                  ::RegSetValueEx(reg, szDllFile, NULL, REG_DWORD, (CONST BYTE*) &pRegInfo->dwCategory, sizeof(DWORD));
               }
               else {
                  reg.DeleteValue(szDllFile);
               }
            }
         }
      }
      else
      {
        BOOL bRes = ::WritePrivateProfileString(_T("MMCPL"), szFriendlyName, (bRegister ? szDllFile : NULL), _T("control.ini"));    
        if( !bRes ) Hr = HRESULT_FROM_WIN32(::GetLastError());
      }
       return Hr;
#else
	   return S_OK;
#endif // !_WIN32_WCE

   }

   void CPlApplet_Init()
   {
   }

   void CPlApplet_Exit()
   {
   }

   void CPlApplet_Stop(int iIndex)
   {
      ATLASSERT(iIndex>=0 && iIndex<CPlApplet_GetCount());
      if( iIndex < 0 || iIndex >= CPlApplet_GetCount() ) return;
   }

   void CPlApplet_DblClick(int iIndex, HWND hWnd)
   {
      ATLASSERT(iIndex>=0 && iIndex<CPlApplet_GetCount());
      if( iIndex < 0 || iIndex >= CPlApplet_GetCount() ) return;
      LONG_PTR lData = _pAtlApplets[iIndex].lData;
      _pAtlApplets[iIndex].pfnCreateInstance(hWnd, lData, _T(""));
   }

#ifndef _WIN32_WCE
   BOOL CPlApplet_StartWithParams(int iIndex, HWND hWnd, LPCTSTR pstrText)
   {
      ATLASSERT(iIndex>=0 && iIndex<CPlApplet_GetCount());
      if( iIndex < 0 || iIndex >= CPlApplet_GetCount() ) return FALSE;
      LONG_PTR lData = _pAtlApplets[iIndex].lData;
      return _pAtlApplets[iIndex].pfnCreateInstance(hWnd, lData, pstrText);
   }
#endif // !_WIN32_WCE

   LONG CPlApplet_GetCount()
   {
      LONG nCount = 0;
      const ATLCPLAPPLETINFO* pObjects = _pAtlApplets;
      while( (*pObjects).pfnCreateInstance != NULL ) pObjects++, nCount++;
      return nCount;
   }

#ifndef _WIN32_WCE
   void CPlApplet_Inquire(int iIndex, CPLINFO* pInfo)
   {
      ATLASSERT(iIndex>=0 && iIndex<CPlApplet_GetCount());
      if( iIndex < 0 || iIndex >= CPlApplet_GetCount() ) return;
      _pAtlApplets[iIndex].pfnGetAppletInfo(0, &_pAtlApplets[iIndex]);
      pInfo->idIcon = _pAtlApplets[iIndex].uIconRes;
      pInfo->idInfo = _pAtlApplets[iIndex].uInfoRes;
      pInfo->idName = _pAtlApplets[iIndex].uNameRes;
      pInfo->lData = _pAtlApplets[iIndex].lData;
   }
#endif // !_WIN32_WCE

   void CPlApplet_NewInquire(int iIndex, NEWCPLINFO* pInfo)
   {
      ATLASSERT(iIndex>=0 && iIndex<CPlApplet_GetCount());
      if( iIndex < 0 || iIndex >= CPlApplet_GetCount() ) return;
      _pAtlApplets[iIndex].pfnGetAppletInfo(1, &_pAtlApplets[iIndex]);
      ::ZeroMemory(pInfo, sizeof(NEWCPLINFO));
      pInfo->dwSize = sizeof(NEWCPLINFO);
      ::LoadString(ModuleHelper::GetResourceInstance(), _pAtlApplets[iIndex].uNameRes, pInfo->szName, sizeof(pInfo->szName) / sizeof(TCHAR));
      ::LoadString(ModuleHelper::GetResourceInstance(), _pAtlApplets[iIndex].uInfoRes, pInfo->szInfo, sizeof(pInfo->szInfo) / sizeof(TCHAR));
      pInfo->hIcon = ::LoadIcon(ModuleHelper::GetResourceInstance(), MAKEINTRESOURCE(_pAtlApplets[iIndex].uIconRes));
      pInfo->dwFlags = _pAtlApplets[iIndex].dwFlags;
      pInfo->dwHelpContext = _pAtlApplets[iIndex].dwHelpContext;
      pInfo->lData = _pAtlApplets[iIndex].lData;
   }

   LPTSTR _FindLastOf(LPTSTR pstr, TCHAR ch) const
   {
      LPTSTR pSep = NULL;
      for( LPTSTR p = pstr; *p != '\0'; p = ::CharNext(p) ) {
         if( *p == ch ) pSep = p;
      }
      return pSep;
   }
};

extern CCPlAppletModule _Applets;



#endif __ATLCPLAPPLET_H__
<file_sep>/FingerSuite/FingerSuiteCPL/FingerMenuCPLDlg.h
// FingerMenuCONFIGView.h : interface of the CFingerMenuCONFIGView class
//
/////////////////////////////////////////////////////////////////////////////

#pragma once

#include "..\Common\Utils.h"
#include <Tlhelp32.h>

#define IDT_TMR_CTRL 10001
#define TMR_CTRL_INTERVAL 1000

class CColorViewImpl : public CWindowImpl<CColorViewImpl, CStatic>
{
public:

	CColorViewImpl ()
	{
		m_color = RGB(255, 255, 255);
	}

	void SetColor(COLORREF color)
	{
		m_color = color;
		InvalidateRect(NULL);
		UpdateWindow();
	}

	BEGIN_MSG_MAP(CColorViewImpl)
		MESSAGE_HANDLER(WM_PAINT, OnPaint)
	END_MSG_MAP()
 
	LRESULT OnPaint(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		RECT rc; GetClientRect(&rc);
		CPaintDC dc(m_hWnd);
		dc.FillSolidRect(&rc, m_color);
		return 0;
	}

public:
	COLORREF m_color;
};

/********************************************************
 PAGE1
 ********************************************************/

class CFingerMenuCPLDlg1 :    public CPropertyPageImpl<CFingerMenuCPLDlg1>,
							  public CWinDataExchange<CFingerMenuCPLDlg1>,
							  public CUpdateUI<CFingerMenuCPLDlg1>
{
public:
	enum { IDD = IDD_PAGE1 };

	BOOL PreTranslateMessage(MSG* pMsg)
	{
		return CWindow::IsDialogMessage(pMsg);
	}

	BOOL OnIdle()
	{
		UIUpdateChildWindows();
		return FALSE;
	}

	void DoPaint(CDCHandle dc) {}


	BEGIN_MSG_MAP_EX(CFingerMenuCPLDlg1)
		MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
		CHAIN_MSG_MAP(CPropertyPageImpl<CFingerMenuCPLDlg1>)
	END_MSG_MAP()

    BEGIN_DDX_MAP(CFingerMenuCPLDlg1)
		DDX_CHECK(IDC_AUTOSTART_MENU, m_bAutostartMenu)
		DDX_CHECK(IDC_AUTOSTART_MSGBOX, m_bAutostartMsgbox)
    END_DDX_MAP()

	BEGIN_UPDATE_UI_MAP(CFingerMenuCPLDlg1)
    END_UPDATE_UI_MAP()

	int OnApply()
	{
		DoDataExchange(TRUE);
		SaveConfiguration();
		return PSNRET_NOERROR;
	}

	LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		UIAddChildWindowContainer(m_hWnd);

		// get startup folder
		WCHAR szValue[MAX_PATH];
		if (SHGetSpecialFolderPath(m_hWnd, szValue, CSIDL_STARTUP, FALSE))
		{
//		if (RegReadString(HKEY_LOCAL_MACHINE, L"System\\Explorer\\Shell Folders", L"StartUp", szValue))
//		{
			m_szStartupFolder.Format(L"%s", szValue);
		}
		else
		{
			OutputDebugString(ErrorString(GetLastError()));
			m_szStartupFolder = L"\\Windows\\StartUp";
		}

		ZeroMemory(szValue, sizeof(szValue));
		if (SHGetSpecialFolderPath(m_hWnd, szValue, CSIDL_PROGRAM_FILES, FALSE))
		{
		//if (RegReadString(HKEY_LOCAL_MACHINE, L"System\\Explorer\\Shell Folders", L"Program Files", szValue))
		//{
			m_szProgramFilesFolder.Format(L"%s", szValue);
		}
		else
		{
			OutputDebugString(ErrorString(GetLastError()));
			m_szProgramFilesFolder = L"\\Program Files";
		}


		if (!(m_bWithFingerMenu))
		{
			CWindow wnd1 = GetDlgItem(IDC_AUTOSTART_MENU);
			wnd1.EnableWindow(FALSE);

			CWindow wnd2 = GetDlgItem(IDC_LBL_AUTOSTART_MENU);
			wnd2.EnableWindow(FALSE);

		}

		LoadConfiguration();

		DoDataExchange(FALSE); 

		return TRUE;
	}

public:
	BOOL m_bWithFingerMenu;
private:
	BOOL m_bAutostartMenu;
	BOOL m_bAutostartMsgbox;
	CString m_szStartupFolder;
	CString m_szProgramFilesFolder;

	void LoadConfiguration()
	{
		CFindFile finder; 
		if (m_bWithFingerMenu)
			m_bAutostartMenu = finder.FindFile(m_szStartupFolder + L"\\FingerMenu.lnk");
		m_bAutostartMsgbox = finder.FindFile(m_szStartupFolder + L"\\FingerMsgbox.lnk");
	}

	void SaveConfiguration()
	{
		if (m_bWithFingerMenu)
		{
			if (m_bAutostartMenu)
			{
				HANDLE hLink = ::CreateFile(m_szStartupFolder + L"\\FingerMenu.lnk", 
											GENERIC_WRITE,
											0,
											NULL,
											CREATE_ALWAYS,
											FILE_ATTRIBUTE_NORMAL,
											NULL);
				if (hLink != INVALID_HANDLE_VALUE)
				{
					CString szPath;
					WCHAR szInstallDir[MAX_PATH];
					if (RegistryGetString(HKEY_LOCAL_MACHINE, L"Software\\FingerMenu", L"InstallDir", szInstallDir, MAX_PATH) == S_OK)
					{
						szPath.Format(L"%s\\FingerMenu.exe", szInstallDir);
					}
					else
					{
						szPath = m_szProgramFilesFolder + L"\\FingerMenu\\FingerMenu.exe";
					}


					//CHAR szLink[] = "42#\"\\Program Files\\FingerMenu\\FingerMenu.exe\"";
					CString szLink; szLink.Format(L"%d#\"%s\"", szPath.GetLength() + 2, szPath);
					CHAR* tmp = new CHAR[ szLink.GetLength() + 1 ];
					ZeroMemory(tmp, szLink.GetLength());
					for (int i = 0; i < szLink.GetLength(); i++)
						tmp[i] = (CHAR)szLink[i];

					DWORD dwNumberOfBytesWritten;
					::WriteFile(hLink, tmp, szLink.GetLength(), &dwNumberOfBytesWritten, NULL);
					CloseHandle(hLink);
				}
			}
			else
			{
				::DeleteFile(m_szStartupFolder + L"\\FingerMenu.lnk");
			}
		}

		if (m_bAutostartMsgbox)
		{
			HANDLE hLink = ::CreateFile(m_szStartupFolder + L"\\FingerMsgbox.lnk", 
				                        GENERIC_WRITE,
										0,
										NULL,
										CREATE_ALWAYS,
										FILE_ATTRIBUTE_NORMAL,
										NULL);
			if (hLink != INVALID_HANDLE_VALUE)
			{
				CString szPath;
				WCHAR szInstallDir[MAX_PATH];
				if (RegistryGetString(HKEY_LOCAL_MACHINE, L"Software\\FingerMsgbox", L"InstallDir", szInstallDir, MAX_PATH) == S_OK)
				{
					szPath.Format(L"%s\\FingerMsgbox.exe", szInstallDir);
				}
				else
				{
					szPath = m_szProgramFilesFolder + L"\\FingerMsgbox\\FingerMsgbox.exe";
				}

				CString szLink; szLink.Format(L"%d#\"%s\"", szPath.GetLength() + 2, szPath);
				CHAR* tmp = new CHAR[ szLink.GetLength() + 1 ];
				ZeroMemory(tmp, szLink.GetLength());
				for (int i = 0; i < szLink.GetLength(); i++)
					tmp[i] = (CHAR)szLink[i];

				DWORD dwNumberOfBytesWritten;
				::WriteFile(hLink, tmp, szLink.GetLength(), &dwNumberOfBytesWritten, NULL);
				CloseHandle(hLink);
			}
		}
		else
		{
			::DeleteFile(m_szStartupFolder + L"\\FingerMsgbox.lnk");
		}
	}
};

/********************************************************
 PAGE2
 ********************************************************/

class CFingerMenuCPLDlg2 :    public CPropertyPageImpl<CFingerMenuCPLDlg2>,
							  public CWinDataExchange<CFingerMenuCPLDlg2>,
							  public CUpdateUI<CFingerMenuCPLDlg2>
{
public:
	enum { IDD = IDD_PAGE2 };

	BOOL PreTranslateMessage(MSG* pMsg)
	{
		return CWindow::IsDialogMessage(pMsg);
	}

	BOOL OnIdle()
	{
		UIUpdateChildWindows();
		return FALSE;
	}

	void DoPaint(CDCHandle dc) {}


	BEGIN_MSG_MAP_EX(CFingerMenuCPLDlg2)
		MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
		COMMAND_HANDLER(IDC_BTN_BKGCOLORTRANSP, BN_CLICKED, OnBnClickedBtnBkgColorTransp)
		NOTIFY_HANDLER_EX(IDC_SPIN_TRANSLEVEL, UDN_DELTAPOS, OnSpinTransLevelDeltaPos)
		NOTIFY_HANDLER_EX(IDC_SPIN_MAXCOUNT, UDN_DELTAPOS, OnSpinMaxCount)
		NOTIFY_HANDLER_EX(IDC_SPIN_MAXVELOCITY, UDN_DELTAPOS, OnSpinMaxVelocity)
		CHAIN_MSG_MAP(CPropertyPageImpl<CFingerMenuCPLDlg2> )
	END_MSG_MAP()

    BEGIN_DDX_MAP(CFingerMenuCPLDlg2)
		DDX_UINT(IDC_TRANSLEVEL, m_dwTransparencyLevel)
		DDX_UINT(IDC_MAXCOUNT, m_dwMaxVisibleItemCount)
		DDX_UINT(IDC_MAXVELOCITY, m_dwMaxVelocity)
		DDX_CHECK(IDC_ENABLE_SIP, m_bEnableSIP)
		DDX_CHECK(IDC_ENABLE_TRANSPARENCY, m_bDisableTransparency)
		DDX_CHECK(IDC_DISABLE_BTNS, m_bDisableButtons)
		DDX_CHECK(IDC_ENABLE_ANIMATION, m_bEnableAnimation)
		DDX_CONTROL(IDC_CL_BKGCOLORTRANSP, m_ccBkgColorTransp)
    END_DDX_MAP()

	BEGIN_UPDATE_UI_MAP(CFingerMenuCPLDlg2)
    END_UPDATE_UI_MAP()

	int OnApply()
	{
		DoDataExchange(TRUE);
		SaveConfiguration();
		return PSNRET_NOERROR;
	}

	LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		//CMessageLoop* pLoop = _Module.GetMessageLoop();
		//ATLASSERT(pLoop != NULL);
		//pLoop->AddIdleHandler(this);
		UIAddChildWindowContainer(m_hWnd);

		LoadConfiguration();

		DoDataExchange(FALSE); 

		return TRUE;
	}

	LRESULT OnSpinTransLevelDeltaPos ( NMHDR* phdr )
	{
		NMUPDOWN* pm = (NMUPDOWN*)phdr;
		m_dwTransparencyLevel -= pm->iDelta;
		DoDataExchange(FALSE, IDC_TRANSLEVEL); 
		return 0;
	}

	LRESULT OnSpinMaxCount ( NMHDR* phdr )
	{
		NMUPDOWN* pm = (NMUPDOWN*)phdr;
		m_dwMaxVisibleItemCount -= pm->iDelta;
		DoDataExchange(FALSE, IDC_MAXCOUNT); 
		return 0;
	}

	LRESULT OnSpinMaxVelocity ( NMHDR* phdr )
	{
		NMUPDOWN* pm = (NMUPDOWN*)phdr;
		m_dwMaxVelocity -= pm->iDelta;
		DoDataExchange(FALSE, IDC_MAXVELOCITY); 
		return 0;
	}

	LRESULT OnBnClickedBtnBkgColorTransp(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
	{
		CColorDialog colorDlg;
		if (colorDlg.DoModal() == IDOK) // The user selected the "OK" button
		{
			m_ccBkgColorTransp.SetColor( colorDlg.GetColor() ); 
		}
		return 0;
	}

public:
	DWORD m_dwTransparencyLevel;
	BOOL  m_bEnableSIP;
	DWORD m_dwMaxVisibleItemCount;
	DWORD m_dwMaxVelocity;
	BOOL  m_bDisableTransparency;
	BOOL  m_bDisableButtons;
	BOOL  m_bEnableAnimation;
	CColorViewImpl m_ccBkgColorTransp;

private:
	void LoadConfiguration()
	{
		WCHAR keyName[] = L"Software\\FingerMenu";

		// load transparency level
		m_dwTransparencyLevel = 128;
		if (!(RegReadDWORD(HKEY_LOCAL_MACHINE, keyName, L"TransparencyLevel", m_dwTransparencyLevel)))
			wprintf(L"Unable to read TransparencyLevel from registry: %s\n", ErrorString(GetLastError()));


		m_bEnableSIP = TRUE;
		if (!(RegReadBOOL(HKEY_LOCAL_MACHINE, keyName, L"EnableSIP", m_bEnableSIP)))
			wprintf(L"Unable to read EnableSIP from registry: %s\n", ErrorString(GetLastError()));

		m_dwMaxVisibleItemCount = 0;
		if (!(RegReadDWORD(HKEY_LOCAL_MACHINE, keyName, L"MaxMenuItemCount", m_dwMaxVisibleItemCount)))
			wprintf(L"Unable to read MaxMenuItemCount from registry: %s\n", ErrorString(GetLastError()));

		m_dwMaxVelocity = 15;
		if (!(RegReadDWORD(HKEY_LOCAL_MACHINE, keyName, L"MaxVelocity", m_dwMaxVelocity)))
			wprintf(L"Unable to read MaxVelocity from registry: %s\n", ErrorString(GetLastError()));

		m_bDisableTransparency = FALSE;
		if (!(RegReadBOOL(HKEY_LOCAL_MACHINE, keyName, L"DisableTransparency", m_bDisableTransparency)))
			wprintf(L"Unable to read DisableTransparency from registry: %s\n", ErrorString(GetLastError()));

		m_bDisableButtons = FALSE;
		if (!(RegReadBOOL(HKEY_LOCAL_MACHINE, keyName, L"NeverShowButtons", m_bDisableButtons)))
			wprintf(L"Unable to read NeverShowButtons from registry: %s\n", ErrorString(GetLastError()));

		m_bEnableAnimation = TRUE;
		if (!(RegReadBOOL(HKEY_LOCAL_MACHINE, keyName, L"EnableAnimation", m_bEnableAnimation)))
			wprintf(L"Unable to read EnableAnimation from registry: %s\n", ErrorString(GetLastError()));

		RegReadColor(HKEY_LOCAL_MACHINE, keyName, L"NoTranspBkgColor", m_ccBkgColorTransp.m_color);

	}
public:
	void SaveConfiguration()
	{
		WCHAR szKeyName[] = L"Software\\FingerMenu";
		RegWriteDWORD(HKEY_LOCAL_MACHINE, szKeyName, L"TransparencyLevel", m_dwTransparencyLevel);
		RegWriteDWORD(HKEY_LOCAL_MACHINE, szKeyName, L"MaxMenuItemCount", m_dwMaxVisibleItemCount);
		RegWriteDWORD(HKEY_LOCAL_MACHINE, szKeyName, L"MaxVelocity", m_dwMaxVelocity);
		RegWriteBOOL(HKEY_LOCAL_MACHINE,  szKeyName, L"EnableSIP", m_bEnableSIP);
		RegWriteBOOL(HKEY_LOCAL_MACHINE,  szKeyName, L"DisableTransparency", m_bDisableTransparency);
		RegWriteBOOL(HKEY_LOCAL_MACHINE,  szKeyName, L"NeverShowButtons", m_bDisableButtons);
		RegWriteColor(HKEY_LOCAL_MACHINE, szKeyName, L"NoTranspBkgColor", m_ccBkgColorTransp.m_color);
		RegWriteBOOL(HKEY_LOCAL_MACHINE,  szKeyName, L"EnableAnimation", m_bEnableAnimation);
	}
};

/********************************************************
 PAGE3
 ********************************************************/

class CFingerMenuCPLDlg3 :    public CPropertyPageImpl<CFingerMenuCPLDlg3>,
							  public CWinDataExchange<CFingerMenuCPLDlg3>,
							  public CUpdateUI<CFingerMenuCPLDlg3>
{
public:
	enum { IDD = IDD_PAGE3 };

	BOOL PreTranslateMessage(MSG* pMsg)
	{
		return CWindow::IsDialogMessage(pMsg);
	}

	BOOL OnIdle()
	{
		UIUpdateChildWindows();
		return FALSE;
	}

	void DoPaint(CDCHandle dc) {}


	BEGIN_MSG_MAP_EX(CFingerMenuCPLDlg3)
		MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
		COMMAND_HANDLER(IDC_BTN_ADDPROGRAM, BN_CLICKED, OnBnClickedBtnAddProgram)
		COMMAND_HANDLER(IDC_BTN_REFRESH, BN_CLICKED, OnBnClickedBtnRefresh)
		COMMAND_HANDLER(IDC_BTN_REMOVEPROGRAMS, BN_CLICKED, OnBnClickedBtnRemove)
		CHAIN_MSG_MAP(CPropertyPageImpl<CFingerMenuCPLDlg3> )
	END_MSG_MAP()

    BEGIN_DDX_MAP(CFingerMenuCPLDlg3)
		DDX_CONTROL_HANDLE(IDC_CB_PROCESSES, m_cbProcesses)
		DDX_CONTROL_HANDLE(IDC_LB_PROCESSES, m_lbProcesses)
    END_DDX_MAP()

	BEGIN_UPDATE_UI_MAP(CFingerMenuCPLDlg)
    END_UPDATE_UI_MAP()

	int OnApply()
	{
		DoDataExchange(TRUE);
		SaveConfiguration();
		return PSNRET_NOERROR;
	}

	LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		//CMessageLoop* pLoop = _Module.GetMessageLoop();
		//ATLASSERT(pLoop != NULL);
		//pLoop->AddIdleHandler(this);
		UIAddChildWindowContainer(m_hWnd);

		//

		DoDataExchange(FALSE); 

		LoadConfiguration();

		RefreshProcessList();

		return TRUE;
	}



	LRESULT OnBnClickedBtnAddProgram(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
	{
		int i = m_cbProcesses.GetCurSel();
		if (i >= 0)
		{
			CString proc; m_cbProcesses.GetLBText(i, proc);
			int k = m_lbProcesses.FindString(0, proc);
			if (k < 0)
				m_lbProcesses.AddString(proc);
		}
		else
		{
			WCHAR proc[80]; ZeroMemory(proc, 80);
			m_cbProcesses.GetWindowText(proc, 80);
			if (proc[0] != '\0')
			{
				int k = m_lbProcesses.FindString(0, proc);
				if (k < 0)
					m_lbProcesses.AddString(proc);
			}
		}
		return 0;
	}

	LRESULT OnBnClickedBtnRefresh(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
	{
		RefreshProcessList();
		return 0;
	}

	LRESULT OnBnClickedBtnRemove(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
	{
		int i = m_lbProcesses.GetCurSel();
		if (i >= 0)
			m_lbProcesses.DeleteString(i);
		return 0;
	}

private:
	void RefreshProcessList()
	{
		m_cbProcesses.ResetContent();
		m_cbProcesses.Clear();
		// set compiler flag /EHa
		HANDLE snapShot = INVALID_HANDLE_VALUE;
		try
		{
		    snapShot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS | TH32CS_SNAPNOHEAPS, 0);

		    if (snapShot != INVALID_HANDLE_VALUE)
			{
				// Build new list
				PROCESSENTRY32 processEntry;
				processEntry.dwSize = sizeof(PROCESSENTRY32);
				BOOL ret = Process32First(snapShot, &processEntry);
				while (ret == TRUE)
				{
					if (
						(lstrcmpi(processEntry.szExeFile, L"gwes.exe") != 0) &&
						(lstrcmpi(processEntry.szExeFile, L"nk.exe") != 0) &&
						(lstrcmpi(processEntry.szExeFile, L"connmgr.exe") != 0) &&
						(lstrcmpi(processEntry.szExeFile, L"device.exe") != 0) &&
						(lstrcmpi(processEntry.szExeFile, L"filesys.exe") != 0) &&
						(lstrcmpi(processEntry.szExeFile, L"services.exe") != 0) &&
						(lstrcmpi(processEntry.szExeFile, L"shell32.exe") != 0) 
					   )
					{
						m_cbProcesses.AddString(processEntry.szExeFile);
					}

					ret = Process32Next(snapShot, &processEntry);
				}
				CloseToolhelp32Snapshot(snapShot);
			}
		} catch (...)
		{
			// do nothing
			if (snapShot != INVALID_HANDLE_VALUE)
			{
				CloseToolhelp32Snapshot(snapShot);
			}
		}
	}

public:
	CSimpleArray<CString> m_szProcesses;
	CComboBox m_cbProcesses;
	CListBox m_lbProcesses;


private:
	void LoadConfiguration()
	{
		CSimpleArray<CString, CStringEqualHelper<CString>> arExcludedApp;
		LoadExclusionList(arExcludedApp, L"Software\\FingerMenu");

		m_lbProcesses.ResetContent();
		for (int i = 0; i < arExcludedApp.GetSize(); i ++)
		{
			m_lbProcesses.AddString(arExcludedApp[i]);
		}
	}
public:
	void SaveConfiguration()
	{
		CSimpleArray<CString, CStringEqualHelper<CString>> arrExcludedApps;

		for (int i = 0; i < m_lbProcesses.GetCount(); i++)
		{
			CString proc; m_lbProcesses.GetText(i, proc);
			arrExcludedApps.Add(proc);
		}

		SaveExclusionList(arrExcludedApps, L"Software\\FingerMenu");
	}
};



/********************************************************
 PAGE4
 ********************************************************/

class CFingerMenuCPLDlg4 :    public CPropertyPageImpl<CFingerMenuCPLDlg4>,
							  public CWinDataExchange<CFingerMenuCPLDlg4>,
							  public CUpdateUI<CFingerMenuCPLDlg4>
{
public:
	enum { IDD = IDD_PAGE4 };

	CComboBox m_cbSkinFingerMenu;
	CComboBox m_cbSkinFingerMsgbox;

	BOOL PreTranslateMessage(MSG* pMsg)
	{
		return CWindow::IsDialogMessage(pMsg);
	}

	BOOL OnIdle()
	{
		UIUpdateChildWindows();
		return FALSE;
	}

	void DoPaint(CDCHandle dc) {}


	BEGIN_MSG_MAP_EX(CFingerMenuCPLDlg4)
		MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
		CHAIN_MSG_MAP(CPropertyPageImpl<CFingerMenuCPLDlg4>)
	END_MSG_MAP()

    BEGIN_DDX_MAP(CFingerMenuCPLDlg4)
		DDX_CONTROL_HANDLE(IDC_CB_SKIN_FINGERMENU, m_cbSkinFingerMenu)
		DDX_CONTROL_HANDLE(IDC_CB_SKIN_FINGERMSGBOX, m_cbSkinFingerMsgbox)
    END_DDX_MAP()

	BEGIN_UPDATE_UI_MAP(CFingerMenuCPLDlg4)
    END_UPDATE_UI_MAP()

	int OnApply()
	{
		DoDataExchange(TRUE);
		SaveConfiguration();
		return PSNRET_NOERROR;
	}

	LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		UIAddChildWindowContainer(m_hWnd);

		DoDataExchange(FALSE); 

		if (!(m_bWithFingerMenu))
		{
			CWindow wnd1 = GetDlgItem(IDC_CB_SKIN_FINGERMENU);
			wnd1.EnableWindow(FALSE);

			CWindow wnd2 = GetDlgItem(IDC_LBL_CB_SKIN_FINGERMENU);
			wnd2.EnableWindow(FALSE);

		}

		LoadConfiguration();

		return TRUE;
	}

public:
	BOOL m_bWithFingerMenu;


private:
	void LoadConfiguration()
	{
		CString szProgramFilesFolder;
		WCHAR szValue[MAX_PATH]; 
		if (RegReadString(HKEY_LOCAL_MACHINE, L"System\\Explorer\\Shell Folders", L"Program Files", szValue))
		{
			szProgramFilesFolder.Format(L"%s", szValue);
		}

		// menu
		WCHAR szKeyName[] = L"Software\\FingerMenu";
		WCHAR skin[50];
		BOOL setDefault = RegReadString(HKEY_LOCAL_MACHINE, szKeyName, L"Skin", skin);

		m_cbSkinFingerMenu.ResetContent();

		CFindFile finder;
		BOOL bWorking = finder.FindFile(szProgramFilesFolder + L"\\FingerMenu\\skins\\*");
		BOOL bAdd = bWorking;
		int i = 0;
		while (bWorking)
		{
			if (bAdd)
			{
				m_cbSkinFingerMenu.AddString(finder.GetFileName());
				if ((setDefault) && (lstrcmpi(skin, finder.GetFileName()) == 0))
					m_cbSkinFingerMenu.SetCurSel(i);
				i++;
			}
			
			bWorking = finder.FindNextFile();
			if (bWorking)
			{
				if ( finder.IsDirectory() && (!(finder.IsDots())) )
				{
					bAdd = TRUE;
				}
				else
				{
					bAdd = FALSE;
				}
			}
		}

		// msgbox
		WCHAR szKeyName2[] = L"Software\\FingerMsgbox";
		setDefault = RegReadString(HKEY_LOCAL_MACHINE, szKeyName2, L"Skin", skin);

		m_cbSkinFingerMsgbox.ResetContent();

		bWorking = finder.FindFile(szProgramFilesFolder + L"\\FingerMsgbox\\skins\\*");
		bAdd = bWorking;
		i = 0;
		while (bWorking)
		{
			if (bAdd)		
			{
				m_cbSkinFingerMsgbox.AddString(finder.GetFileName());
				if ((setDefault) && (lstrcmpi(skin, finder.GetFileName()) == 0))
					m_cbSkinFingerMsgbox.SetCurSel(i);
				i++;
			}
			
			bWorking = finder.FindNextFile();
			if (bWorking)
			{
				if ( finder.IsDirectory() && (!(finder.IsDots())) )
				{
					bAdd = TRUE;
				}
				else
				{
					bAdd = FALSE;
				}
			}
		}
	}
public:
	void SaveConfiguration()
	{
		if (m_bWithFingerMenu)
		{
			WCHAR szKeyName[] = L"Software\\FingerMenu";
			int i = m_cbSkinFingerMenu.GetCurSel();
			CString skin;
			if (i >= 0)
				m_cbSkinFingerMenu.GetLBText(i, skin);
			else
				skin = L"default";
			RegWriteString(HKEY_LOCAL_MACHINE, szKeyName, L"Skin", skin, skin.GetLength());
		}

		{
			WCHAR szKeyName[] = L"Software\\FingerMsgbox";
			int i = m_cbSkinFingerMsgbox.GetCurSel();
			CString skin;
			if (i >= 0)
				m_cbSkinFingerMsgbox.GetLBText(i, skin);
			else
				skin = L"default";
			RegWriteString(HKEY_LOCAL_MACHINE, szKeyName, L"Skin", skin, skin.GetLength());
		}
	}
};


/********************************************************
 PAGE5
 ********************************************************/

class CFingerMenuCPLDlg5 :    public CPropertyPageImpl<CFingerMenuCPLDlg5>,
							  public CWinDataExchange<CFingerMenuCPLDlg5>,
							  public CUpdateUI<CFingerMenuCPLDlg5>
{
public:
	enum { IDD = IDD_PAGE5 };

	BOOL PreTranslateMessage(MSG* pMsg)
	{
		return CWindow::IsDialogMessage(pMsg);
	}

	BOOL OnIdle()
	{
		UIUpdateChildWindows();
		return FALSE;
	}

	void DoPaint(CDCHandle dc) {}


	BEGIN_MSG_MAP_EX(CFingerMenuCPLDlg5)
		MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
		COMMAND_HANDLER(IDC_BTN_BKGCOLORTRANSP, BN_CLICKED, OnBnClickedBtnBkgColorTransp)
		NOTIFY_HANDLER_EX(IDC_SPIN_TRANSLEVEL, UDN_DELTAPOS, OnSpinTransLevelDeltaPos)
		CHAIN_MSG_MAP(CPropertyPageImpl<CFingerMenuCPLDlg5> )
	END_MSG_MAP()

    BEGIN_DDX_MAP(CFingerMenuCPLDlg5)
		DDX_UINT(IDC_TRANSLEVEL, m_dwTransparencyLevel)
		DDX_CHECK(IDC_ENABLE_TRANSPARENCY, m_bDisableTransparency)
		DDX_CONTROL(IDC_CL_BKGCOLORTRANSP, m_ccBkgColorTransp)
    END_DDX_MAP()

	BEGIN_UPDATE_UI_MAP(CFingerMenuCPLDlg5)
    END_UPDATE_UI_MAP()

	int OnApply()
	{
		DoDataExchange(TRUE);
		SaveConfiguration();
		return PSNRET_NOERROR;
	}

	LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		//CMessageLoop* pLoop = _Module.GetMessageLoop();
		//ATLASSERT(pLoop != NULL);
		//pLoop->AddIdleHandler(this);
		UIAddChildWindowContainer(m_hWnd);

		LoadConfiguration();

		DoDataExchange(FALSE); 

		return TRUE;
	}

	LRESULT OnSpinTransLevelDeltaPos ( NMHDR* phdr )
	{
		NMUPDOWN* pm = (NMUPDOWN*)phdr;
		m_dwTransparencyLevel -= pm->iDelta;
		DoDataExchange(FALSE, IDC_TRANSLEVEL); 
		return 0;
	}

	LRESULT OnBnClickedBtnBkgColorTransp(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
	{
		CColorDialog colorDlg;
		if (colorDlg.DoModal() == IDOK) // The user selected the "OK" button
		{
			m_ccBkgColorTransp.SetColor( colorDlg.GetColor() ); 
		}
		return 0;
	}

public:
	DWORD m_dwTransparencyLevel;
	BOOL  m_bDisableTransparency;
	CColorViewImpl m_ccBkgColorTransp;

private:
	void LoadConfiguration()
	{
		WCHAR keyName[] = L"Software\\FingerMsgbox";

		// load transparency level
		m_dwTransparencyLevel = 128;
		if (!(RegReadDWORD(HKEY_LOCAL_MACHINE, keyName, L"TransparencyLevel", m_dwTransparencyLevel)))
			wprintf(L"Unable to read TransparencyLevel from registry: %s\n", ErrorString(GetLastError()));

		m_bDisableTransparency = FALSE;
		if (!(RegReadBOOL(HKEY_LOCAL_MACHINE, keyName, L"DisableTransparency", m_bDisableTransparency)))
			wprintf(L"Unable to read DisableTransparency from registry: %s\n", ErrorString(GetLastError()));

		RegReadColor(HKEY_LOCAL_MACHINE, keyName, L"NoTranspBkgColor", m_ccBkgColorTransp.m_color);

	}
public:
	void SaveConfiguration()
	{
		WCHAR szKeyName[] = L"Software\\FingerMsgbox";
		RegWriteDWORD(HKEY_LOCAL_MACHINE, szKeyName, L"TransparencyLevel", m_dwTransparencyLevel);
		RegWriteBOOL(HKEY_LOCAL_MACHINE,  szKeyName, L"DisableTransparency", m_bDisableTransparency);
		RegWriteColor(HKEY_LOCAL_MACHINE, szKeyName, L"NoTranspBkgColor", m_ccBkgColorTransp.m_color);
	}
};



/********************************************************
 PAGE6
 ********************************************************/

class CFingerMenuCPLDlg6 :    public CPropertyPageImpl<CFingerMenuCPLDlg6>,
							  public CWinDataExchange<CFingerMenuCPLDlg6>,
							  public CUpdateUI<CFingerMenuCPLDlg6>
{
public:
	enum { IDD = IDD_PAGE3 };

	BOOL PreTranslateMessage(MSG* pMsg)
	{
		return CWindow::IsDialogMessage(pMsg);
	}

	BOOL OnIdle()
	{
		UIUpdateChildWindows();
		return FALSE;
	}

	void DoPaint(CDCHandle dc) {}


	BEGIN_MSG_MAP_EX(CFingerMenuCPLDlg6)
		MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
		COMMAND_HANDLER(IDC_BTN_ADDPROGRAM, BN_CLICKED, OnBnClickedBtnAddProgram)
		COMMAND_HANDLER(IDC_BTN_REFRESH, BN_CLICKED, OnBnClickedBtnRefresh)
		COMMAND_HANDLER(IDC_BTN_REMOVEPROGRAMS, BN_CLICKED, OnBnClickedBtnRemove)
		CHAIN_MSG_MAP(CPropertyPageImpl<CFingerMenuCPLDlg6> )
	END_MSG_MAP()

    BEGIN_DDX_MAP(CFingerMenuCPLDlg6)
		DDX_CONTROL_HANDLE(IDC_CB_PROCESSES, m_cbProcesses)
		DDX_CONTROL_HANDLE(IDC_LB_PROCESSES, m_lbProcesses)
    END_DDX_MAP()

	BEGIN_UPDATE_UI_MAP(CFingerMenuCPLDlg6)
    END_UPDATE_UI_MAP()

	int OnApply()
	{
		DoDataExchange(TRUE);
		SaveConfiguration();
		return PSNRET_NOERROR;
	}

	LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		//CMessageLoop* pLoop = _Module.GetMessageLoop();
		//ATLASSERT(pLoop != NULL);
		//pLoop->AddIdleHandler(this);
		UIAddChildWindowContainer(m_hWnd);

		//

		DoDataExchange(FALSE); 

		LoadConfiguration();

		RefreshProcessList();

		return TRUE;
	}



	LRESULT OnBnClickedBtnAddProgram(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
	{
		int i = m_cbProcesses.GetCurSel();
		if (i >= 0)
		{
			CString proc; m_cbProcesses.GetLBText(i, proc);
			int k = m_lbProcesses.FindString(0, proc);
			if (k < 0)
				m_lbProcesses.AddString(proc);
		}
		else
		{
			WCHAR proc[80]; ZeroMemory(proc, 80);
			m_cbProcesses.GetWindowText(proc, 80);
			if (proc[0] != '\0')
			{
				int k = m_lbProcesses.FindString(0, proc);
				if (k < 0)
					m_lbProcesses.AddString(proc);
			}
		}
		return 0;
	}

	LRESULT OnBnClickedBtnRefresh(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
	{
		RefreshProcessList();
		return 0;
	}

	LRESULT OnBnClickedBtnRemove(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
	{
		int i = m_lbProcesses.GetCurSel();
		if (i >= 0)
			m_lbProcesses.DeleteString(i);
		return 0;
	}

private:
	void RefreshProcessList()
	{
		m_cbProcesses.ResetContent();
		m_cbProcesses.Clear();
		// set compiler flag /EHa
		HANDLE snapShot = INVALID_HANDLE_VALUE;
		try
		{
		    snapShot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS | TH32CS_SNAPNOHEAPS, 0);

		    if (snapShot != INVALID_HANDLE_VALUE)
			{
				// Build new list
				PROCESSENTRY32 processEntry;
				processEntry.dwSize = sizeof(PROCESSENTRY32);
				BOOL ret = Process32First(snapShot, &processEntry);
				while (ret == TRUE)
				{
					if (
						(lstrcmpi(processEntry.szExeFile, L"gwes.exe") != 0) &&
						(lstrcmpi(processEntry.szExeFile, L"nk.exe") != 0) &&
						(lstrcmpi(processEntry.szExeFile, L"connmgr.exe") != 0) &&
						(lstrcmpi(processEntry.szExeFile, L"device.exe") != 0) &&
						(lstrcmpi(processEntry.szExeFile, L"filesys.exe") != 0) &&
						(lstrcmpi(processEntry.szExeFile, L"services.exe") != 0) &&
						(lstrcmpi(processEntry.szExeFile, L"shell32.exe") != 0) 
					   )
					{
						m_cbProcesses.AddString(processEntry.szExeFile);
					}

					ret = Process32Next(snapShot, &processEntry);
				}
				CloseToolhelp32Snapshot(snapShot);
			}
		} catch (...)
		{
			// do nothing
			if (snapShot != INVALID_HANDLE_VALUE)
			{
				CloseToolhelp32Snapshot(snapShot);
			}
		}
	}

public:
	CSimpleArray<CString> m_szProcesses;
	CComboBox m_cbProcesses;
	CListBox m_lbProcesses;


private:
	void LoadConfiguration()
	{
		CSimpleArray<CString, CStringEqualHelper<CString>> arExcludedApp;
		LoadExclusionList(arExcludedApp, L"Software\\FingerMsgbox");

		m_lbProcesses.ResetContent();
		for (int i = 0; i < arExcludedApp.GetSize(); i ++)
		{
			m_lbProcesses.AddString(arExcludedApp[i]);
		}
	}
public:
	void SaveConfiguration()
	{
		CSimpleArray<CString, CStringEqualHelper<CString>> arrExcludedApps;

		for (int i = 0; i < m_lbProcesses.GetCount(); i++)
		{
			CString proc; m_lbProcesses.GetText(i, proc);
			arrExcludedApps.Add(proc);
		}

		SaveExclusionList(arrExcludedApps, L"Software\\FingerMsgbox");
	}
};




/********************************************************
 PAGE7
 ********************************************************/

class CFingerMenuCPLDlg7 :    public CPropertyPageImpl<CFingerMenuCPLDlg7>,
							  public CWinDataExchange<CFingerMenuCPLDlg7>,
							  public CUpdateUI<CFingerMenuCPLDlg7>
{
public:
	enum { IDD = IDD_PAGE7 };

	BOOL PreTranslateMessage(MSG* pMsg)
	{
		return CWindow::IsDialogMessage(pMsg);
	}

	BOOL OnIdle()
	{
		UIUpdateChildWindows();
		return FALSE;
	}

	void DoPaint(CDCHandle dc) {}


	BEGIN_MSG_MAP_EX(CFingerMenuCPLDlg7)
		MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
		COMMAND_HANDLER(IDC_BTN_REMOVEPROGRAMS, BN_CLICKED, OnBnClickedBtnRemove)
		CHAIN_MSG_MAP(CPropertyPageImpl<CFingerMenuCPLDlg7> )
	END_MSG_MAP()

    BEGIN_DDX_MAP(CFingerMenuCPLDlg7)
		DDX_CONTROL_HANDLE(IDC_LB_PROCESSES, m_lbProcesses)
    END_DDX_MAP()

	BEGIN_UPDATE_UI_MAP(CFingerMenuCPLDlg7)
    END_UPDATE_UI_MAP()

	int OnApply()
	{
		DoDataExchange(TRUE);
		SaveConfiguration();
		return PSNRET_NOERROR;
	}

	LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		//CMessageLoop* pLoop = _Module.GetMessageLoop();
		//ATLASSERT(pLoop != NULL);
		//pLoop->AddIdleHandler(this);
		UIAddChildWindowContainer(m_hWnd);

		//

		DoDataExchange(FALSE); 

		LoadConfiguration();

		return TRUE;
	}

	LRESULT OnBnClickedBtnRemove(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
	{
		int i = m_lbProcesses.GetCurSel();
		if (i >= 0)
			m_lbProcesses.DeleteString(i);
		return 0;
	}

public:
	CSimpleArray<CString> m_szProcesses;
	CListBox m_lbProcesses;


private:
	void LoadConfiguration()
	{
		CSimpleArray<CString, CStringEqualHelper<CString>> arExcludedWnds;
		LoadWndExclusionList(arExcludedWnds, L"Software\\FingerMenu");

		m_lbProcesses.ResetContent();
		for (int i = 0; i < arExcludedWnds.GetSize(); i ++)
		{
			m_lbProcesses.AddString(arExcludedWnds[i]);
		}
	}
public:
	void SaveConfiguration()
	{
		CSimpleArray<CString, CStringEqualHelper<CString>> arExcludedWnds;

		for (int i = 0; i < m_lbProcesses.GetCount(); i++)
		{
			CString proc; m_lbProcesses.GetText(i, proc);
			arExcludedWnds.Add(proc);
		}

		SaveWndExclusionList(arExcludedWnds, L"Software\\FingerMenu");
	}
};


/********************************************************
 PAGE8
 ********************************************************/

class CFingerMenuCPLDlg8 :    public CPropertyPageImpl<CFingerMenuCPLDlg8>,
							  public CWinDataExchange<CFingerMenuCPLDlg8>,
							  public CUpdateUI<CFingerMenuCPLDlg8>
{
public:
	enum { IDD = IDD_PAGE7 };

	BOOL PreTranslateMessage(MSG* pMsg)
	{
		return CWindow::IsDialogMessage(pMsg);
	}

	BOOL OnIdle()
	{
		UIUpdateChildWindows();
		return FALSE;
	}

	void DoPaint(CDCHandle dc) {}


	BEGIN_MSG_MAP_EX(CFingerMenuCPLDlg8)
		MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
		COMMAND_HANDLER(IDC_BTN_REMOVEPROGRAMS, BN_CLICKED, OnBnClickedBtnRemove)
		CHAIN_MSG_MAP(CPropertyPageImpl<CFingerMenuCPLDlg8> )
	END_MSG_MAP()

    BEGIN_DDX_MAP(CFingerMenuCPLDlg8)
		DDX_CONTROL_HANDLE(IDC_LB_PROCESSES, m_lbProcesses)
    END_DDX_MAP()

	BEGIN_UPDATE_UI_MAP(CFingerMenuCPLDlg8)
    END_UPDATE_UI_MAP()

	int OnApply()
	{
		DoDataExchange(TRUE);
		SaveConfiguration();
		return PSNRET_NOERROR;
	}

	LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		//CMessageLoop* pLoop = _Module.GetMessageLoop();
		//ATLASSERT(pLoop != NULL);
		//pLoop->AddIdleHandler(this);
		UIAddChildWindowContainer(m_hWnd);

		//

		DoDataExchange(FALSE); 

		LoadConfiguration();

		return TRUE;
	}

	LRESULT OnBnClickedBtnRemove(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
	{
		int i = m_lbProcesses.GetCurSel();
		if (i >= 0)
			m_lbProcesses.DeleteString(i);
		return 0;
	}

public:
	CSimpleArray<CString> m_szProcesses;
	CListBox m_lbProcesses;


private:
	void LoadConfiguration()
	{
		CSimpleArray<CString, CStringEqualHelper<CString>> arExcludedWnds;
		LoadWndExclusionList(arExcludedWnds, L"Software\\FingerMsgbox");

		m_lbProcesses.ResetContent();
		for (int i = 0; i < arExcludedWnds.GetSize(); i ++)
		{
			m_lbProcesses.AddString(arExcludedWnds[i]);
		}
	}
public:
	void SaveConfiguration()
	{
		CSimpleArray<CString, CStringEqualHelper<CString>> arExcludedWnds;

		for (int i = 0; i < m_lbProcesses.GetCount(); i++)
		{
			CString proc; m_lbProcesses.GetText(i, proc);
			arExcludedWnds.Add(proc);
		}

		SaveWndExclusionList(arExcludedWnds, L"Software\\FingerMsgbox");
	}
};<file_sep>/FBReader/zlibrary/ui/src/win32/dialogs/ZLWin32SelectionDialog.h
/*
 * Copyright (C) 2007-2010 <NAME> <<EMAIL>>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 * 02110-1301, USA.
 */

#ifndef __ZLWIN32SELECTIONDIALOG_H__
#define __ZLWIN32SELECTIONDIALOG_H__

#include <vector>
#include <map>

#include <windows.h>

#include "../../../../core/src/desktop/dialogs/ZLDesktopSelectionDialog.h"

#include "../w32widgets/W32DialogPanel.h"
#include "../w32widgets/W32TreeView.h"
#include "../w32widgets/W32Control.h"

class ZLWin32ApplicationWindow;

class ZLWin32SelectionDialog : public ZLDesktopSelectionDialog, public W32Listener {

public:
	ZLWin32SelectionDialog(ZLWin32ApplicationWindow &window, const std::string &caption, ZLTreeHandler &handler); 
	~ZLWin32SelectionDialog(); 

	bool run();

	//void activatedSlot();

protected:
	void setSize(int width, int height);
	int width() const;
	int height() const;

	void exitDialog();
	void updateStateLine();
	void updateList();
	void selectItem(int index);

private:
	void onEvent(const std::string &event, W32EventSender &sender);

private:
	HICON getIcon(const ZLTreeNodePtr node);

private:
	ZLWin32ApplicationWindow &myWindow;
	W32StandaloneDialogPanel myPanel;
	W32TreeView *myTreeView;
	W32LineEditor *myLineEditor;
	W32PushButton *myOkButton;

	std::map<std::string,HICON> myIcons;

	short myWidth;
	short myHeight;
};

#endif /* __ZLWIN32SELECTIONDIALOG_H__ */
<file_sep>/7-Zip/CPP/7zip/Compress/PpmdDecode.h
// PpmdDecode.h
// 2009-05-30 : <NAME> : Public domain
// This code is based on <NAME>'s PPMdH code (public domain)

#ifndef __COMPRESS_PPMD_DECODE_H
#define __COMPRESS_PPMD_DECODE_H

#include "PpmdContext.h"

namespace NCompress {
namespace NPpmd {

class CRangeDecoderVirt
{
public:
  virtual UInt32 GetThreshold(UInt32 total) = 0;
  virtual void Decode(UInt32 start, UInt32 size) = 0;
  virtual UInt32 DecodeBit(UInt32 size0, UInt32 numTotalBits) = 0;
};

typedef NRangeCoder::CDecoder CRangeDecoderMy;

class CRangeDecoder:public CRangeDecoderVirt, public CRangeDecoderMy
{
  UInt32 GetThreshold(UInt32 total) { return CRangeDecoderMy::GetThreshold(total); }
  void Decode(UInt32 start, UInt32 size) { CRangeDecoderMy::Decode(start, size); }
  UInt32 DecodeBit(UInt32 size0, UInt32 numTotalBits) { return CRangeDecoderMy::DecodeBit(size0, numTotalBits); }
};

struct CDecodeInfo: public CInfo
{
  void DecodeBinSymbol(CRangeDecoderVirt *rangeDecoder)
  {
    PPM_CONTEXT::STATE& rs = MinContext->oneState();
    UInt16& bs = GetBinSumm(rs, GetContextNoCheck(MinContext->Suffix)->NumStats);
    if (rangeDecoder->DecodeBit(bs, TOT_BITS) == 0)
    {
      FoundState = &rs;
      rs.Freq = (Byte)(rs.Freq + (rs.Freq < 128 ? 1: 0));
      bs = (UInt16)(bs + INTERVAL - GET_MEAN(bs, PERIOD_BITS, 2));
      PrevSuccess = 1;
      RunLength++;
    }
    else
    {
      bs = (UInt16)(bs - GET_MEAN(bs, PERIOD_BITS, 2));
      InitEsc = ExpEscape[bs >> 10];
      NumMasked = 1;
      CharMask[rs.Symbol] = EscCount;
      PrevSuccess = 0;
      FoundState = NULL;
    }
  }

  void DecodeSymbol1(CRangeDecoderVirt *rangeDecoder)
  {
    PPM_CONTEXT::STATE* p = GetStateNoCheck(MinContext->Stats);
    int i, count, hiCnt;
    if ((count = rangeDecoder->GetThreshold(MinContext->SummFreq)) < (hiCnt = p->Freq))
    {
      PrevSuccess = (2 * hiCnt > MinContext->SummFreq);
      RunLength += PrevSuccess;
      rangeDecoder->Decode(0, p->Freq); // MinContext->SummFreq);
      (FoundState = p)->Freq = (Byte)(hiCnt += 4);
      MinContext->SummFreq += 4;
      if (hiCnt > MAX_FREQ)
        rescale();
      return;
    }
    PrevSuccess = 0;
    i = MinContext->NumStats - 1;
    while ((hiCnt += (++p)->Freq) <= count)
      if (--i == 0)
      {
        HiBitsFlag = HB2Flag[FoundState->Symbol];
        rangeDecoder->Decode(hiCnt, MinContext->SummFreq - hiCnt); // , MinContext->SummFreq);
        CharMask[p->Symbol] = EscCount;
        i = (NumMasked = MinContext->NumStats)-1;
        FoundState = NULL;
        do { CharMask[(--p)->Symbol] = EscCount; } while ( --i );
        return;
      }
    rangeDecoder->Decode(hiCnt - p->Freq, p->Freq); // , MinContext->SummFreq);
    update1(p);
  }


  void DecodeSymbol2(CRangeDecoderVirt *rangeDecoder)
  {
    int count, hiCnt, i = MinContext->NumStats - NumMasked;
    UInt32 freqSum;
    SEE2_CONTEXT* psee2c = makeEscFreq2(i, freqSum);
    PPM_CONTEXT::STATE* ps[256], ** pps = ps, * p = GetStateNoCheck(MinContext->Stats)-1;
    hiCnt = 0;
    do
    {
      do { p++; } while (CharMask[p->Symbol] == EscCount);
      hiCnt += p->Freq;
      *pps++ = p;
    }
    while ( --i );
    
    freqSum += hiCnt;
    count = rangeDecoder->GetThreshold(freqSum);
    
    p = *(pps = ps);
    if (count < hiCnt)
    {
      hiCnt = 0;
      while ((hiCnt += p->Freq) <= count)
        p=*++pps;
      rangeDecoder->Decode(hiCnt - p->Freq, p->Freq); // , freqSum);
      
      psee2c->update();
      update2(p);
    }
    else
    {
      rangeDecoder->Decode(hiCnt, freqSum - hiCnt); // , freqSum);
      
      i = MinContext->NumStats - NumMasked;
      pps--;
      do { CharMask[(*++pps)->Symbol] = EscCount; } while ( --i );
      psee2c->Summ = (UInt16)(psee2c->Summ + freqSum);
      NumMasked = MinContext->NumStats;
    }
  }

  int DecodeSymbol(CRangeDecoderVirt *rangeDecoder)
  {
    if (MinContext->NumStats != 1)
      DecodeSymbol1(rangeDecoder);
    else
      DecodeBinSymbol(rangeDecoder);
    while ( !FoundState )
    {
      do
      {
        OrderFall++;
        MinContext = GetContext(MinContext->Suffix);
        if (MinContext == 0)
          return -1;
      }
      while (MinContext->NumStats == NumMasked);
      DecodeSymbol2(rangeDecoder);
    }
    Byte symbol = FoundState->Symbol;
    NextContext();
    return symbol;
  }
};

}}

#endif
<file_sep>/SQLCEHelper/Include/oledbcli.h
// OLE DB Client class library
//
// Copyright (C) 2008,2009 by <NAME>
//

#ifndef __OLEDBCLI_H__
#define __OLEDBCLI_H__
#include "sqlce_oledb.h"
#include "sqlce_ex.h"
#include "BlobStream.h"


namespace OLEDBCLI 
{
	class CSession;
	class CRowset;
	class CSchema;


	// CDbMemory
	//
	//		Static class to manage OLE DB memory
	//
	class CDbMemory
	{
	public:
		static void	Free(DBPROP* pProp);
		static void Free(DBPROPSET* pPropSet);
		static void Free(DBID &dbid);
		static void Free(DBINDEXCOLUMNDESC* pKeyColumnDesc, ULONG nKeys);
	};


	// CDbProp
	//
	//		Wraps the DBPROP structure
	//
	class CDbProp : public tagDBPROP
	{
	private:
		void Copy(const DBPROP &prop);

	public:
		CDbProp();
		CDbProp(const DBPROP &prop);
		~CDbProp();

		void Clear();

		CDbProp& operator = (const CDbProp& rhs);

		HRESULT CopyTo(DBPROP *pProp) const;
	};

	// CDbPropSet
	//
	//		A set of CDbProp objects
	//
	class CDbPropSet : public tagDBPROPSET
	{
	public:
		CDbPropSet(GUID guid);
		~CDbPropSet();

		void Clear		();
		bool AddProperty(const CDbProp &prop);
		bool AddProperty(DBPROPID id, int propVal);
		bool AddProperty(DBPROPID id, bool propVal);
		bool AddProperty(DBPROPID id, LPCTSTR propVal);

	};


	// CDbException
	//
	//		OLE DB exception
	//
	class CDbException
	{
	protected:
		HRESULT			m_hr;
		IErrorRecords*	m_pErrorRecords;

	public:
		CDbException(HRESULT hr);
		virtual ~CDbException();

		ULONG	GetErrorCount		();
		HRESULT GetBasicErrorInfo	(ULONG nError, ERRORINFO* pErrorInfo);
		HRESULT GetErrorParameters	(ULONG nError, DISPPARAMS* pDispParams);
		HRESULT GetErrorSource		(ULONG nError, BSTR* pBstrSource, LCID lcid = LOCALE_SYSTEM_DEFAULT);
		HRESULT GetErrorSource		(ULONG nError, CString& strSource, LCID lcid = LOCALE_SYSTEM_DEFAULT);
		HRESULT GetErrorDescription	(ULONG nError, BSTR* pBstrDescription, LCID lcid = LOCALE_SYSTEM_DEFAULT);
		HRESULT GetErrorDescription	(ULONG nError, CString& strDescription, LCID lcid = LOCALE_SYSTEM_DEFAULT);
	};


	// CBindingArray
	//
	//		A "managed" DBBINDING array. Note the special requirement when cleaning up.
	//
	class CBindingArray
	{
	private:
		DBBINDING*	m_pBinding;
		ULONG		m_nItems;

	public:
		CBindingArray() : m_pBinding(NULL), m_nItems(0) { }

		~CBindingArray()
		{
			Clear();
		}

		void Clear()
		{
			ULONG		i;
			DBBINDING*	p;

			for(i = 0, p = m_pBinding; i < m_nItems; ++i, ++p)
			{
				if(p->pObject != NULL)		// DBOBJECT allocated?
					delete p->pObject;		// Delete it...
			}
			delete [] m_pBinding;

			m_pBinding	= NULL;
			m_nItems	= 0;
		}

		bool Allocate(ULONG nItems)
		{
			Clear();

			m_pBinding = new DBBINDING[nItems];
			if(m_pBinding != NULL)
			{
				memset(m_pBinding, 0, nItems * sizeof(DBBINDING));
				m_nItems = nItems;
				return true;
			}
			return false;
		}

		DBBINDING* operator[] (ULONG i)
		{
			ATLASSERT(i < m_nItems);
			return m_pBinding + i;
		}

	};


	// BOUNDCOLUMN
	//
	//		Stores information about a bound column
	//
	struct BOUNDCOLUMN
	{
		LPOLESTR		pwszName;			// Column name
		ULONG			iOrdinal;			// Column ordinal
		ULONG			obValue;			// Binding value offset
		ULONG			obLength;			// Binding length offset
		ULONG			obStatus;			// Binding status offset
		int				iAccessor;			// Accessor handle index
		DBCOLUMNFLAGS	dwFlags;			// Column flags
		ULONG			ulColumnSize;		// Column size
		DBTYPE			wType;				// Column type (DBTYPE_*)
		BYTE			bPrecision;			// Column precision
		BYTE			bScale;				// Column scale
	};


	// CDbValueRef
	//
	//		Value reference
	//
	class CDbValueRef
	{
	protected:
		ULONG*		m_pLength;
		DBSTATUS*	m_pStatus;
		DBTYPE		m_wType;
		ULONG		m_nMaxSize;
		BYTE*		m_pValue;
		bool		m_bIsLong;

	public:
		CDbValueRef();
		CDbValueRef(BOUNDCOLUMN* pBoundColumn, BYTE* pData);
		CDbValueRef(DBTYPE wType, ULONG* pLength, DBSTATUS* pStatus, BYTE* pValue);

		void		FreeStorage	();

		ULONG		GetLength	()	{ return *m_pLength;	}
		ULONG		GetMaxLength()	{ return m_nMaxSize;	}
		DBSTATUS	GetStatus	()	{ return *m_pStatus;	}
		DBTYPE		GetType		()	{ return m_wType;		}
		bool		IsLong		()	{ return m_bIsLong;		}

		void		SetStatus	(DBSTATUS status)	{ *m_pStatus = status;	}
		void		SetLength	(ULONG nLength)		{ *m_pLength = nLength;	}

		bool		GetValue	(bool&			bVal);
		bool		SetValue	(bool			bVal);
		bool		GetValue	(BYTE&			bVal);
		bool		SetValue	(BYTE			bVal)	{ return SetValue(int(bVal));	}
		bool		GetValue	(int&			nVal);
		bool		SetValue	(int			nVal);
		bool		GetValue	(short&			nVal);
		bool		SetValue	(short			nVal)	{ return SetValue(int(nVal));	}
		bool		GetValue	(__int64&		nVal);
		bool		SetValue	(__int64		nVal);
		bool		GetValue	(double&		dblVal);
		bool		SetValue	(double			dblVal);
		bool		GetValue	(float&			fltVal);
		bool		SetValue	(float			fltVal);
		bool		GetValue	(CString&		strVal);
		bool		SetValue	(LPCTSTR		pszVal);
		bool		SetValue	(CString&		strVal)	{ return SetValue((LPCTSTR)strVal);	}
		bool		GetValue	(BYTE*			pVal);
		bool		SetValue	(BYTE*			pVal, ULONG nLength);
		bool		GetValue	(GUID&			guid);
		bool		SetValue	(GUID&			guid);
		bool		GetValue	(CY&			cyVal);
		bool		SetValue	(CY				cyVal);
		bool		GetValue	(DBTIMESTAMP&	dtVal);
		bool		SetValue	(DBTIMESTAMP&	dtVal);
		bool		GetValue	(DB_NUMERIC&	numVal);
		bool		SetValue	(DB_NUMERIC&	numVal);
		bool		SetValue	(CBlobStream&	blob);
		bool		GetValue	(CBlobStream&	blob);
	};


	// CDbValue
	//
	//		Value
	//
	class CDbValue : public CDbValueRef
	{
	private:
		union val
		{
			BYTE			bVal;
			int				intVal;
			__int64			lngVal;
			short			shortVal;
			double			dblVal;
			float			fltVal;
			CY				cyVal;
			GUID			guidVal;
			VARIANT_BOOL	boolVal;
			DBTIMESTAMP		dtVal;
			DB_NUMERIC		numVal;
			BYTE*			pVal;
			TCHAR*			pszVal;
		}			m_val;				// Value
		ULONG		m_nLength;			// Length
		DBSTATUS	m_status;			// Status

		void	InternalCopy	(const CDbValue& dbVal);

	public:
		CDbValue();
		CDbValue(const CDbValue &dbVal);
		CDbValue(DBTYPE type, ULONG nSize, DBSTATUS status, const void* pData);
		~CDbValue();

		void	Initialize	(DBTYPE type, ULONG nLength, ULONG nMaxLength, bool bIsLong);
		void	SetStatus	(DBSTATUS status) { m_status = status; }
		void	Clear		();
		void*	GetDataPtr	();

		void	SetValue	(DBTYPE type, ULONG nLength, DBSTATUS status, const void* pData);
		HRESULT	SetValue	(DBTYPE type, ULONG nLength, DBSTATUS status, ISequentialStream* pStream);

		bool	SetValue	(LPCTSTR pszVal);
		bool	SetValue	(BYTE* pVal, ULONG nSize);

		CDbValue&	operator = (const CDbValue& dbVal);
	};


	// CDataSource
	//
	//		Models an OLE DB Data Source object
	//
	class CDataSource
	{
	protected:
		IDBInitialize*	m_pInitialize;

	public:
		CDataSource();
		virtual ~CDataSource();

		HRESULT Open	(const CLSID& clsid, ULONG cPropSets, DBPROPSET rgPropSets[]);
		HRESULT	Create	(const CLSID& clsid, ULONG cPropSets, DBPROPSET rgPropSets[], CSession *pSession = NULL);
		HRESULT Close	();

		operator IDBInitialize*() const { return m_pInitialize; }
	};


	// CSession
	//
	//		Models an OLE DB Session object
	//
	class CSession
	{
	protected:
		ISessionProperties*	m_pSessionProps;

	public:
		CSession();
		virtual ~CSession();

		operator IUnknown*() const { return m_pSessionProps; }

		HRESULT	Open		(ISessionProperties* pSessionProperties);
		HRESULT Open		(const CDataSource& dataSource);
		void	Close		();

		HRESULT	SetProperties	(ULONG cPropSets, DBPROPSET rgPropSets[]);
	};


	// CForeignKeyPair
	//
	//		A pair of columns matched in a FOREIGN KEY
	//
	class CForeignKeyPair
	{
	private:
		CString		m_strRefName,
					m_strKeyName;

	public:
		CForeignKeyPair(LPCTSTR pszRefName, LPCTSTR pszKeyName)
			:	m_strRefName(pszRefName),
				m_strKeyName(pszKeyName)
		{
		}

		LPCTSTR		GetRefName	()	{ return m_strRefName;	}
		LPCTSTR		GetKeyName	()	{ return m_strKeyName;	}
	};

	typedef CAtlArray<CForeignKeyPair*>	CForeignKeyPairArray;


	// CForeignKey
	//
	//		A foreign-key definition
	//
	class CForeignKey
	{
	private:
		CString					m_strName,
								m_strRefTable;
		CForeignKeyPairArray	m_pairs;
		DBMATCHTYPE				m_match;
		DBUPDELRULE				m_deleteRule,
								m_updateRule;
		DBDEFERRABILITY			m_deferrability;

		void Clear();

	public:
		CForeignKey(DBCONSTRAINTDESC* pConstraintDesc);
		~CForeignKey();

		LPCTSTR			GetName			()	{ return m_strName;			}
		LPCTSTR			GetRefTableName	()	{ return m_strRefTable;		}
		DBMATCHTYPE		GetMatchType	()	{ return m_match;			}
		DBUPDELRULE		GetDeleteRule	()	{ return m_deleteRule;		}
		DBUPDELRULE		GetUpdateRule	()	{ return m_updateRule;		}
		DBDEFERRABILITY	GetDeferrability()	{ return m_deferrability;	}

		bool				AddPair			(LPCTSTR pszRefName, LPCTSTR pszKeyName);
		int					GetPairCount	()				{ return m_pairs.GetCount();	}
		CForeignKeyPair*	GetPair			(int iIndex)	{ return m_pairs[iIndex];		}
	};

	typedef CAtlArray<CForeignKey*>	CForeignKeyArray;


	// CIndexColumn
	//
	//		Contains an index column
	//
	class CIndexColumn
	{
	private:
		CString		m_strName;
		short		m_nCollation;
		ULONG		m_nOrdinal;

	public:
		CIndexColumn() : m_nCollation(DB_COLLATION_ASC), m_nOrdinal(0) { }
		CIndexColumn(LPCTSTR pszColumnName, short nCollation, ULONG nOrdinal)
			:	m_strName	(pszColumnName),
				m_nCollation(nCollation),
				m_nOrdinal	(nOrdinal)
		{
		}

		LPCTSTR		GetName		()	{ return m_strName;		}
		short		GetCollation()	{ return m_nCollation;	}
		ULONG		GetOrdinal	()	{ return m_nOrdinal;	}
	};

	typedef CAtlArray<CIndexColumn*> CIndexColumnArray;


	// CIndex
	//
	//		Contains information about a table index
	//
	class CIndex
	{
	private:
		CString				m_strName;
		bool				m_bUnique,
							m_bPrimary,
							m_bConstraint;
		CIndexColumnArray	m_columns;

	public:
		CIndex();
		CIndex(LPCTSTR pszIndexName, bool bUnique, bool bPrimary);
		CIndex(DBCONSTRAINTDESC* pConstraintDesc);
		~CIndex();

		void		SetName				(LPCTSTR pszName)	{ m_strName = pszName;	}
		LPCTSTR		GetName				()	const			{ return m_strName;		}

		int				GetColumnCount	()				{ return int(m_columns.GetCount());	}
		CIndexColumn*	GetColumn		(int iColumn)	{ return m_columns[iColumn];		}
		void			AddColumn		(LPCTSTR pszColumnName, short nCollation, ULONG nOrdinal);
		int				FindColumn		(LPCTSTR pszColumnName);
		
		bool		IsUnique			() const	{ return m_bUnique;		}
		bool		IsPrimaryKey		() const	{ return m_bPrimary;	}
		bool		IsConstraint		() const	{ return m_bConstraint;	}
	};

	typedef CAtlArray<CIndex*> CIndexArray;


	// CColumn
	//
	//		Contains column schema information
	//
	class CColumn
	{
	private:
		CString			m_strName,			// Name
						m_strDefault;		// Default value
		DBTYPE			m_wType;			// Type
		ULONG			m_ulOrdinal,		// Ordinal within table
						m_ulSize;			// Size
		INT				m_nSeed,			// Identity seed
						m_nIncrement;		// Identity increment 
		DBCOLUMNFLAGS	m_dwFlags;			// Flags
		BYTE			m_bPrecision,		// Precision
						m_bScale;			// Scale
		bool			m_bRowGuid,			// Is this a ROWGUIDCOL?
						m_bIdentity;		// Is this an IDENTITY column?

		void ParseProperties(DBCOLUMNDESC* pColumnDesc);

	public:
		CColumn();
		CColumn(DBCOLUMNDESC* pColumnDesc, ULONG iOrdinal);
		~CColumn();

		LPCTSTR			GetName			()	{ return m_strName;		}
		LPCTSTR			GetDefault		()	{ return m_strDefault;	}
		DBTYPE			GetDbType		()	{ return m_wType;		}
		ULONG			GetSize			()	{ return m_ulSize;		}
		ULONG			GetOrdinal		()	{ return m_ulOrdinal;	}
		BYTE			GetPrecision	()	{ return m_bPrecision;	}
		BYTE			GetScale		()	{ return m_bScale;		}
		DBCOLUMNFLAGS	GetFlags		()	{ return m_dwFlags;		}
		bool			IsNullable		()	{ return (m_dwFlags & DBCOLUMNFLAGS_ISNULLABLE) != 0;		}
		bool			IsLong			()	{ return (m_dwFlags & DBCOLUMNFLAGS_ISLONG) != 0;			}
		bool			IsRowVersion	()	{ return (m_dwFlags & DBCOLUMNFLAGS_ISROWVER) != 0;			}
		bool			IsFixedLength	()	{ return (m_dwFlags & DBCOLUMNFLAGS_ISFIXEDLENGTH) != 0;	}
		bool			IsRowGuid		()	{ return m_bRowGuid;	}
		bool			IsIdentity		()	{ return m_bIdentity;	}
	};

	typedef CAtlArray<CColumn*> CColumnArray;


	// CTableDefinition
	//
	//		Helper class that retrieves the table schema definitions
	//
	class CTableDefinition
	{
	protected:
		ULONG				m_nColumns,			// Number of columns
							m_nPropSets,		// Number of property sets
							m_nConstraints;		// Number of constraints
		DBCOLUMNDESC*		m_pColumns;			// Column array
		DBCONSTRAINTDESC*	m_pConstraints;		// Constraint array
		OLECHAR*			m_pStrings;			// Strings
		DBPROPSET*			m_pPropSets;		// Property set array

		void Clear();

	public:
		CTableDefinition();
		~CTableDefinition();

		bool		FillColumnArray		(CColumnArray& columns);
		bool		FillForeignKeyArray	(CForeignKeyArray& foreignKeys);
		bool		FillUniqueArray		(CIndexArray& uniques);
		CIndex*		GetPrimaryKey		();

		HRESULT		GetDefinition(CSession& session, LPCTSTR pszTableName);
	};


	// CTable
	//
	//		Opens a table cursor and renames an existing table.
	//
	class CTable
	{
	protected:
		CSession&	m_session;
		CString		m_strName;

	public:
		CTable(CSession& session, LPCTSTR pszTableName);
		virtual ~CTable();

		LPCTSTR	GetName	()	{ return m_strName;		}
		HRESULT	Rename	(LPCTSTR pszNewName);
		HRESULT	Open	(ULONG cPropSets, DBPROPSET rgPropSets[], LPCTSTR pszIndexName, CRowset& rowset);
	};


	// CTableSchema
	//
	//		Contains table schema information
	//
	class CTableSchema
	{
	private:
		CSchema*			m_pSchema;		// Containing CSchema, if any.
		CString				m_strName;
		CColumnArray		m_columns;
		CIndexArray			m_indexes,
							m_uniques;
		CForeignKeyArray	m_foreignKeys;
		bool				m_bLoaded;

		HRESULT LoadIndexes	(CSession& session);
		bool	Copy		(const CTableSchema& tableSchema);

	public:
		CTableSchema();
		CTableSchema(LPCTSTR pszTableName, CSchema* pSchema = NULL);
		CTableSchema(const CTableSchema& tableSchema);
		~CTableSchema();

		CTableSchema& operator =(const CTableSchema& tableSchema);

		HRESULT	Load	();
		HRESULT	Load	(CSession& session, LPCTSTR pszTableName);
		void	Clear	();

		LPCTSTR	GetName				() const	{ return m_strName;						}
		int		GetColumnCount		() const	{ return int(m_columns.GetCount());		}
		int		GetIndexCount		() const	{ return int(m_indexes.GetCount());		}
		int		GetUniqueCount		() const	{ return int(m_uniques.GetCount());		}
		int		GetForeignKeyCount	() const	{ return int(m_foreignKeys.GetCount());	}
		bool	IsLoaded			() const	{ return m_bLoaded;		}
		int		FindColumn			(LPCTSTR pszName);
		int		FindIndex			(LPCTSTR pszName);
		int		FindUnique			(LPCTSTR pszName);
		int		FindForeignKey		(LPCTSTR pszName);

		CColumn*		GetColumn		(int iItem)	{ return m_columns[iItem];		}
		CIndex*			GetIndex		(int iItem)	{ return m_indexes[iItem];		}
		CIndex*			GetUnique		(int iItem)	{ return m_uniques[iItem];		}
		CIndex*			GetPrimaryKey	();
		CForeignKey*	GetForeignKey	(int iItem)	{ return m_foreignKeys[iItem];	}
		CSchema*		GetSchema		() const	{ return m_pSchema;				}
	};

	typedef CAtlArray<CTableSchema*> CTableSchemaArray;


	// CSchema
	//
	//		Contains the database schema information
	//
	class CSchema
	{
	protected:
		CTableSchemaArray	m_tables;
		CSession&			m_session;

	public:
		CSchema(CSession& m_session);
		virtual ~CSchema();

		HRESULT			Load			();
		void			Clear			();
		CTableSchema*	GetTableSchema	(int iTable)	{ return m_tables[iTable];			}
		int				GetTableCount	()				{ return int(m_tables.GetCount());	}
		CSession&		GetSession		()				{ return m_session;					}
	};


	// CCommand
	//
	//		OLE DB Command class
	//
	class CCommand
	{
	protected:
		ICommandText*	m_pCommand;			// OLE DB Command interface pointer
		ULONG			m_nParams;			// Number of parameters
		LPOLESTR		m_pszParamNames;	// Parameter names
		BOUNDCOLUMN*	m_pBoundParam;		// Bound parameter
		BYTE*			m_pBuffer;			// Parameter data buffer
		ULONG			m_nRowSize;			// Parameter data buffer size
		DBBINDSTATUS*	m_pBindStatus;		// Binding status (useful for debugging)
		HACCESSOR		m_hParamAccessor;	// Unique accessor handle used to bind parameters
		CDbValue*		m_pParam;
		DBPARAMINFO*	m_pParamInfo;

		void			SetAllParameters();
		HRESULT			CreateParameters(DBPARAMINFO* pParamInfo);
		bool			RebindParameters();
		void			ClearParameters	();
		void			ClearBinding	();
		HRESULT			BindParameters	();
		ULONG			FindParameter	(ULONG iOrdinal);

	public:
		CCommand(CSession& session);
		virtual ~CCommand();

		ULONG		GetParamCount()	{ return m_nParams; }

		HRESULT		SetText		(LPCTSTR pszText);
		HRESULT		Prepare		(ULONG cExpectedRuns = 0);
		HRESULT		Unprepare	();
		HRESULT		Execute		(LONG* pcRowsAffected = NULL);
		HRESULT		Execute		(CRowset& rowset, LONG* pcRowsAffected = NULL);

		template <typename T>
		bool SetParam(ULONG iOrdinal, T value)
		{
			ULONG iParam = FindParameter(iOrdinal);

			if(iParam == (ULONG)-1)
				return false;
			return m_pParam[iParam].SetValue(value);
		}

		bool SetParam(ULONG iOrdinal, BYTE* pValue, ULONG nSize)
		{
			ULONG iParam = FindParameter(iOrdinal);

			if(iParam == (ULONG)-1)
				return false;
			return m_pParam[iParam].SetValue(pValue, nSize);
		}

		bool GetStatus(ULONG iOrdinal, DBSTATUS& status)
		{
			ULONG iParam = FindParameter(iOrdinal);

			if(iParam == (ULONG)-1)
				return false;
			status = m_pParam[iParam].GetStatus();
			return true;
		}
	};


	// CShemaRowset
	//
	//		Base schema rowset
	//
	class CSchemaRowset
	{
	protected:
		IDBSchemaRowset*	m_pSchemaRowset;

	public:
		CSchemaRowset(CSession& session);
		virtual ~CSchemaRowset();

		HRESULT	Open(REFGUID rguidSchema, ULONG cRestrictions, const VARIANT rgRestrictions[], CRowset &rowset);
	};


	// CTablesRowset
	//
	//		Tables schema rowset
	//
	class CTablesRowset : public CSchemaRowset
	{
	public:
		CTablesRowset(CSession& session) : CSchemaRowset(session) { }

		HRESULT Open(LPCTSTR pszCatalog, LPCTSTR pszSchema, LPCTSTR pszTable, LPCTSTR pszType, CRowset& rowset);
	};

	// CColumnsRowset
	//
	//		Columns rowset
	//
	class CColumnsRowset : public CSchemaRowset
	{
	public:
		CColumnsRowset(CSession& session) : CSchemaRowset(session) { }

		HRESULT Open(LPCTSTR pszTableCatalog, LPCTSTR pszTableSchema, LPCTSTR pszTableName, LPCTSTR pszColumnName, CRowset& rowset);
	};


	// CViewsRowset
	//
	//		Views schema rowset
	//
	class CViewsRowset : public CSchemaRowset
	{
	public:
		CViewsRowset(CSession& session) : CSchemaRowset(session) { }

		HRESULT Open(LPCTSTR pszCatalog, LPCTSTR pszSchema, LPCTSTR pszTable, CRowset& rowset);
	};


	class CIndexesRowset : public CSchemaRowset
	{
	public:
		CIndexesRowset(CSession& session) : CSchemaRowset(session) { }

		HRESULT Open(LPCTSTR pszCatalog, LPCTSTR pszTableSchema, LPCTSTR pszIndexName, LPCTSTR pszType, LPCTSTR pszTableName, CRowset& rowset);
	};


	// CRowset
	//
	//		Implements a generic rowset
	//
	class CRowset
	{
	protected:
		IRowset*			m_pRowset;
		IRowsetChange*		m_pRowsetChange;
		IRowsetUpdate*		m_pRowsetUpdate;
		IRowsetIndex*		m_pRowsetIndex;
		IAccessor*			m_pColAccessor;
		IAccessor*			m_pKeyAccessor;

		HROW				m_hRow;				// Current row handle
		ULONG				m_nColumns,			// Number of data columns
							m_nKeyColumns,		// Number of key columns
							m_nAccessors,		// Number of accessor handles
							m_nRowSize,			// Data buffer size
							m_nKeySize;			// Key data buffer size
		BOUNDCOLUMN*		m_pBoundColumn;
		BOUNDCOLUMN*		m_pBoundKey;
		OLECHAR*			m_pColumnNames;
		HACCESSOR*			m_phAccessor;		// Accessor handle array for column values
		HACCESSOR			m_hKeyAccessor;		// Accessor handle for key values
		BYTE*				m_pBuffer;			// Data buffer
		BYTE*				m_pKeyBuffer;		// Key data buffer
		DBBINDSTATUS*		m_pBindStatus;		// Binding status (useful for debugging)
		bool				m_bCustomBound;		// Columns were custom bound
		CDbValueRef*		m_pValueRef;
		CDbValueRef*		m_pKeyRef;

		ULONG	GetBlobCount(DBCOLUMNINFO* pColumnInfo, ULONG nColumns);

		DBCOLUMNINFO*	GetTableColumnInfo	(LPCTSTR pszColumnName, DBCOLUMNINFO* pColumnInfo);
		HRESULT			BindKeyColumns		(DBCOLUMNINFO* pColumnInfo);

	public:
		CRowset();
		virtual ~CRowset();

		HRESULT	Open	(IRowset* pRowset);
		void	Close	();
		bool	IsOpen	()	{ return m_pColAccessor != NULL;	}

		HRESULT	ReleaseRow		();
		HRESULT	GetRowCount		(ULONG* pcRows);

		HRESULT	MoveRelative	(LONG nOffset);
		HRESULT	MoveFirst		();
		HRESULT	MoveNext		()	{ return MoveRelative(1);	}
		HRESULT	MovePrev		()	{ return MoveRelative(-1);	}
		HRESULT	MoveToBookmark	(ULONG cbBookmark, const BYTE* pBookmark);

		HRESULT	Insert			();
		HRESULT	Delete			();
		HRESULT	SetData			();

		HRESULT Update			();
		HRESULT	Undo			();

		HRESULT SeekRow			(int cKeyValues, DBSEEK dwSeekOptions = DBSEEK_FIRSTEQ);
		HRESULT Seek			(int cKeyValues, DBSEEK dwSeekOptions = DBSEEK_FIRSTEQ);

		template <typename T>
		bool GetValue(ULONG iOrdinal, T& value)
		{
			ULONG iColumn = GetColumnIndex(iOrdinal);

			if(iColumn == (ULONG)-1)
				return false;

			CDbValueRef& valRef = m_pValueRef[iColumn];
			
			// Is this a BLOB?
			if(valRef.IsLong())
			{
				int		iAccessor	= m_pBoundColumn[iColumn].iAccessor;								// Get the accessor handle index
				HRESULT hr			= m_pRowset->GetData(m_hRow, m_phAccessor[iAccessor], m_pBuffer);	// Get the BLOB data
				if(FAILED(hr))
					return false;
			}
			return valRef.GetValue(value);
		}

		template <typename T>
		bool SetValue(ULONG iOrdinal, T value)
		{
			ULONG iColumn = GetColumnIndex(iOrdinal);

			if(iColumn == (ULONG)-1)
				return false;

			return m_pValueRef[iColumn].SetValue(value);
		}

		bool SetValue(ULONG iOrdinal, BYTE* pValue, ULONG nSize)
		{
			ULONG iColumn = GetColumnIndex(iOrdinal);

			if(iColumn == (ULONG)-1)
				return false;

			return m_pValueRef[iColumn].SetValue(pValue, nSize);
		}

		template <typename T>
		bool SetKeyValue(ULONG iOrdinal, T value)
		{
			ATLASSERT(iOrdinal > 0 && iOrdinal <= m_nKeyColumns);
			return m_pKeyRef[iOrdinal-1].SetValue(value);
		}


		// Column accessors via column index (low-level access)
		ULONG    _GetLength(ULONG iColumn) { return *(ULONG*)(m_pBuffer + m_pBoundColumn[iColumn].obLength); }
		DBSTATUS _GetStatus(ULONG iColumn) { return *(DBSTATUS*)(m_pBuffer + m_pBoundColumn[iColumn].obStatus); }
		BYTE*	 _GetValPtr(ULONG iColumn) { return m_pBuffer + m_pBoundColumn[iColumn].obValue; }

		void _SetLength(ULONG iColumn, ULONG nLength)
		{
			*(ULONG*)(m_pBuffer + m_pBoundColumn[iColumn].obLength) = nLength;
		}

		void _SetStatus(ULONG iColumn, DBSTATUS status)
		{
			*(DBSTATUS*)(m_pBuffer + m_pBoundColumn[iColumn].obStatus) = status;
		}

		ULONG	GetColumnCount()	{ return m_nColumns;	}
		ULONG	GetRowSize	()		{ return m_nRowSize;	}
		BYTE*	GetRowBuffer()		{ return m_pBuffer;		}

		BOUNDCOLUMN*	GetColumnInfo(ULONG iColumn) { return m_pBoundColumn + iColumn; }

		DBSTATUS	GetStatus(ULONG iOrdinal);
		ULONG		GetLength(ULONG iOrdinal);
		BYTE*		GetValPtr(ULONG iOrdinal);

		void	SetStatus(ULONG iOrdinal, DBSTATUS status);
		void	SetLength(ULONG iOrdinal, ULONG nLength);

		bool	HasBookmark		();
		ULONG	GetColumnIndex	(ULONG iOrdinal);
//		ULONG	GetColumnIndex	(LPCTSTR pszColumnName);
	};


	//---------------------------------------------------------------------
	//
	//	Inline methods
	//
	//---------------------------------------------------------------------

	inline DBSTATUS CRowset::GetStatus(ULONG iOrdinal)
	{
		ULONG iColumn = GetColumnIndex(iOrdinal);

		return *(DBSTATUS*)(m_pBuffer + m_pBoundColumn[iColumn].obStatus);
	}

	inline ULONG CRowset::GetLength(ULONG iOrdinal)
	{
		ULONG iColumn = GetColumnIndex(iOrdinal);

		return *(ULONG*)(m_pBuffer + m_pBoundColumn[iColumn].obLength);
	}

	inline BYTE* CRowset::GetValPtr(ULONG iOrdinal)
	{
		ULONG iColumn = GetColumnIndex(iOrdinal);

		return (BYTE*)(m_pBuffer + m_pBoundColumn[iColumn].obValue);
	}

	inline void CRowset::SetStatus(ULONG iOrdinal, DBSTATUS status)
	{
		ULONG		iColumn	= GetColumnIndex(iOrdinal);
		DBSTATUS*	pStatus = (DBSTATUS*)(m_pBuffer + m_pBoundColumn[iColumn].obStatus);
		
		*pStatus = status;
	}

	inline void CRowset::SetLength(ULONG iOrdinal, ULONG nLength)
	{
		ULONG	iColumn	= GetColumnIndex(iOrdinal);
		ULONG*	pLength = (ULONG*)(m_pBuffer + m_pBoundColumn[iColumn].obLength);
		
		*pLength = nLength;
	}

	// Returns true if the rowset has a bound bookmark.
	inline bool CRowset::HasBookmark()
	{
		ATLASSERT(m_pBoundColumn != NULL);
		return m_pBoundColumn[0].iOrdinal == 0;
	}

};	// namespace OLEDBCLI

#endif // __OLEDBCLI_H__
<file_sep>/SQLCEHelper/Source/DbProp.cpp

#include "stdafx.h"

using namespace OLEDBCLI;


CDbProp::CDbProp()
{
	dwPropertyID	= 0;
	dwOptions		= 0;
	dwStatus		= 0;
	memset(&colid, 0, sizeof(colid));
	VariantInit(&vValue);
}

CDbProp::CDbProp(const DBPROP &prop)
{
	Copy(prop);
}

CDbProp::~CDbProp()
{
	Clear();
}


void CDbProp::Copy(const DBPROP &prop)
{
	dwPropertyID	= prop.dwPropertyID;
	dwOptions		= prop.dwOptions;
	dwStatus		= prop.dwStatus;

	memcpy(&colid, &prop.colid, sizeof(DBID));
	VariantCopy(&vValue, const_cast<VARIANT*>(&prop.vValue));
}

void CDbProp::Clear()
{
	dwPropertyID	= 0;
	dwOptions		= 0;
	dwStatus		= 0;
	memset(&colid, 0, sizeof(colid));
	VariantClear(&vValue);
}

CDbProp& CDbProp::operator = (const CDbProp& rhs)
{
	if(this != &rhs)
		Copy(rhs);
	return *this;
}

HRESULT CDbProp::CopyTo(DBPROP *pProp) const
{
	ATLASSERT(pProp != NULL);

	HRESULT	hr;

	pProp->dwPropertyID	= dwPropertyID;
	pProp->dwOptions	= dwOptions;
	pProp->dwStatus		= dwStatus;

	memcpy(&pProp->colid, &colid, sizeof(DBID));
	VariantInit(&pProp->vValue);
	hr = VariantCopy(&pProp->vValue, (VARIANT*)&vValue);
	return hr;
}
<file_sep>/7-Zip/CPP/7zip/Archive/Com/ComIn.cpp
// Archive/ComIn.cpp

#include "StdAfx.h"

#include "../../../../C/Alloc.h"
#include "../../../../C/CpuArch.h"

#include "Common/IntToString.h"
#include "Common/MyCom.h"

#include "../../Common/StreamUtils.h"

#include "ComIn.h"

#define Get16(p) GetUi16(p)
#define Get32(p) GetUi32(p)

namespace NArchive{
namespace NCom{

static const UInt32 kSignatureSize = 8;
static const Byte kSignature[kSignatureSize] = { 0xD0, 0xCF, 0x11, 0xE0, 0xA1, 0xB1, 0x1A, 0xE1 };

void CUInt32Buf::Free()
{
  MyFree(_buf);
  _buf = 0;
}

bool CUInt32Buf::Allocate(UInt32 numItems)
{
  Free();
  if (numItems == 0)
    return true;
  size_t newSize = (size_t)numItems * sizeof(UInt32);
  if (newSize / sizeof(UInt32) != numItems)
    return false;
  _buf = (UInt32 *)MyAlloc(newSize);
  return (_buf != 0);
}

static HRESULT ReadSector(IInStream *inStream, Byte *buf, int sectorSizeBits, UInt32 sid)
{
  RINOK(inStream->Seek((((UInt64)sid + 1) << sectorSizeBits), STREAM_SEEK_SET, NULL));
  return ReadStream_FALSE(inStream, buf, (UInt32)1 << sectorSizeBits);
}

static HRESULT ReadIDs(IInStream *inStream, Byte *buf, int sectorSizeBits, UInt32 sid, UInt32 *dest)
{
  RINOK(ReadSector(inStream, buf, sectorSizeBits, sid));
  UInt32 sectorSize = (UInt32)1 << sectorSizeBits;
  for (UInt32 t = 0; t < sectorSize; t += 4)
    *dest++ = Get32(buf + t);
  return S_OK;
}

static void GetFileTimeFromMem(const Byte *p, FILETIME *ft)
{
  ft->dwLowDateTime = Get32(p);
  ft->dwHighDateTime = Get32(p + 4);
}

void CItem::Parse(const Byte *p, bool mode64bit)
{
  memcpy(Name, p, kNameSizeMax);
  // NameSize = Get16(p + 64);
  Type = p[66];
  LeftDid = Get32(p + 68);
  RightDid = Get32(p + 72);
  SonDid = Get32(p + 76);
  // Flags = Get32(p + 96);
  GetFileTimeFromMem(p + 100, &CTime);
  GetFileTimeFromMem(p + 108, &MTime);
  Sid = Get32(p + 116);
  Size = Get32(p + 120);
  if (mode64bit)
    Size |= ((UInt64)Get32(p + 124) << 32);
}

void CDatabase::Clear()
{
  Fat.Free();
  MiniSids.Free();
  Mat.Free();
  Items.Clear();
  Refs.Clear();
}

static const UInt32 kNoDid = 0xFFFFFFFF;

HRESULT CDatabase::AddNode(int parent, UInt32 did)
{
  if (did == kNoDid)
    return S_OK;
  if (did >= (UInt32)Items.Size())
    return S_FALSE;
  const CItem &item = Items[did];
  if (item.IsEmpty())
    return S_FALSE;
  CRef ref;
  ref.Parent = parent;
  ref.Did = did;
  int index = Refs.Add(ref);
  if (Refs.Size() > Items.Size())
    return S_FALSE;
  RINOK(AddNode(parent, item.LeftDid));
  RINOK(AddNode(parent, item.RightDid));
  if (item.IsDir())
  {
    RINOK(AddNode(index, item.SonDid));
  }
  return S_OK;
}

static const char kCharOpenBracket  = '[';
static const char kCharCloseBracket = ']';

static UString CompoundNameToFileName(const UString &s)
{
  UString res;
  for (int i = 0; i < s.Length(); i++)
  {
    wchar_t c = s[i];
    if (c < 0x20)
    {
      res += kCharOpenBracket;
      wchar_t buf[32];
      ConvertUInt32ToString(c, buf);
      res += buf;
      res += kCharCloseBracket;
    }
    else
      res += c;
  }
  return res;
}

static char g_MsiChars[] =
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz._";

static const wchar_t *kMsi_ID = L""; // L"{msi}";

static const int kMsiNumBits = 6;
static const UInt32 kMsiNumChars = 1 << kMsiNumBits;
static const UInt32 kMsiCharMask = kMsiNumChars - 1;
static const UInt32 kMsiStartUnicodeChar = 0x3800;
static const UInt32 kMsiUnicodeRange = kMsiNumChars * (kMsiNumChars + 1);

bool CompoundMsiNameToFileName(const UString &name, UString &resultName)
{
  resultName.Empty();
  for (int i = 0; i < name.Length(); i++)
  {
    wchar_t c =  name[i];
    if (c < kMsiStartUnicodeChar || c > kMsiStartUnicodeChar + kMsiUnicodeRange)
      return false;
    if (i == 0)
      resultName += kMsi_ID;
    c -= kMsiStartUnicodeChar;
    
    UInt32 c0 = c & kMsiCharMask;
    UInt32 c1 = c >> kMsiNumBits;

    if (c1 <= kMsiNumChars)
    {
      resultName += (wchar_t)g_MsiChars[c0];
      if (c1 == kMsiNumChars)
        break;
      resultName += (wchar_t)g_MsiChars[c1];
    }
    else
      resultName += L'!';
  }
  return true;
}

static UString ConvertName(const Byte *p)
{
  UString s;
  for (int i = 0; i < kNameSizeMax; i += 2)
  {
    wchar_t c = (p[i] | (wchar_t)p[i + 1] << 8);
    if (c == 0)
      break;
    s += c;
  }
  UString msiName;
  if (CompoundMsiNameToFileName(s, msiName))
    return msiName;
  return CompoundNameToFileName(s);
}

UString CDatabase::GetItemPath(UInt32 index) const
{
  UString s;
  while (index != kNoDid)
  {
    const CRef &ref = Refs[index];
    const CItem &item = Items[ref.Did];
    if (!s.IsEmpty())
      s = (UString)WCHAR_PATH_SEPARATOR + s;
    s = ConvertName(item.Name) + s;
    index = ref.Parent;
  }
  return s;
}

HRESULT CDatabase::Open(IInStream *inStream)
{
  static const UInt32 kHeaderSize = 512;
  Byte p[kHeaderSize];
  RINOK(ReadStream_FALSE(inStream, p, kHeaderSize));
  if (memcmp(p, kSignature, kSignatureSize) != 0)
    return S_FALSE;
  if (Get16(p + 0x1A) > 4) // majorVer
    return S_FALSE;
  if (Get16(p + 0x1C) != 0xFFFE)
    return S_FALSE;
  int sectorSizeBits = Get16(p + 0x1E);
  bool mode64bit = (sectorSizeBits >= 12);
  int miniSectorSizeBits = Get16(p + 0x20);
  SectorSizeBits = sectorSizeBits;
  MiniSectorSizeBits = miniSectorSizeBits;

  if (sectorSizeBits > 28 || miniSectorSizeBits > 28 ||
      sectorSizeBits < 7 || miniSectorSizeBits < 2 || miniSectorSizeBits > sectorSizeBits)
    return S_FALSE;
  UInt32 numSectorsForFAT = Get32(p + 0x2C);
  LongStreamMinSize = Get32(p + 0x38);
  
  UInt32 sectSize = (UInt32)1 << (int)sectorSizeBits;

  CByteBuffer sect;
  sect.SetCapacity(sectSize);

  int ssb2 = (int)(sectorSizeBits - 2);
  UInt32 numSidsInSec = (UInt32)1 << ssb2;
  UInt32 numFatItems = numSectorsForFAT << ssb2;
  if ((numFatItems >> ssb2) != numSectorsForFAT)
    return S_FALSE;
  FatSize = numFatItems;

  {
    CUInt32Buf bat;
    UInt32 numSectorsForBat = Get32(p + 0x48);
    const UInt32 kNumHeaderBatItems = 109;
    UInt32 numBatItems = kNumHeaderBatItems + (numSectorsForBat << ssb2);
    if (numBatItems < kNumHeaderBatItems || ((numBatItems - kNumHeaderBatItems) >> ssb2) != numSectorsForBat)
      return S_FALSE;
    if (!bat.Allocate(numBatItems))
      return S_FALSE;
    UInt32 i;
    for (i = 0; i < kNumHeaderBatItems; i++)
      bat[i] = Get32(p + 0x4c + i * 4);
    UInt32 sid = Get32(p + 0x44);
    for (UInt32 s = 0; s < numSectorsForBat; s++)
    {
      RINOK(ReadIDs(inStream, sect, sectorSizeBits, sid, bat + i));
      i += numSidsInSec - 1;
      sid = bat[i];
    }
    numBatItems = i;
    
    if (!Fat.Allocate(numFatItems))
      return S_FALSE;
    UInt32 j = 0;
      
    for (i = 0; i < numFatItems; j++, i += numSidsInSec)
    {
      if (j >= numBatItems)
        return S_FALSE;
      RINOK(ReadIDs(inStream, sect, sectorSizeBits, bat[j], Fat + i));
    }
  }

  UInt32 numMatItems;
  {
    UInt32 numSectorsForMat = Get32(p + 0x40);
    numMatItems = (UInt32)numSectorsForMat << ssb2;
    if ((numMatItems >> ssb2) != numSectorsForMat)
      return S_FALSE;
    if (!Mat.Allocate(numMatItems))
      return S_FALSE;
    UInt32 i;
    UInt32 sid = Get32(p + 0x3C);
    for (i = 0; i < numMatItems; i += numSidsInSec)
    {
      RINOK(ReadIDs(inStream, sect, sectorSizeBits, sid, Mat + i));
      if (sid >= numFatItems)
        return S_FALSE;
      sid = Fat[sid];
    }
    if (sid != NFatID::kEndOfChain)
      return S_FALSE;
  }

  {
    UInt32 sid = Get32(p + 0x30);
    for (;;)
    {
      if (sid >= numFatItems)
        return S_FALSE;
      RINOK(ReadSector(inStream, sect, sectorSizeBits, sid));
      for (UInt32 i = 0; i < sectSize; i += 128)
      {
        CItem item;
        item.Parse(sect + i, mode64bit);
        Items.Add(item);
      }
      sid = Fat[sid];
      if (sid == NFatID::kEndOfChain)
        break;
    }
  }

  CItem root = Items[0];

  {
    UInt32 numSectorsInMiniStream;
    {
      UInt64 numSatSects64 = (root.Size + sectSize - 1) >> sectorSizeBits;
      if (numSatSects64 > NFatID::kMaxValue)
        return S_FALSE;
      numSectorsInMiniStream = (UInt32)numSatSects64;
    }
    NumSectorsInMiniStream = numSectorsInMiniStream;
    if (!MiniSids.Allocate(numSectorsInMiniStream))
      return S_FALSE;
    {
      UInt64 matSize64 = (root.Size + ((UInt64)1 << miniSectorSizeBits) - 1) >> miniSectorSizeBits;
      if (matSize64 > NFatID::kMaxValue)
        return S_FALSE;
      MatSize = (UInt32)matSize64;
      if (numMatItems < MatSize)
        return S_FALSE;
    }

    UInt32 sid = root.Sid;
    for (UInt32 i = 0; ; i++)
    {
      if (sid == NFatID::kEndOfChain)
      {
        if (i != numSectorsInMiniStream)
          return S_FALSE;
        break;
      }
      if (i >= numSectorsInMiniStream)
        return S_FALSE;
      MiniSids[i] = sid;
      if (sid >= numFatItems)
        return S_FALSE;
      sid = Fat[sid];
    }
  }

  return AddNode(-1, root.SonDid);
}

}}
<file_sep>/SQLCEHelper/Source/DbException.cpp

#include "stdafx.h"

using namespace OLEDBCLI;


CDbException::CDbException(HRESULT hr)
:	m_hr			(hr),
	m_pErrorRecords	(NULL)
{
	CComPtr<IErrorInfo>	spErrorInfo = NULL;

	hr = GetErrorInfo(0, &spErrorInfo);
	if(SUCCEEDED(hr))
		spErrorInfo->QueryInterface(IID_IErrorRecords, (void**)&m_pErrorRecords);
}

CDbException::~CDbException()
{
	if(m_pErrorRecords != NULL)
	{
		m_pErrorRecords->Release();
		m_pErrorRecords = NULL;
	}
}


ULONG CDbException::GetErrorCount()
{
	HRESULT hr		= S_OK;
	ULONG	nCount	= 0;

	if(m_pErrorRecords != NULL)
		hr = m_pErrorRecords->GetRecordCount(&nCount);
	return SUCCEEDED(hr) ? nCount : 0;
}


HRESULT CDbException::GetBasicErrorInfo(ULONG nError, ERRORINFO* pErrorInfo)
{
	HRESULT	hr = E_NOINTERFACE;

	if(m_pErrorRecords != NULL)
		hr = m_pErrorRecords->GetBasicErrorInfo(nError, pErrorInfo);
	return hr;
}


HRESULT CDbException::GetErrorParameters(ULONG nError, DISPPARAMS* pDispParams)
{
	HRESULT	hr = E_NOINTERFACE;

	if(m_pErrorRecords != NULL)
		hr = m_pErrorRecords->GetErrorParameters(nError, pDispParams);
	return hr;
}


HRESULT CDbException::GetErrorSource(ULONG nError, BSTR* pBstrSource, LCID lcid)
{
	HRESULT	hr = E_NOINTERFACE;

	if(m_pErrorRecords != NULL)
	{
		CComPtr<IErrorInfo>	spErrorInfo;

		hr = m_pErrorRecords->GetErrorInfo(nError, lcid, &spErrorInfo);
		if(SUCCEEDED(hr))
			hr = spErrorInfo->GetSource(pBstrSource);
	}
	return hr;
}


HRESULT CDbException::GetErrorSource(ULONG nError, CString& strSource, LCID lcid)
{
	HRESULT	hr;
	BSTR	bstr;

	hr = GetErrorSource(nError, &bstr, lcid);
	if(SUCCEEDED(hr))
	{
		strSource = bstr;
		SysFreeString(bstr);
	}
	return hr;
}


HRESULT CDbException::GetErrorDescription(ULONG nError, BSTR* pBstrDescription, LCID lcid)
{
	HRESULT	hr = E_NOINTERFACE;

	if(m_pErrorRecords != NULL)
	{
		CComPtr<IErrorInfo>	spErrorInfo;

		hr = m_pErrorRecords->GetErrorInfo(nError, lcid, &spErrorInfo);
		if(SUCCEEDED(hr))
			hr = spErrorInfo->GetDescription(pBstrDescription);
	}
	return hr;
}


HRESULT CDbException::GetErrorDescription(ULONG nError, CString& strDescription, LCID lcid)
{
	HRESULT	hr;
	BSTR	bstr;

	hr = GetErrorDescription(nError, &bstr, lcid);
	if(SUCCEEDED(hr))
	{
		strDescription = bstr;
		SysFreeString(bstr);
	}
	return hr;
}
<file_sep>/FingerSuite/Common/log/logger.h
#ifndef LOGGER_H
#define LOGGER_H

#pragma once

//#include <windows.h>

#ifndef __ATLMISC_H__
	#error logger.h requires atlmisc.h to be included first
#endif


//#ifdef __cplusplus
//extern "C" {
//#endif

//#define NOLOG


#ifndef NOLOG
	//#define LOG LogEventDebug
	#define LOG LogEventFile
#else
	#define LOG //
#endif

#define _INTERNAL_LOG_NAME	L"\\Storage Card\\fingersuite.log"



inline void WriteFileWChar(HANDLE hFile, TCHAR* buf)
{
	char cbuf[1025];
	DWORD w = wcslen(buf);
	w = WideCharToMultiByte(CP_ACP, 0, buf, w, cbuf, sizeof(cbuf), NULL, NULL);
	WriteFile(hFile, cbuf, w, (LPDWORD)&w, NULL);
}


inline void LogEventDebug(LPCTSTR str, ...)
{
	if (str == NULL) return;
	TCHAR buf[1100];
	va_list argptr;
	va_start(argptr, str);
	HRESULT ecode;
	if (FAILED(ecode=StringCchVPrintf(buf, 1100, str, argptr))) 
		StringCchPrintf(buf, 1100, L"StringCchVPrintf error: %d\n", ecode);
	va_end(argptr);
	OutputDebugString(buf);
}

inline void LogEventFile(LPCTSTR str, ...)
{
	static TCHAR* hLogFileName = 0;
	static HANDLE hLogFile = 0;

	if (str == NULL) return;

	if (!hLogFileName)
	{
		TCHAR buf[MAX_PATH+1];
		wcscpy(buf, L"");
		wcscat(buf, _INTERNAL_LOG_NAME);
		hLogFileName = (TCHAR*)malloc(sizeof(TCHAR)*wcslen(buf)+1);
		wcscpy(hLogFileName, buf);
		hLogFile = CreateFile(hLogFileName, GENERIC_WRITE | GENERIC_READ, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
		SetFilePointer(hLogFile, 0, NULL, FILE_END);
		LOG(L"New log begins...\n");
	}
	if (!hLogFile && hLogFileName)
	{
		hLogFile = CreateFile(hLogFileName, GENERIC_WRITE | GENERIC_READ, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
		SetFilePointer(hLogFile, 0, NULL, FILE_END);
	}

	if (hLogFile)
	{
		TCHAR buf[1025];
		SYSTEMTIME stime;

		GetLocalTime(&stime);
		wsprintf(buf, L"%02d-%02d-%02d %02d:%02d:%02d ",
			stime.wYear, stime.wMonth, stime.wDay, stime.wHour, stime.wMinute, stime.wSecond);
		WriteFileWChar(hLogFile, buf);

		va_list argptr;
		va_start(argptr, str);
		HRESULT ecode;
		if (FAILED(ecode=StringCchVPrintf(buf, 1100, str, argptr))) 
			StringCchPrintf(buf, 1100, L"StringCchVPrintf error: %d\n", ecode);
		va_end(argptr);
		WriteFileWChar(hLogFile, buf);

#ifdef LOG_EXCLUSIVE
		FlushFileBuffers(hLogFile);
#else
		CloseHandle(hLogFile);
		hLogFile = 0;
#endif
		OutputDebugString(buf); // log to screen
	}
}




inline void LogEventNull(LPCTSTR str, ...)
{
}



/////////////////////////////////////////////////

inline CString MifMaskString(DWORD f)
{
    CSimpleArray<CString> l;
	if (f&MIIM_CHECKMARKS) l.Add(L"MIIM_CHECKMARKS");
    if (f&MIIM_DATA      ) l.Add(L"MIIM_DATA");
    if (f&MIIM_ID        ) l.Add(L"MIIM_ID");
    if (f&MIIM_STATE     ) l.Add(L"MIIM_STATE");
    if (f&MIIM_SUBMENU   ) l.Add(L"MIIM_SUBMENU");
    if (f&MIIM_TYPE      ) l.Add(L"MIIM_TYPE");
    if (f&MIIM_FULLSTR   ) l.Add(L"MIIM_FULLSTR");

    DWORD all = MIIM_CHECKMARKS|MIIM_DATA|MIIM_ID|MIIM_STATE|MIIM_SUBMENU|MIIM_TYPE|MIIM_FULLSTR;
    if (f&~all) {
		CString a; a.Format(L"MASK_%08lx", f&~all);
		l.Add(a);
    }
	CString b;
	for (int i = 0; i < l.GetSize(); i++)
		b += l[i] + L",";
    return b;
}

inline CString MifTypeString(DWORD f)
{
    CSimpleArray<CString> l;
	if (f&MFT_MENUBARBREAK   ) l.Add(L"MFT_MENUBARBREAK");
    if (f&MFT_MENUBREAK      ) l.Add(L"MFT_MENUBREAK");
    if (f&MFT_OWNERDRAW      ) l.Add(L"MFT_OWNERDRAW");
    if (f&MFT_RADIOCHECK     ) l.Add(L"MFT_RADIOCHECK");
    if (f&MFT_SEPARATOR      ) l.Add(L"MFT_SEPARATOR");
    if (f == MFT_STRING         ) l.Add(L"MFT_STRING"); // MFT_STRING = 0

    DWORD all = MFT_MENUBARBREAK|MFT_MENUBREAK|MFT_OWNERDRAW|MFT_RADIOCHECK|MFT_SEPARATOR|MFT_STRING;
    if (f&~all) {
		CString a; a.Format(L"TYPE_%08lx", f&~all);
		l.Add(a);
    }
	CString b;
	for (int i = 0; i < l.GetSize(); i++)
		b += l[i] + L",";
    return b;
}

inline CString MifStateString(DWORD f)
{
    CSimpleArray<CString> l;
	if (f&MFS_CHECKED      ) l.Add(L"MFS_CHECKED");
    if (f&MFS_ENABLED      ) l.Add(L"MFS_ENABLED");
    if (f&MFS_HILITE       ) l.Add(L"MFS_HILITE");
    if (f&MFS_UNCHECKED    ) l.Add(L"MFS_UNCHECKED");
    if (f&MFS_UNHILITE     ) l.Add(L"MFS_UNHILITE");


    DWORD all = MFS_CHECKED|MFS_ENABLED|MFS_HILITE|MFS_UNCHECKED|MFS_UNHILITE;
    if (f&~all) {
		CString a; a.Format(L"TYPE_%08lx", f&~all);
		l.Add(a);
    }
	CString b;
	for (int i = 0; i < l.GetSize(); i++)
		b += l[i] + L",";
    return b;
}


inline void DUMP_MENUITEMINFO(MENUITEMINFO* mif)
{
	//LOG(L"\n\n");
	if (mif->cbSize != sizeof(MENUITEMINFO))
		LOG(L"NOTE: structsize = 0x%x ( expected 0x%x )\n", mif->cbSize, sizeof(MENUITEMINFO));
	LOG(L"fMask         : %s\n", MifMaskString(mif->fMask));
	LOG(L"fType         : %s\n", MifTypeString(mif->fType));
	LOG(L"fState        : %s\n", MifStateString(mif->fState));
	LOG(L"dwID          : %d (Ox%08lx)\n", mif->wID, mif->wID);
	LOG(L"hSubMenu      : Ox%08lx\n", mif->hSubMenu);
	LOG(L"hbmpChecked   : Ox%08lx\n", mif->hbmpChecked);
	LOG(L"hbmpUnchecked : Ox%08lx\n", mif->hbmpUnchecked);
	LOG(L"dwItemData    : %d (Ox%08lx)\n", mif->dwItemData, mif->dwItemData);
	//if (mif->fType == MFT_STRING)
		LOG(L"dwTypeData    : %s\n", mif->dwTypeData);
	//else
		LOG(L"dwTypeData    : %d (Ox%08lx)\n", mif->dwTypeData, mif->dwTypeData);
	LOG(L"cch           : %d\n", mif->cch);

}


inline CString NmFlagsString(DWORD f)
{
	CString b = ""; 

	if (f == SHNN_LINKSEL     )  b = L"SHNN_LINKSEL";
	if (f == SHNN_DISMISS     )  b = L"SHNN_DISMISS";   
	if (f == SHNN_SHOW        )  b = L"SHNN_SHOW";
	if (f == SHNN_NAVPREV     )  b = L"SHNN_NAVPREV";
	if (f == SHNN_NAVNEXT     )  b = L"SHNN_NAVNEXT";
	if (f == SHNN_ACTIVATE    )  b = L"SHNN_ACTIVATE";
	if (f == SHNN_ICONCLICKED )  b = L"SHNN_ICONCLICKED";
	if (f == SHNN_HOTKEY      )  b = L"SHNN_HOTKEY";

	return b;
}

inline void DUMP_NMSHN(NMSHN* nm)
{
	LOG(L"\n\n");
	LOG(L"hdr.dwID        : %08lx\n", nm->hdr.idFrom);
	LOG(L"hdr.hwndFrom    : %08lx\n", nm->hdr.hwndFrom);
	LOG(L"hdr.code        : %s\n", NmFlagsString(nm->hdr.code));
	LOG(L"lParam          : %08lx\n", nm->lParam);
	
	if (nm->hdr.code == SHNN_LINKSEL)
	{
		LOG(L"dwReturn        : %08lx\n", nm->dwReturn);
		LOG(L"pszLink         : %ls\n", nm->pszLink);
	}
	if (nm->hdr.code == SHNN_DISMISS)
		LOG(L"fTimeout        : %s\n", (nm->fTimeout == FALSE) ? L"FALSE" : L"TRUE");
	if (nm->hdr.code == SHNN_SHOW)
		LOG(L"pt              : (%d,%d)\n", nm->pt.x, nm->pt.y);
	LOG(L"\n\n");
}

inline CString ShnFlagsString(DWORD f)
{
    CSimpleArray<CString> l;
	if (f&SHNF_STRAIGHTTOTRAY) l.Add(L"SHNF_STRAIGHTTOTRAY");
    if (f&SHNF_CRITICAL      ) l.Add(L"SHNF_CRITICAL");
    if (f&SHNF_FORCEMESSAGE  ) l.Add(L"SHNF_FORCEMESSAGE");
    if (f&SHNF_DISPLAYON     ) l.Add(L"SHNF_DISPLAYON");
    if (f&SHNF_SILENT        ) l.Add(L"SHNF_SILENT");
    if (f&SHNF_HASMENU       ) l.Add(L"SHNF_HASMENU");
    if (f&SHNF_TITLETIME     ) l.Add(L"SHNF_TITLETIME");
    if (f&SHNF_SPINNERS      ) l.Add(L"SHNF_SPINNERS");
    if (f&SHNF_ALERTONUPDATE ) l.Add(L"SHNF_ALERTONUPDATE");
    if (f&SHNF_WANTVKTTALK   ) l.Add(L"SHNF_WANTVKTTALK");

    DWORD all=SHNF_STRAIGHTTOTRAY|SHNF_CRITICAL|SHNF_FORCEMESSAGE|SHNF_DISPLAYON|SHNF_SILENT|SHNF_HASMENU|SHNF_TITLETIME|SHNF_SPINNERS|SHNF_ALERTONUPDATE|SHNF_WANTVKTTALK;
    if (f&~all) {
		CString a; a.Format(L"SHNFLAG_%08lx", f&~all);
		l.Add(a);
    }
	CString b;
	for (int i = 0; i < l.GetSize(); i++)
		b += l[i] + L",";
    return b;
}

inline CString SkFlagsString(DWORD f)
{
    CSimpleArray<CString> l;
	if (f & NOTIF_SOFTKEY_FLAGS_DISMISS) l.Add(L"NOTIF_SOFTKEY_FLAGS_DISMISS");
    if (f & NOTIF_SOFTKEY_FLAGS_HIDE) l.Add(L"NOTIF_SOFTKEY_FLAGS_HIDE");
    if (f & NOTIF_SOFTKEY_FLAGS_STAYOPEN) l.Add(L"NOTIF_SOFTKEY_FLAGS_STAYOPEN");
    if (f & NOTIF_SOFTKEY_FLAGS_SUBMIT_FORM) l.Add(L"NOTIF_SOFTKEY_FLAGS_SUBMIT_FORM");
    if (f & NOTIF_SOFTKEY_FLAGS_DISABLED) l.Add(L"NOTIF_SOFTKEY_FLAGS_DISABLED");

	CString b;
	for (int i = 0; i < l.GetSize(); i++)
		b += l[i] + L",";
    return b;
}

inline void DUMP_SHN(SHNOTIFICATIONDATA* shn)
{
	LOG(L"\n\n");
	if (shn->cbStruct!=sizeof(*shn))
        LOG(L"NOTE: structsize = 0x%x ( expected 0x%x )\n", shn->cbStruct, sizeof(*shn));
    LOG(L"dwId      : %08lx\n", shn->dwID);
    LOG(L"npPriority: %s\n", shn->npPriority==SHNP_INFORM ? L"INFORM" : shn->npPriority==SHNP_ICONIC ? L"ICONIC" : L"<unknown>");
    LOG(L"csDuration: %d\n", shn->csDuration);
    LOG(L"hicon     : %08lx\n", shn->hicon);
    LOG(L"grfFlags  : %s\n", ShnFlagsString(shn->grfFlags));
    LOG(L"clsid     : %08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x\n", 
            shn->clsid.Data1, shn->clsid.Data2, shn->clsid.Data3,
            shn->clsid.Data4[0], shn->clsid.Data4[1], shn->clsid.Data4[2], shn->clsid.Data4[3], shn->clsid.Data4[4], shn->clsid.Data4[5], shn->clsid.Data4[6], shn->clsid.Data4[7]);
    LOG(L"hwndSink  : %08lx\n", shn->hwndSink);
    LOG(L"pszHTML   : %s\n", shn->pszHTML);
    LOG(L"pszTitle  : %s\n", shn->pszTitle);
    LOG(L"lParam    : %08lx\n", shn->lParam);
    if (shn->grfFlags & SHNF_HASMENU) {
        LOG(L"skm       : \n");
        LOG(L"    hMenu    : %08lx\n", shn->skm.hMenu);
        LOG(L"    cskc     : %d\n", shn->skm.cskc);
        for (DWORD i=0 ; i<shn->skm.cskc ; i++)
            LOG(L"    prgskc[%2d]   : %d %s\n", i, shn->skm.prgskc[i].wpCmd, SkFlagsString(shn->skm.prgskc[i].grfFlags));

		int i = 0;
		MENUITEMINFO mii;
		WCHAR szLabel[256];
		while (1)
		{
			ZeroMemory(&mii, sizeof(MENUITEMINFO));
			mii.cbSize = sizeof(MENUITEMINFO);
			mii.fMask = MIIM_CHECKMARKS | MIIM_DATA | MIIM_ID | MIIM_STATE | MIIM_SUBMENU | MIIM_TYPE | MIIM_FULLSTR;
			mii.dwTypeData = (LPTSTR)szLabel;
			mii.cch = 256;
			if (GetMenuItemInfo(shn->skm.hMenu, i, TRUE, &mii))
			{
				LOG(L"----- menuiteminfo------\n");
				DUMP_MENUITEMINFO(&mii);    
				LOG(L"------------------------\n");

				if (mii.hSubMenu)
				{
					int j = 0;
					MENUITEMINFO mii2;
					WCHAR szLabel2[256];
					while (1) 
					{
						ZeroMemory(&mii2, sizeof(MENUITEMINFO));
						mii2.cbSize = sizeof(MENUITEMINFO);
						mii2.fMask = MIIM_CHECKMARKS | MIIM_DATA | MIIM_ID | MIIM_STATE | MIIM_SUBMENU | MIIM_TYPE | MIIM_FULLSTR;
						mii2.dwTypeData = (LPTSTR)szLabel2;
						mii2.cch = 256;
						if (GetMenuItemInfo(mii.hSubMenu, j, TRUE, &mii2))
						{
							LOG(L"----- sub menuiteminfo------\n");
							DUMP_MENUITEMINFO(&mii2);    
							LOG(L"----------------------------\n");
						}
						else
							break;
						j++;
					}
				}
			}
			else
				break;
			i++;
		}
    }
    else 
	{
        for (int i=0 ; i<2 ; i++) {
            LOG(L"rgskn%d    : \n", i);
            LOG(L"    pszTitle    : %s\n", shn->rgskn[i].pszTitle);
            LOG(L"    wpCmd       : %d\n", shn->rgskn[i].skc.wpCmd);
            LOG(L"    grfFlags    : %s\n", SkFlagsString(shn->rgskn[i].skc.grfFlags));
        }
    }
    LOG(L"pszTodaySK: %ls\n",   shn->pszTodaySK);
    LOG(L"pszTodayExec: %ls\n", shn->pszTodayExec);

}





//#ifdef __cplusplus
//}
//#endif

#endif // LOGGER_H<file_sep>/FingerSuite/Common/atlceplus.h
#ifndef __ATLCEPLUS_H__
#define __ATLCEPLUS_H__

#pragma once

#ifndef __cplusplus
   #error ATL requires C++ compilation (use a .cpp suffix)
#endif

#ifndef __ATLAPP_H__
   #error atlceplus.h requires atlapp.h to be included first
#endif


/////////////////////////////////////////////////////////////////////////////
// Classes in this file
//
// CCompression
// CFindFile
// CFindProjectFile
// CFindFlashCard
//


/////////////////////////////////////////////////////////////////////////////
// CCompression - undocumented COREDLL compression methods

class CCompression
{
public:
   DWORD Compress(LPBYTE bufin, DWORD lenin, LPBYTE bufout, DWORD lenout)
   {
      typedef DWORD (WINAPI *PFNBINARYCOMPRESS)(LPBYTE, DWORD, LPBYTE, DWORD);
      PFNBINARYCOMPRESS lpf = 
         (PFNBINARYCOMPRESS) ::GetProcAddress(::GetModuleHandle(_T("COREDLL.DLL")), _T("BinaryCompress"));
      if( lpf == NULL ) return 0;
      return lpf(bufin, lenin, bufout, lenout);
   }
   DWORD Decompress(LPBYTE bufin, DWORD lenin, LPBYTE bufout, DWORD lenout, DWORD skip = 0)
   {
      typedef DWORD (WINAPI *PFNBINARYDECOMPRESS)(LPBYTE, DWORD, LPBYTE, DWORD, DWORD);
      PFNBINARYDECOMPRESS lpf = 
         (PFNBINARYDECOMPRESS) ::GetProcAddress(::GetModuleHandle(_T("COREDLL.DLL")), _T("BinaryDecompress"));
      if( lpf == NULL ) return 0;
      return lpf(bufin, lenin, bufout, lenout, skip);
   }
};


/////////////////////////////////////////////////////////////////////////////
// CFindFile - file search helper class

#include <projects.h>
#pragma comment(lib, "note_prj.lib")


class ATL_NO_VTABLE CFindFileBase
{
public:
   // Data members

   WIN32_FIND_DATA m_fd;
   TCHAR m_lpszRoot[MAX_PATH];
   TCHAR m_chDirSeparator;
   HANDLE m_hFind;
   BOOL m_bFound;

   // Constructor/destructor

   CFindFileBase() : m_hFind(NULL), m_chDirSeparator('\\'), m_bFound(FALSE)
   { 
   }
   ~CFindFileBase()
   {
      Close();
   }

   // Operations

   void Close()
   {
      m_bFound = FALSE;
      if( m_hFind != NULL && m_hFind != INVALID_HANDLE_VALUE ) {
         ::FindClose(m_hFind);
         m_hFind = NULL;
      }
   }

   // Attributes

   ULONGLONG GetFileSize() const
   {
      ATLASSERT(m_hFind!=NULL);
      ULARGE_INTEGER nFileSize;
      if( m_bFound ) {
         nFileSize.LowPart = m_fd.nFileSizeLow;
         nFileSize.HighPart = m_fd.nFileSizeHigh;
      }
      else {
         nFileSize.QuadPart = 0;
      }
      return nFileSize.QuadPart;
   }
   BOOL GetFileName(LPTSTR lpstrFileName, int cchLength) const
   {
      ATLASSERT(m_hFind!=NULL);
      if( (int) lstrlen(m_fd.cFileName) >= cchLength ) return FALSE;
      return (m_bFound && (::lstrcpy(lpstrFileName, m_fd.cFileName) != NULL));
   }
   BOOL GetFilePath(LPTSTR lpstrFilePath, int cchLength) const
   {
      ATLASSERT(m_hFind!=NULL);
      int nLen = lstrlen(m_lpszRoot);
      ATLASSERT(nLen > 0);
      if( nLen == 0 ) return FALSE;
      bool bAddSep = (m_lpszRoot[nLen - 1] != '\\' && m_lpszRoot[nLen - 1] != '/');
      if( ((int) lstrlen(m_lpszRoot) + (bAddSep ?  1 : 0)) >= cchLength ) return FALSE;
      BOOL bRet = (::lstrcpy(lpstrFilePath, m_lpszRoot) != NULL);
      if( bRet ) {
         TCHAR szSeparator[2] = { m_chDirSeparator, 0 };
         bRet = (::lstrcat(lpstrFilePath, szSeparator) != NULL);
         if( bRet ) bRet = (::lstrcat(lpstrFilePath, m_fd.cFileName) != NULL);
      }
      return bRet;
   }
   BOOL GetRoot(LPTSTR lpstrRoot, int cchLength) const
   {
      ATLASSERT(m_hFind!=NULL);
      if( (int) lstrlen(m_lpszRoot) >= cchLength ) return FALSE;
      return (::lstrcpy(lpstrRoot, m_lpszRoot) != NULL);
   }
#if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__)
   CString GetFileName() const
   {
      ATLASSERT(m_hFind!=NULL);
      CString ret;
      if( m_bFound ) ret = m_fd.cFileName;
      return ret;
   }
   CString GetFilePath() const
   {
      ATLASSERT(m_hFind!=NULL);
      CString strResult = m_lpszRoot;
      if( strResult[strResult.GetLength() - 1] != '\\' &&
         strResult[strResult.GetLength() - 1] != '/' )
         strResult += m_chDirSeparator;
      strResult += GetFileName();
      return strResult;
   }
   CString GetRoot() const
   {
      ATLASSERT(m_hFind!=NULL);
      return m_lpszRoot;
   }
#endif //defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__)
   BOOL GetLastWriteTime(FILETIME* pTimeStamp) const
   {
      ATLASSERT(m_hFind!=NULL);
      ATLASSERT(pTimeStamp != NULL);
      if( m_bFound && pTimeStamp != NULL ) {
         *pTimeStamp = m_fd.ftLastWriteTime;
         return TRUE;
      }
      return FALSE;
   }
   BOOL GetLastAccessTime(FILETIME* pTimeStamp) const
   {
      ATLASSERT(m_hFind!=NULL);
      ATLASSERT(pTimeStamp != NULL);
      if( m_bFound && pTimeStamp != NULL ) {
         *pTimeStamp = m_fd.ftLastAccessTime;
         return TRUE;
      }
      return FALSE;
   }
   BOOL GetCreationTime(FILETIME* pTimeStamp) const
   {
      ATLASSERT(m_hFind!=NULL);
      if( m_bFound && pTimeStamp != NULL ) {
         *pTimeStamp = m_fd.ftCreationTime;
         return TRUE;
      }
      return FALSE;
   }
   BOOL MatchesMask(DWORD dwMask) const
   {
      ATLASSERT(m_hFind!=NULL);
      if( m_bFound ) return ((m_fd.dwFileAttributes & dwMask) != 0);
      return FALSE;
   }
   BOOL IsDots() const
   {
      ATLASSERT(m_hFind!=NULL);
      // return TRUE if the file name is "." or ".." and
      // the file is a directory
      BOOL bResult = FALSE;
      if( m_bFound && IsDirectory() ) {
         if( m_fd.cFileName[0] == '.' 
             && (m_fd.cFileName[1] == '\0' 
             || (m_fd.cFileName[1] == '.' && m_fd.cFileName[2] == '\0')) )
         {
            bResult = TRUE;
         }
      }
      return bResult;
   }

   BOOL IsReadOnly() const
   {
      return MatchesMask(FILE_ATTRIBUTE_READONLY);
   }
   BOOL IsDirectory() const
   {
      return MatchesMask(FILE_ATTRIBUTE_DIRECTORY);
   }
   BOOL IsCompressed() const
   {
      return MatchesMask(FILE_ATTRIBUTE_COMPRESSED);
   }
   BOOL IsSystem() const
   {
      return MatchesMask(FILE_ATTRIBUTE_SYSTEM);
   }
   BOOL IsHidden() const
   {
      return MatchesMask(FILE_ATTRIBUTE_HIDDEN);
   }
   BOOL IsTemporary() const
   {
      return MatchesMask(FILE_ATTRIBUTE_TEMPORARY);
   }
   BOOL IsNormal() const
   {
      return MatchesMask(FILE_ATTRIBUTE_NORMAL);
   }
   BOOL IsArchived() const
   {
      return MatchesMask(FILE_ATTRIBUTE_ARCHIVE);
   }
};


class CFindFile : public CFindFileBase
{
public:
   // Operations

   BOOL FindFile(LPCTSTR pstrPattern = NULL)
   {
      Close();
      if( pstrPattern == NULL ) pstrPattern = _T("*.*");
      ::lstrcpy(m_fd.cFileName, pstrPattern);
      m_hFind = ::FindFirstFile(pstrPattern, &m_fd);
      if( m_hFind == INVALID_HANDLE_VALUE ) return FALSE;
      ::ZeroMemory(m_lpszRoot, sizeof(m_lpszRoot));
      m_lpszRoot[0] = m_chDirSeparator;
      LPCTSTR pstr = NULL;
      LPCTSTR p = pstrPattern;
      while( *p ) {
         if( *p == m_chDirSeparator ) pstr = p;
         p = ::CharNext(p);
      }
      if( pstr ) ::lstrcpyn(m_lpszRoot, pstrPattern, pstr - pstrPattern + 1);
      m_bFound = TRUE;
      return TRUE;
   }
   BOOL FindNextFile()
   {
      ATLASSERT(m_hFind!=NULL);
      if( m_hFind == NULL ) return FALSE;
      if( !m_bFound ) return FALSE;
      m_bFound = ::FindNextFile(m_hFind, &m_fd);
      return m_bFound;
   }
};


class CFindProjectFile : public CFindFileBase
{
public:
   // Operations

   BOOL FindFile(LPCTSTR pstrPattern = NULL, DWORD dwOidFlash = 0, LPTSTR lpszProj = NULL)
   {
      Close();
      if( pstrPattern == NULL ) pstrPattern = _T("*.*");
      ::lstrcpy(m_fd.cFileName, pstrPattern);
      m_hFind = ::FindFirstProjectFile(pstrPattern, &m_fd, dwOidFlash, lpszProj);
      if( m_hFind == INVALID_HANDLE_VALUE ) return FALSE;
      ::ZeroMemory(m_lpszRoot, sizeof(m_lpszRoot));
      LPCTSTR pstr = NULL;
      LPCTSTR p = pstrPattern;
      while( *p ) {
         if( *p == m_chDirSeparator ) pstr = p;
         p = ::CharNext(p);
      }
      if( pstr ) ::lstrcpyn(m_lpszRoot, pstrPattern, pstr - pstrPattern); else ::lstrcpy(m_lpszRoot, _T("\\"));
      m_bFound = TRUE;
      return TRUE;
   }
   BOOL FindNextFile()
   {
      ATLASSERT(m_hFind!=NULL);
      if( m_hFind == NULL ) return FALSE;
      if( !m_bFound ) return FALSE;
      m_bFound = ::FindNextProjectFile(m_hFind, &m_fd);
      return m_bFound;
   }
};


class CFindFlashCard : public CFindFileBase
{
public:
   // Operations

   BOOL FindFile()
   {
      Close();
      m_hFind = ::FindFirstFlashCard(&m_fd);
      if( m_hFind == INVALID_HANDLE_VALUE ) return FALSE;
      ::ZeroMemory(m_lpszRoot, sizeof(m_lpszRoot));
      m_lpszRoot[0] = m_chDirSeparator;
      m_bFound = TRUE;
      return TRUE;
   }
   BOOL FindNextFile()
   {
      ATLASSERT(m_hFind!=NULL);
      if( m_hFind == NULL ) return FALSE;
      if( !m_bFound ) return FALSE;
      m_bFound = ::FindNextFlashCard(m_hFind, &m_fd);
      return m_bFound;
   }
};


#endif // __ATLCEPLUS_H__
<file_sep>/SQLCEHelper/Source/DataSource.cpp

#include "stdafx.h"

using namespace OLEDBCLI;


// CDataSource::CDataSource
//
//		Default constructor
//
CDataSource::CDataSource()
:	m_pInitialize(NULL)
{
}


// CDataSource::~CDataSource
//
//		Destructor
//
CDataSource::~CDataSource()
{
	Close();
}


// CDataSource::Open
//
//		Opens an existing data source
//
HRESULT CDataSource::Open(const CLSID &clsid, ULONG cPropSets, DBPROPSET rgPropSets[])
{
	HRESULT	hr;

	Close();

	hr = CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER, IID_IDBInitialize, (LPVOID*)&m_pInitialize);
	if(SUCCEEDED(hr))
	{
		CComPtr<IDBProperties>	spProperties;

		hr = m_pInitialize->QueryInterface(IID_IDBProperties, (void**)&spProperties);
		if(SUCCEEDED(hr))
		{
			hr = spProperties->SetProperties(cPropSets, rgPropSets);
			if(SUCCEEDED(hr))
				hr = m_pInitialize->Initialize();
		}
	}

	return hr;
}


// CDataSource::Create
//
//		Creates a new data source and optionally returns an open session
//
HRESULT CDataSource::Create(const CLSID& clsid, ULONG cPropSets, DBPROPSET rgPropSets[], CSession* pSession)
{
	HRESULT						hr;
	CComPtr<IDBDataSourceAdmin>	spAdmin;

	Close();

	hr = CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER, IID_IDBDataSourceAdmin, (void**)&spAdmin);
	if(FAILED(hr))
		return hr;

	if(pSession != NULL)
	{
		ISessionProperties* pSessionProperties = NULL;

		hr = spAdmin->CreateDataSource(cPropSets, rgPropSets, NULL, IID_ISessionProperties, (IUnknown**)&pSessionProperties);
		if(SUCCEEDED(hr))
			pSession->Open(pSessionProperties);
	}
	else
		hr = spAdmin->CreateDataSource(cPropSets, rgPropSets, NULL, IID_IUnknown, NULL);

	// Get the IDBInitialize pointer in order to keep the data source "open"
	if(SUCCEEDED(hr))
		spAdmin->QueryInterface(IID_IDBInitialize, (void**)&m_pInitialize);

	return hr;
}


// CDataSource::Close
//
//		Closes the data source
//
HRESULT CDataSource::Close()
{
	HRESULT hr = E_NOINTERFACE;

	if(m_pInitialize != NULL)
	{
		hr = m_pInitialize->Uninitialize();

		if(SUCCEEDED(hr))
			m_pInitialize->Release();
	}
	return hr;
}
<file_sep>/FingerSuite/FingerMenuCTRL/MainFrm.h
// MainFrm.h : interface of the CMainFrame class
//
/////////////////////////////////////////////////////////////////////////////

#pragma once

//DEFINE_GUID(CLSID_ImagingFactory, 0x327abda8,0x072b,0x11d3,0x9d,0x7b,0x00,0x00,0xf8,0x1e,0xf3,0x2e);

#include "..\Common\AboutView.h"
#include "..\FingerSuiteCPL\Commons.h"
#include "..\Common\fngrsplash.h"

typedef enum {SQVGA = 240, QVGA = 320, WQVGA = 400, VGA = 640, WVGA = 800} RESOLUTION;

static UINT UWM_INTERCEPT_MENU = ::RegisterWindowMessage(UWM_INTERCEPT_MENU_MSG);

static UINT UWM_UPDATECONFIGURATION = ::RegisterWindowMessage(UWM_UPDATECONFIGURATION_MSG);


class CMainFrame : public CFrameWindowImpl<CMainFrame>, public CUpdateUI<CMainFrame>,
		public CMessageFilter, public CIdleHandler
{
public:
	DECLARE_FRAME_WND_CLASS(L"FINGER_MENU", IDR_MAINFRAME)

	CWrapMenuWindow  m_menuView;
	CAboutView       m_aboutView;


	virtual BOOL PreTranslateMessage(MSG* pMsg)
	{
		if(CFrameWindowImpl<CMainFrame>::PreTranslateMessage(pMsg))
			return TRUE;

		if (pMsg->message == WM_LBUTTONDOWN)
		{
			m_xPos = LOWORD(pMsg->lParam);
			m_bMouseIsDown = TRUE;
		}

		if (pMsg->message == WM_LBUTTONUP)
		{
			// back gesture recognition
			if (m_bMouseIsDown)
			{
				m_bMouseIsDown = FALSE;
				int xPosNew =  LOWORD(pMsg->lParam);
				
				if ((m_xPos - xPosNew) > 100 * m_menuView.GetScaleFactor())
				{
					// back gesture recognized 
					Back();
					return TRUE;
				}
			}
		}

		return m_menuView.PreTranslateMessage(pMsg);
	}

	virtual BOOL OnIdle()
	{
		return FALSE;
	}
	
	BEGIN_UPDATE_UI_MAP(CMainFrame)
	END_UPDATE_UI_MAP()

	BEGIN_MSG_MAP(CMainFrame)
		MESSAGE_HANDLER(WM_CREATE, OnCreate)
		MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
		MESSAGE_HANDLER(WM_SIZE, OnSize)
		MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBkgnd)
		MESSAGE_HANDLER(WM_ACTIVATE, OnActivate)
		MESSAGE_HANDLER(WM_SETTINGCHANGE , OnSettingsChange)
		MESSAGE_HANDLER(UM_MINIMIZE, OnMinimize)
		MESSAGE_HANDLER(UWM_INTERCEPT_MENU, OnInterceptMenu)
		MESSAGE_HANDLER(UWM_UPDATECONFIGURATION, OnUpdateConfiguration)
		MESSAGE_HANDLER(UM_SETNEWMENU, OnSetNewMenu)
		MESSAGE_HANDLER(UM_GETDESTWND, OnGetDestWnd)
		COMMAND_ID_HANDLER(ID_MENU_CANCEL, OnCancel)
		COMMAND_ID_HANDLER(ID_ACTION, OnAction)
		COMMAND_ID_HANDLER(ID_MENU_EXIT, OnMenuExit)
		COMMAND_ID_HANDLER(ID_MENU_ADDTOEXCLUSIONLIST, OnMenuAddToExclusionList)
		COMMAND_ID_HANDLER(ID_MENU_ADDTOWNDEXCLUSIONLIST, OnMenuAddToWndExclusionList)
		COMMAND_ID_HANDLER(ID_MENU_SHOWORIGINAL, OnMenuShowOriginal)
		COMMAND_ID_HANDLER(ID_MENU_ABOUT, OnMenuAbout)
		COMMAND_ID_HANDLER(ID_BACK, OnBack)
		CHAIN_MSG_MAP(CUpdateUI<CMainFrame>)
		CHAIN_MSG_MAP(CFrameWindowImpl<CMainFrame>)
	END_MSG_MAP()


	LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		RestoreMenuBar();

		CSplashWindow* pSplash = new CSplashWindow(m_hWnd, IDR_MAINFRAME, L"FingerMenu");


		LoadConfiguration();

		// menu
		m_hWndClient = m_menuView.Create(m_hWnd, rcDefault, NULL, WS_CHILD | WS_VISIBLE |WS_CLIPSIBLINGS | WS_CLIPCHILDREN);  //

		// about
		CString strCredits = "\n\n"
			    "\tFingerMenu v1.12\n\n"
				"\rdeveloped by:\n"
				"<NAME>\n"
				"<<EMAIL>>\n"
				"\n\n"
				"http://forum.xda-developers.com/\n"
				"                showthread.php?t=459125\n";
		m_aboutView.SetCredits(strCredits);
		m_aboutView.Create(m_hWnd, rcDefault, NULL, WS_CHILD | WS_VISIBLE |WS_CLIPSIBLINGS | WS_CLIPCHILDREN);  //

		// register object for message filtering and idle updates
		CMessageLoop* pLoop = _Module.GetMessageLoop();
		ATLASSERT(pLoop != NULL);
		pLoop->AddMessageFilter(this);
		pLoop->AddIdleHandler(this);

		CreateConfigMenu();

		if (m_bEnableSIP)
			InstallHookOnSIP();

		SetHWndServer(m_hWnd);

		InstallHook();

		SignalWaitEvent(EVT_FNGRMENU);

		ModifyStyle(0, WS_NONAVDONEBUTTON, SWP_NOSIZE);

		pSplash->Dismiss();

		return 0;  
	}

	LRESULT OnSize(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled)
	{
		if(wParam != SIZE_MINIMIZED)
		{

		}
			
		return 0;
	}


	LRESULT OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		//RemoveHook(); TODO 

		return 0;
	}

	LRESULT OnEraseBkgnd(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		CDCHandle dc( (HDC) wParam );
		RECT rc; GetClientRect(&rc);

		if (m_bDisabledTransp)
		{
			dc.FillSolidRect(&rc, m_clNoTranspBackground);
		}
		else
		{
			if (!(m_imgBkg.IsValid()))
				CaptureScreen(dc);

			m_imgBkg.Draw(dc, rc);
		}
		return 1;
	}

	LRESULT OnActivate(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		int fActive = LOWORD(wParam); 
		if ((fActive == WA_ACTIVE) || (fActive == WA_CLICKACTIVE))
		{
		}
		else if (fActive == WA_INACTIVE)
		{
			if (IsWindowVisible())
			{
				Minimize(FALSE);
			}
		}
		return 0;
	}

	LRESULT OnSettingsChange(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		if (wParam == SETTINGCHANGE_RESET)
		{
			m_menuView.ModifyTopShape();

			m_menuView.Show();
		}
		return 0;
	}

	LRESULT OnGetDestWnd(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		return (LRESULT)m_hDestWnd;
	}

	LRESULT OnSetNewMenu(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		// always called for sub menu
		CreateBackMenuBar();
		SetNewMenu((HMENU)wParam);
		return 0;
	}



	LRESULT OnMinimize(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		Minimize((int)wParam);
		return 0;
	}

	LRESULT OnCancel(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
	{
		Minimize(FALSE);

		return 0;
	}

	/*
	LRESULT OnInterceptMenu1(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
	{
		LOG(L"Intercepting TrackMenuPopupEx (1) ...hMenu=%08x hWnd=%08X\n", (HMENU)wParam, (HWND)lParam);

		if (IsDeviceLocked())
			return 1;

		HWND hDestWnd = (HWND)lParam;
		HWND hWndSIP = FindWindow(NULL, L"MS_SIPBUTTON");
		if (hDestWnd == hWndSIP) 
		{
			if (m_bEnableSIP)
				m_menuView.SetNewMenu((HMENU)wParam, NULL, NULL, FALSE);	
			else
				return 1;
		}
		else
		{
			if (IsExcludedApp(hDestWnd))
				return 1;
			
			HWND hDestCtrl = ManageDOTNETApp(hDestWnd);

			if (!(m_menuView.SetNewMenu((HMENU)wParam, hDestWnd, hDestCtrl, TRUE)))
				return 1;
		}
		
		//Sleep(100);

		RestoreMenuBar();
		
		SwitchToMenuView();

		SetForegroundWindow((HWND)((ULONG) m_hWnd | 0x00000001));
		ShowWindow(SW_SHOW);		
		
		bHandled = TRUE;
		return 0;
	}
	*/


	LRESULT OnInterceptMenu(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled)
	{
		//LOG(L"Intercepting TrackMenuPopupEx (2)...hMenu=%08x hWnd=%08X\n", (HMENU)wParam, (HWND)lParam);

		if (IsDeviceLocked())
			return 1;

		LPTRACKPOPUPMENUINFO lpInfo = (LPTRACKPOPUPMENUINFO)lParam;

		m_hPrevDestWnd = m_hDestWnd;

		m_hDestWnd = lpInfo->hWnd;
		m_uFlags = lpInfo->uFlags;


		HWND hWndSIP = FindWindow(NULL, L"MS_SIPBUTTON");
		if (m_hDestWnd == hWndSIP) 
		{
			if (!(m_bEnableSIP))
				return 1;
		}
		else
		{
			if (IsExcludedApp(m_hDestWnd))
				return 1;

			if (IsExcludedWnd(m_hDestWnd))
				return 1;

		}

		m_menus.RemoveAll();
		

		if (!(SetNewMenu(lpInfo->hMenu)))
			return 1;

		RestoreMenuBar();
		
		SwitchToMenuView();

		SetForegroundWindow((HWND)((ULONG) m_hWnd | 0x00000001));
		ShowWindow(SW_SHOW);		
		
		bHandled = TRUE;
		return 0;
	}

	LRESULT OnAction(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
	{
		m_hPrevDestWnd = m_hDestWnd;
		m_hDestWnd = m_hWnd;

		SetNewMenu(m_menuConfig);

		SwitchToMenuView();

		SetForegroundWindow((HWND)((ULONG) m_hWnd | 0x00000001));
		ShowWindow(SW_SHOW);		
		return 0;
	}

	LRESULT OnBack(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
	{
		Back();
		return 0;
	}

	LRESULT OnMenuExit(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
	{
		Minimize(FALSE);
		PostMessage(WM_CLOSE);
		return 0;
	}

	LRESULT OnMenuAddToExclusionList(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
	{
		DWORD dwProcessId; GetWindowThreadProcessId(m_hPrevDestWnd, &dwProcessId);
		HMODULE hProcess = (HMODULE)dwProcessId;
		WCHAR szName[MAX_PATH];
		if (GetModuleFileName(hProcess, szName, MAX_PATH))
		{
			CString szApp = (LPTSTR)szName;
			szApp = szApp.Right(szApp.GetLength() - szApp.ReverseFind('\\') - 1);

			if (m_excludedApps.Find(szApp) == -1)
				m_excludedApps.Add(szApp);

			SaveExclusionList(m_excludedApps, L"Software\\FingerMenu");
		}

		Minimize(-1);

		return 0;
	}

	LRESULT OnMenuAddToWndExclusionList(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
	{
		WCHAR szTitle[MAX_PATH];
		::GetWindowText(m_hPrevDestWnd, szTitle, MAX_PATH); 

		WCHAR szClassName[MAX_PATH];
		::GetClassName(m_hPrevDestWnd, szClassName, MAX_PATH);

		if (lstrcmp(szClassName, L"MS_SOFTKEY_CE_1.0") == 0)
		{
			Minimize(FALSE);
			return 0;
		}

		WCHAR szName[MAX_PATH];
		wsprintf(szName, L"%s - %s", szTitle, szClassName);
		
		CString szWnd = (LPTSTR)szName;
		if (m_excludedWnds.Find(szWnd) == -1)
			m_excludedWnds.Add(szWnd);

		SaveWndExclusionList(m_excludedWnds, L"Software\\FingerMenu");

		Minimize(-1);

		return 0;
	}

	LRESULT OnMenuShowOriginal(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
	{
		Minimize(-1);
		
		return 0;
	}

	LRESULT OnMenuAbout(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
	{
		SwitchToAboutView();
		SetForegroundWindow((HWND)((ULONG) m_hWnd | 0x00000001));
		ShowWindow(SW_SHOW);	
		return 0;
	}		

	LRESULT OnUpdateConfiguration(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		LoadConfiguration();

		Minimize(FALSE);
		return 0;
	}

private:

	BOOL RestoreMenuBar()
	{
		SHMENUBARINFO mbi = { 0 };
		mbi.cbSize = sizeof(mbi);
		mbi.hwndParent = m_hWnd;
		mbi.dwFlags = SHCMBF_HIDESIPBUTTON;
		mbi.nToolBarId = FM_IDW_MENU_BAR;
		mbi.hInstRes  = ModuleHelper::GetResourceInstance();
		mbi.hwndMB = NULL;   // This gets set by SHCreateMenuBar

		BOOL bRet = ::SHCreateMenuBar(&mbi);
		if (bRet != FALSE)
		{
			m_hWndCECommandBar = mbi.hwndMB;
			SizeToMenuBar();
		}

		return bRet;
	}

	BOOL CreateBackMenuBar()
	{
		SHMENUBARINFO mbi = { 0 };
		mbi.cbSize = sizeof(mbi);
		mbi.hwndParent = m_hWnd;
		mbi.dwFlags = SHCMBF_HIDESIPBUTTON;
		mbi.nToolBarId = FM_IDW_BACK_MENU_BAR;
		mbi.hInstRes  = ModuleHelper::GetResourceInstance();
		mbi.hwndMB = NULL;   // This gets set by SHCreateMenuBar

		BOOL bRet = ::SHCreateMenuBar(&mbi);
		if( bRet != FALSE)
		{
			m_hWndCECommandBar = mbi.hwndMB;
			SizeToMenuBar();
		}

		return TRUE;
	}		



	void Minimize(int iResult)
	{
		// check if service menu
		if ((m_hWnd == m_hDestWnd) && (iResult > 0))
		{
			// service menu
			PostMessage(WM_COMMAND, (WPARAM)iResult);
			return;
		}
					
		ShowWindow(SW_HIDE);

		SetTrackPopupMenuExResult(iResult);

		SignalWaitEvent(EVT_FNGRMENU);

		if ((!(m_uFlags & TPM_RETURNCMD)) && (iResult > 0) && (m_hWnd != m_hDestWnd)) 
			::PostMessage(m_hDestWnd, WM_COMMAND, (WPARAM)iResult, (LPARAM)0);
	}

	
	HWND ManageDOTNETApp(HWND& hDestWnd)
	{
		HWND hDestCtrl = NULL;
		WCHAR szClass[50];
		::GetClassName(hDestWnd, szClass, 50);
		if (lstrcmpi(szClass, L"MS_SOFTKEY_CE_1.0") == 0)
		{
			DWORD dwProcessId; GetWindowThreadProcessId(hDestWnd, &dwProcessId);

			HWND hDotNETWnd = ::FindWindow(L"#NETCF_AGL_BASE_", NULL);
			if (hDotNETWnd != NULL)
			{
				DWORD dwProcess2Id; GetWindowThreadProcessId(hDotNETWnd, &dwProcess2Id);
				if (dwProcess2Id == dwProcessId)
				{
					hDestCtrl = hDestWnd;
					hDestWnd = hDotNETWnd;
				}
			}
		}
		return hDestCtrl;
	}
	

	BOOL IsExcludedApp(HWND hWnd)
	{
		DWORD dwProcessId; GetWindowThreadProcessId(hWnd, &dwProcessId);
		HMODULE hProcess = (HMODULE)dwProcessId;
		// execute GetCommandLine() on remote process
		WCHAR szName[MAX_PATH];
		if (GetModuleFileName(hProcess, szName, MAX_PATH))
		{
			CString szApp = (LPTSTR)szName;
			szApp = szApp.Right(szApp.GetLength() - szApp.ReverseFind('\\') - 1);
			for (int i = 0; i < m_excludedApps.GetSize(); i ++)
			{
				if (m_excludedApps[i].CompareNoCase( szApp ) == 0)
					return TRUE;
			}
		}

		return FALSE;
	}

	BOOL IsExcludedWnd(HWND hWnd)
	{
		WCHAR szTitle[MAX_PATH];
		::GetWindowText(hWnd, szTitle, MAX_PATH); 

		WCHAR szClassName[MAX_PATH];
		::GetClassName(hWnd, szClassName, MAX_PATH);

		WCHAR szName[MAX_PATH];
		wsprintf(szName, L"%s - %s", szTitle, szClassName);


		CString szWnd = (LPTSTR)szName;
		for (int i = 0; i < m_excludedWnds.GetSize(); i ++)
		{
			if (m_excludedWnds[i].CompareNoCase( szWnd ) == 0)
				return TRUE;
		}

		return FALSE;
	}


	void CaptureScreen(CDCHandle dc)
	{
		RECT rc; GetClientRect(&rc);
		CDC dcTemp; dcTemp.CreateCompatibleDC(dc);
		CBitmap bmpBkg; bmpBkg.CreateCompatibleBitmap(dc, rc.right, rc.bottom);
		CBitmap bmpOld = dcTemp.SelectBitmap(bmpBkg);
		dcTemp.FillSolidRect(&rc, RGB(0,0,0));
		dcTemp.SelectBitmap(bmpOld);
		m_imgBkg.CreateFromHBITMAP(bmpBkg);
		m_imgBkg.AlphaCreate();
		m_imgBkg.AlphaSet((BYTE)m_iTransp);
	}

	void LoadConfiguration()
	{
		WCHAR keyName[] = L"Software\\FingerMenu";
		// load transparency level
		m_iTransp = 128;
		if (!(RegReadDWORD(HKEY_LOCAL_MACHINE, keyName, L"TransparencyLevel", m_iTransp)))
			LOG(L"Unable to read TransparencyLevel from registry: %s\n", ErrorString(GetLastError()));

		m_bEnableSIP = TRUE;
		if (!(RegReadBOOL(HKEY_LOCAL_MACHINE, keyName, L"EnableSIP", m_bEnableSIP)))
			LOG(L"Unable to read EnableSIP from registry: %s\n", ErrorString(GetLastError()));

		m_menuView.m_iMaxVisibleItemCount = 0;
		if (!(RegReadDWORD(HKEY_LOCAL_MACHINE, keyName, L"MaxMenuItemCount", m_menuView.m_iMaxVisibleItemCount)))
			LOG(L"Unable to read MaxMenuItemCount from registry: %s\n", ErrorString(GetLastError()));
		if (m_menuView.m_iMaxVisibleItemCount == 0)
			m_menuView.m_iMaxVisibleItemCount = 1000;

		DWORD iMaxScrollVelocity = 15;
		if (!(RegReadDWORD(HKEY_LOCAL_MACHINE, keyName, L"MaxScrollVelocity", iMaxScrollVelocity)))
			LOG(L"Unable to read MaxScrollVelocity from registry: %s\n", ErrorString(GetLastError()));
		m_menuView.m_menu.SetMaxVelocity(iMaxScrollVelocity);


		m_bDisabledTransp = FALSE;
		if (!(RegReadBOOL(HKEY_LOCAL_MACHINE, keyName, L"DisableTransparency", m_bDisabledTransp)))
			LOG(L"Unable to read DisableTransparency from registry: %s\n", ErrorString(GetLastError()));

		m_clNoTranspBackground = RGB(0,0,0);
		RegReadColor(HKEY_LOCAL_MACHINE, keyName, L"NoTranspBkgColor", m_clNoTranspBackground);

		//m_bEnableDD = FALSE;
		//if (!(RegReadBOOL(HKEY_LOCAL_MACHINE, keyName, L"EnableDirectDraw", m_bEnableDD)))
		//	LOG(L"Unable to read EnableDirectDraw from registry: %s\n", ErrorString(GetLastError()));

		m_menuView.m_bNoButtons = FALSE;
		if (!(RegReadBOOL(HKEY_LOCAL_MACHINE, keyName, L"NeverShowButtons", m_menuView.m_bNoButtons)))
			LOG(L"Unable to read NeverShowButtons from registry: %s\n", ErrorString(GetLastError()));

		m_menuView.m_bEnableAnimation = TRUE;
		if (!(RegReadBOOL(HKEY_LOCAL_MACHINE, keyName, L"EnableAnimation", m_menuView.m_bEnableAnimation)))
			LOG(L"Unable to read EnableAnimation from registry: %s\n", ErrorString(GetLastError()));


		// load icon images
		WCHAR szSkin[60] = L"default";
		RegReadString(HKEY_LOCAL_MACHINE, keyName, L"Skin", szSkin);
		WCHAR szAppPath[MAX_PATH] = L"";
		CString strAppDirectory;
		GetModuleFileName(NULL, szAppPath, MAX_PATH);
		strAppDirectory = szAppPath;
		strAppDirectory = strAppDirectory.Left(strAppDirectory.ReverseFind('\\'));
		CString skinBasePath; skinBasePath.Format(L"%s\\skins\\%s", strAppDirectory, szSkin);


		// detect resolution
		RESOLUTION resolution = QVGA;
		DEVMODE dm;
		::ZeroMemory(&dm, sizeof(DEVMODE));
		dm.dmSize = sizeof(DEVMODE);
		if (EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dm))
		{
			resolution = (RESOLUTION)dm.dmPelsHeight;
		}

		switch (resolution)
		{
		case SQVGA:
		case QVGA:
		case WQVGA:
			m_menuView.SetScaleFactor(1);
			break;
		case VGA:
		case WVGA:
			m_menuView.SetScaleFactor(2);
			break;
		}		

		if ( (resolution == VGA) || (resolution == WVGA))
		{
			m_menuView.m_menu.m_imgSubmenuImage.Load(skinBasePath + L"\\submenu_vga.png", CXIMAGE_FORMAT_PNG);
			m_menuView.m_menu.m_imgCheckedImage.Load(skinBasePath + L"\\checked_vga.png", CXIMAGE_FORMAT_PNG);
			m_menuView.m_menu.m_imgRadioCheckedImage.Load(skinBasePath + L"\\radio_checked_vga.png", CXIMAGE_FORMAT_PNG);
			m_menuView.m_menu.m_imgRadioUncheckedImage.Load(skinBasePath + L"\\radio_unchecked_vga.png", CXIMAGE_FORMAT_PNG);
			m_menuView.m_menu.m_imgSelectionImage.Load(skinBasePath + L"\\selection_vga.png", CXIMAGE_FORMAT_PNG);
			m_menuView.m_menu.m_imgDPadCursorImage.Load(skinBasePath + L"\\dpad_cursor_vga.png", CXIMAGE_FORMAT_PNG);
			m_menuView.m_bmpBtnUp.Load(skinBasePath + L"\\btn_up_vga.png", CXIMAGE_FORMAT_PNG);
			m_menuView.m_bmpBtnUpPressed.Load(skinBasePath + L"\\btn_up_press_vga.png", CXIMAGE_FORMAT_PNG);
			m_menuView.m_bmpBtnUpDisabled.Load(skinBasePath + L"\\btn_up_disabled_vga.png", CXIMAGE_FORMAT_PNG);
			m_menuView.m_bmpBtnDown.Load(skinBasePath + L"\\btn_down_vga.png", CXIMAGE_FORMAT_PNG);
			m_menuView.m_bmpBtnDownPressed.Load(skinBasePath + L"\\btn_down_press_vga.png", CXIMAGE_FORMAT_PNG);
			m_menuView.m_bmpBtnDownDisabled.Load(skinBasePath + L"\\btn_down_disabled_vga.png", CXIMAGE_FORMAT_PNG);
			m_menuView.m_bmpBtnArrowDown.Load(skinBasePath + L"\\btn_arrow_down_vga.png", CXIMAGE_FORMAT_PNG);
			m_menuView.m_bmpBtnArrowUp.Load(skinBasePath + L"\\btn_arrow_up_vga.png", CXIMAGE_FORMAT_PNG);
		}
		else
		{
			m_menuView.m_menu.m_imgSubmenuImage.Load(skinBasePath + L"\\submenu_qvga.png", CXIMAGE_FORMAT_PNG);
			m_menuView.m_menu.m_imgCheckedImage.Load(skinBasePath + L"\\checked_qvga.png", CXIMAGE_FORMAT_PNG);
			m_menuView.m_menu.m_imgRadioCheckedImage.Load(skinBasePath + L"\\radio_checked_qvga.png", CXIMAGE_FORMAT_PNG);
			m_menuView.m_menu.m_imgRadioUncheckedImage.Load(skinBasePath + L"\\radio_unchecked_qvga.png", CXIMAGE_FORMAT_PNG);
			m_menuView.m_menu.m_imgSelectionImage.Load(skinBasePath + L"\\selection_qvga.png", CXIMAGE_FORMAT_PNG);
			m_menuView.m_menu.m_imgDPadCursorImage.Load(skinBasePath + L"\\dpad_cursor_qvga.png", CXIMAGE_FORMAT_PNG);
			m_menuView.m_bmpBtnUp.Load(skinBasePath + L"\\btn_up_qvga.png", CXIMAGE_FORMAT_PNG);
			m_menuView.m_bmpBtnUpPressed.Load(skinBasePath + L"\\btn_up_press_qvga.png", CXIMAGE_FORMAT_PNG);
			m_menuView.m_bmpBtnUpDisabled.Load(skinBasePath + L"\\btn_up_disabled_qvga.png", CXIMAGE_FORMAT_PNG);
			m_menuView.m_bmpBtnDown.Load(skinBasePath + L"\\btn_down_qvga.png", CXIMAGE_FORMAT_PNG);
			m_menuView.m_bmpBtnDownPressed.Load(skinBasePath + L"\\btn_down_press_qvga.png", CXIMAGE_FORMAT_PNG);
			m_menuView.m_bmpBtnDownDisabled.Load(skinBasePath + L"\\btn_down_disabled_qvga.png", CXIMAGE_FORMAT_PNG);
			m_menuView.m_bmpBtnArrowDown.Load(skinBasePath + L"\\btn_arrow_down_qvga.png", CXIMAGE_FORMAT_PNG);
			m_menuView.m_bmpBtnArrowUp.Load(skinBasePath + L"\\btn_arrow_up_qvga.png", CXIMAGE_FORMAT_PNG);
		}
	                
		m_menuView.SetItemHeight(m_menuView.m_menu.m_imgSelectionImage.GetHeight());
		m_menuView.SetButtonHeight(m_menuView.m_bmpBtnUp.GetHeight());


		// load skin settings
		CSimpleIniW ini(TRUE, TRUE, TRUE);
		SI_Error rc = ini.LoadFile(skinBasePath + L"\\settings_fingermenu.ini");

		// load background and selected color
	
		COLORREF clValue = 0;
		m_menuView.m_menu.m_clBkg          = (StringRGBToColor(ini.GetValue(L"colors", L"BkgColor"), clValue)) ? clValue : RGB(255,255,255);
		m_menuView.m_menu.m_clText         = (StringRGBToColor(ini.GetValue(L"colors", L"TextColor"), clValue)) ? clValue : RGB(0,0,0);
		m_menuView.m_menu.m_clSelText      = (StringRGBToColor(ini.GetValue(L"colors", L"SelTextColor"), clValue)) ? clValue : RGB(255,255,255);
		m_menuView.m_menu.m_clDisabledText = (StringRGBToColor(ini.GetValue(L"colors", L"DisabledTextColor"), clValue)) ? clValue : RGB(160,160,160);
		m_menuView.m_menu.m_clLine         = (StringRGBToColor(ini.GetValue(L"colors", L"LineColor"), clValue)) ? clValue : RGB(160,160,160);
		m_menuView.m_menu.m_clScrollbar    = (StringRGBToColor(ini.GetValue(L"colors", L"ScrollbarColor"), clValue)) ? clValue : RGB(160,160,160);

		// font
		if (!(m_menuView.m_menu.m_fText.IsNull())) m_menuView.m_menu.m_fText.DeleteObject();

		LOGFONT lf;
		if (StringToLogFont(ini.GetValue(L"fonts", L"TextFont"), lf))
		{
			m_menuView.m_menu.m_fText.CreateFontIndirect(&lf);
		}

		// list of excluded apps
		LoadExclusionList(m_excludedApps, L"Software\\FingerMenu");

		LoadWndExclusionList(m_excludedWnds, L"Software\\FingerMenu");
	}

	int Back()
	{
		if ((m_menus.GetSize() - 2) >= 0) 
		{
			int idx = -1;
			HMENU hCurrMenu = m_menuItems[0].hOwnerMenu;
			for (int i = 0; i < m_menus.GetSize(); i++)
			{
				if (m_menus[i].hMenu == hCurrMenu)
				{
					idx = i;
					break;
				}
			}

			if (idx >= 0)
			{
				if (m_menus[idx].hPrevMenu != NULL)
				{
					SetNewMenu(m_menus[idx].hPrevMenu);
					if (idx == 1)
						RestoreMenuBar();
					return idx;
				}
				else
				{
					PostMessage(WM_COMMAND, ID_MENU_CANCEL, 0);
					return 0;
				}
			}
		}
		else
		{
			PostMessage(WM_COMMAND, ID_MENU_CANCEL, 0);
			return 0;
		}
		
		m_menuView.m_menu.m_idxSelected = -1;
		return 0;
	}

	BOOL SetNewMenu(HMENU hMenu)
	{
		// menu
		LPMENU pMu = NULL;
		for (int i = 0; i < m_menus.GetSize(); i++)
		{
			if (m_menus[i].hMenu == hMenu)
			{
				pMu = &m_menus[i];
				break;
			}
		}
		if (pMu == NULL)
		{
			MENU m;
			m.hMenu = hMenu;
			m.bInitMenuSent = FALSE;
			m.hPrevMenu = NULL;
			m_menus.Add(m);

			pMu = &m_menus[m_menus.GetSize() - 1];
		}

		if ((hMenu == NULL) || (hMenu == 0))
		{
			m_menuItems.RemoveAll();
			return FALSE;
		}

		// reset 
		m_menuView.m_menu.m_idxSelected = -1;
		m_menuView.m_menu.m_idxDPadSelected = -1;

		m_menuItems.RemoveAll();


		// let other app initialize menu
		if (!pMu->bInitMenuSent)
		{
			pMu->bInitMenuSent = TRUE;
			DWORD dwResult;
			SendMessageTimeout(m_hDestWnd, WM_INITMENUPOPUP, (WPARAM)hMenu, 0, SMTO_NORMAL, 500, &dwResult);
			SendMessageTimeout(m_hDestWnd, WM_ENTERMENULOOP, (WPARAM)1, 0, SMTO_NORMAL, 500, &dwResult);
		}

		CMenuHandle menuPopup(hMenu);
		int i = 0;
		int nBlankCount = 0;
		while (1)
		{
			MENUINFO mi;
			ZeroMemory(&mi, sizeof(MENUINFO));
			mi.text[0] = ' ';
			mi.text[1] = ' ';
			mi.hOwnerMenu = hMenu;
			mi.mii.cbSize = sizeof(MENUITEMINFO);
			mi.mii.fMask = MIIM_CHECKMARKS | MIIM_DATA | MIIM_ID | MIIM_STATE | MIIM_SUBMENU | MIIM_TYPE | MIIM_FULLSTR;
			mi.mii.dwTypeData = (LPTSTR)&mi.text[2];
			mi.mii.cch = MENU_ITEM_TEXT_SIZE; //sizeof(mi.text);

			if (menuPopup.GetMenuItemInfo(i, TRUE, &mi.mii))
			{
				//DUMP_MENUITEMINFO(&mi.mii);

				if (mi.mii.fType & MFT_SEPARATOR)
				{
					if ((m_menuItems.GetSize() - 1) >= 0)
						m_menuItems[m_menuItems.GetSize() - 1].bFollowSeparator = TRUE;
				}
				else
				{
					// modifiche al campo text
					int j = 0;
					WCHAR c;
					while ((c = mi.text[j]) != L'\0')
					{
						if (mi.text[j] == L'\t')
							mi.text[j] = L' ';
						j++;
					}

					mi.hDestWnd = m_hDestWnd;
					mi.fPosition = i;

					if (mi.mii.dwTypeData == NULL)
						nBlankCount ++;

					if (mi.mii.fType & MFT_OWNERDRAW)
					{
						MEASUREITEMSTRUCT mis;
						ZeroMemory(&mis, sizeof(MEASUREITEMSTRUCT));
						mis.CtlType = ODT_MENU;
						mis.itemData = i; //mi.mii.dwItemData;

						// TODO
						//SendMessageRemote(mi.hDestWnd, WM_MEASUREITEM, 0, (LPARAM)&mis, sizeof(MEASUREITEMSTRUCT));
						/*
						RECT rc; GetClientRect(&rc);
						mis.itemWidth = rc.right - rc.left;
						mis.itemHeight = m_itemHeight; 

						LOG(L"SONO QUI\n");

						DRAWITEMSTRUCT dis;
						ZeroMemory(&dis, sizeof(DRAWITEMSTRUCT));

						CDC dc = ::GetDC(NULL);
						CDC dcTemp; dcTemp.CreateCompatibleDC(dc);
						CBitmap bmp; bmp.CreateCompatibleBitmap(dcTemp, mis.itemWidth, mis.itemHeight);
						CBitmap bmpOld = dcTemp.SelectBitmap(bmp);

						dcTemp.MoveTo(0,0);
						dcTemp.LineTo(mis.itemWidth, mis.itemHeight);

						dis.CtlType = ODT_MENU;
						dis.itemID = mi.mii.wID;
						dis.itemAction = ODA_DRAWENTIRE;
						//dis.itemState = ODS_SELECTED; // TODO
						dis.hwndItem = (HWND)mi.hOwnerMenu;
						dis.hDC = dcTemp;
						SetRect(&dis.rcItem, 0, 0, mis.itemWidth, mis.itemHeight);
						dis.itemData = mi.mii.dwItemData;

						SendMessageRemote(mi.hDestWnd, WM_DRAWITEM, 0, (LPARAM)&dis, sizeof(DRAWITEMSTRUCT));

						dcTemp.SelectBitmap(bmpOld);

						mi.imgOwnerDraw.CreateFromHBITMAP(bmp);
						::ReleaseDC(NULL, dc);

						CString fName; fName.Format(L"\\test%d.png", i);
						mi.imgOwnerDraw.Save(fName, CXIMAGE_FORMAT_PNG);

						LOG(L"SONO QUI 2\n");
						*/
					}

					// save 
					m_menuItems.Add(mi);
				}
			}
			else
			{
				//LOG(L"Error in SetMenu: %s\n", ErrorString(GetLastError()));
				break;
			}
			i ++; 
		}


		/*
		if ((nBlankCount != 0) &&
		    (nBlankCount >= (m_menuItems.GetSize() - 1))
			)
			return FALSE;
		*/

		// gestione radio button
		for (int i = 0; i < m_menuItems.GetSize(); i++)
		{
			if (m_menuItems[i].mii.fType & MFT_RADIOCHECK)
			{
				// back
				for (int k = i; k >= 0; k--)
				{
					if (!(m_menuItems[k].bFollowSeparator))
						m_menuItems[k].mii.fType |= MFT_RADIOCHECK;
					else
						break;
				}
				// forward
				for (int k = i; k < m_menuItems.GetSize(); k++)
				{
					if (!(m_menuItems[k].bFollowSeparator))
						m_menuItems[k].mii.fType |= MFT_RADIOCHECK;
					else
						break;
				}
				break;
			}
		}

		m_menuView.Show();

		return TRUE;
	}


public:
	static HRESULT ActivatePreviousInstance(HINSTANCE hInstance)
	{
		const TCHAR* pszMutex = L"FINGERMENUMUTEX";
		const TCHAR* pszClass = L"FINGER_MENU";

		const DWORD dRetryInterval = 100; 

		const int iMaxRetries = 25;

		for(int i = 0; i < iMaxRetries; ++i)
		{
			// Don't need ownership of the mutex
			HANDLE hMutex = CreateMutex(NULL, FALSE, pszMutex);

			DWORD dw = GetLastError();

			if(hMutex == NULL)
			{
				// ERROR_INVALID_HANDLE - A non-mutex object with this name already exists.
				HRESULT hr = (dw == ERROR_INVALID_HANDLE) ? E_INVALIDARG : E_FAIL;
				return hr;
			}

			// If the mutex already exists, then there should be another instance running
			if(dw == ERROR_ALREADY_EXISTS)
			{
				// Just needed the error result, in this case, so close the handle.
				CloseHandle(hMutex);

				// Try to find the other instance, don't need to close HWND's.
				// Don't check title in case it is changed by app after init.
				HWND hwnd = FindWindow(pszClass, NULL);

				if(hwnd == NULL)
				{
					// It's possible that the other istance is in the process of starting up or shutting down.
					// So wait a bit and try again.
					Sleep(dRetryInterval);
					continue;
				}
				else
				{
					// Set the previous instance as the foreground window

					// The "| 0x1" in the code below activates the correct owned window 
					// of the previous instance's main window according to the SmartPhone 2003
					// wizard generated code.
					if(SetForegroundWindow(reinterpret_cast<HWND>(reinterpret_cast<ULONG>(hwnd) | 0x1)) != 0)
					{
						// S_FALSE indicates that another instance was activated, so this instance should terminate.
						return S_FALSE;
					}
				}
			}
			else
			{
				// This is the first istance, so return S_OK.
				// Don't close the mutext handle here.
				// Do it on app shutdown instead.
				return S_OK;
			}
		}

		// The mutex was created by another instance, but it's window couldn't be brought
		// to the foreground, so ssume  it's not a invalid instance (not this app, hung, etc.)
		// and let this one start.
		return S_OK;
	}

	void CreateConfigMenu()
	{
		m_menuConfig.CreatePopupMenu();
		m_menuConfig.AppendMenuW(MF_STRING, ID_MENU_ADDTOEXCLUSIONLIST, LoadResourceString(IDS_MENU_ADDTOEXCLUSIONLIST)); // L"Add to Exclusion list");
		m_menuConfig.AppendMenuW(MF_STRING, ID_MENU_ADDTOWNDEXCLUSIONLIST, LoadResourceString(IDS_MENU_ADDTOWNDEXCLUSIONLIST)); // L"Add to Exclusion list");
		m_menuConfig.AppendMenuW(MF_STRING, ID_MENU_SHOWORIGINAL, LoadResourceString(IDS_MENU_SHOWORIGINAL));
		m_menuConfig.AppendMenuW(MF_STRING, ID_MENU_ABOUT, LoadResourceString(IDS_MENU_ABOUT));
		m_menuConfig.AppendMenuW(MF_STRING, ID_MENU_EXIT, LoadResourceString(IDS_MENU_EXIT));
	}

	void SwitchToMenuView()
	{
		m_hWndClient = m_menuView;

		m_aboutView.ShowWindow(SW_HIDE);
		m_aboutView.SetWindowLongPtr(GWL_ID, 0);

		m_menuView.ShowWindow(SW_SHOW);
		m_menuView.SetWindowLongPtr(GWL_ID, ATL_IDW_PANE_FIRST);
		m_menuView.SetFocus();

	}

	void SwitchToAboutView()
	{
		m_hWndClient = m_aboutView;

		m_menuView.ShowWindow(SW_HIDE);
		m_menuView.SetWindowLongPtr(GWL_ID, 0);

		m_aboutView.ShowWindow(SW_SHOW);
		m_aboutView.SetWindowLongPtr(GWL_ID, ATL_IDW_PANE_FIRST);
		m_aboutView.SetFocus();
		UpdateLayout();
	}





	void ManageSIP()
	{

	}

protected:
	CxImage m_imgBkg;

	BOOL m_bDisabledTransp;
	COLORREF m_clNoTranspBackground;
	DWORD m_iTransp;
	BOOL m_bEnableSIP;
	BOOL m_bEnableDD;
	CMenu m_menuConfig;
	CSimpleArray<CString, CStringEqualHelper<CString>> m_excludedApps;
	CSimpleArray<CString, CStringEqualHelper<CString>> m_excludedWnds;
	DWORD m_iDisableInterval;
	
	// back gesture recognition
	int m_xPos;
	int m_backGestureThreshold;
	BOOL m_bMouseIsDown;


	HWND m_hDestWnd;
	HWND m_hPrevDestWnd;
	HWND m_hDestCtrl;
	BOOL m_bSendCmd;
	UINT m_uFlags;

};



<file_sep>/FBReaderJ/local.properties
sdk-location=/home/tao/Desktop/tao/Program/android-sdk_r06-linux/
<file_sep>/FingerSuite/FingerMenuCTRL/skins/default/settings_fingermenu.ini
[colors]
BkgColor=255 255 255
TextColor=0 0 0
SelTextColor=255 255 255 
DisabledTextColor=160 160 160
LineColor=200 200 200
ScrollbarColor=160 160 160

; Font settings.
; Options (separated by comma)
; 1. font weight: must be one in "regular", "italic", "bold", "bold italic"
; 2. font height in points
; 3. font face name
[fonts]
; examples
; TextFont=,8p,Arial
; TextFont=italic,,Tahoma
TextFont=bold,,
<file_sep>/SQLCEHelper/Source/Session.cpp

#include "stdafx.h"

using namespace OLEDBCLI;


CSession::CSession()
:	m_pSessionProps(NULL)
{
}


CSession::~CSession()
{
	Close();
}


HRESULT CSession::Open(ISessionProperties* pSessionProperties)
{
	Close();
	m_pSessionProps = pSessionProperties;

	return S_OK;
}


// CSession::Open
//
//		Open a new session on the data source
//
HRESULT CSession::Open(const CDataSource& dataSource)
{
	HRESULT						hr;
	IDBInitialize*				pInitialize	= dataSource;
	CComPtr<IDBCreateSession>	spCreateSession;

	if(pInitialize == NULL)
		return E_NOINTERFACE;

	Close();
	hr = pInitialize->QueryInterface(IID_IDBCreateSession, (void**)&spCreateSession);
	if(SUCCEEDED(hr))
		hr = spCreateSession->CreateSession(NULL, IID_ISessionProperties, (IUnknown**)&m_pSessionProps);

	return hr;
}


// CSession::Close
//
//		Closes the session
//
void CSession::Close()
{
	if(m_pSessionProps != NULL)
	{
		m_pSessionProps->Release();
		m_pSessionProps = NULL;
	}
}


// CSession::SetProperties
//
//		Set the session's properties
//
HRESULT CSession::SetProperties(ULONG cPropSets, DBPROPSET rgPropSets[])
{
	HRESULT	hr = E_NOINTERFACE;

	if(m_pSessionProps == NULL)
		return hr;

	hr = m_pSessionProps->SetProperties(cPropSets, rgPropSets);

	return hr;
}
<file_sep>/FBReaderJ/jni/ModelReader/ModelReader.cpp
#include <vector>

std::vector<int> foo() {
	std::vector<int> v;
	v.push_back(1);
	return v;
}
<file_sep>/7-Zip/CPP/7zip/UI/FileManager/ProgramLocation.cpp
// ProgramLocation.cpp

#include "StdAfx.h"

#include "ProgramLocation.h"

#include "Windows/DLL.h"

using namespace NWindows;

extern HINSTANCE g_hInstance;

bool GetProgramFolderPath(UString &folder)
{
  if (!NDLL::MyGetModuleFileName(g_hInstance, folder))
    return false;
  int pos = folder.ReverseFind(WCHAR_PATH_SEPARATOR);
  if (pos < 0)
    return false;
  folder = folder.Left(pos + 1);
  return true;
}

<file_sep>/7-Zip/CPP/7zip/Archive/Zip/ZipIn.h
// Archive/ZipIn.h

#ifndef __ZIP_IN_H
#define __ZIP_IN_H

#include "Common/MyCom.h"

#include "../../IStream.h"

#include "../../Common/InBuffer.h"

#include "ZipHeader.h"
#include "ZipItemEx.h"

namespace NArchive {
namespace NZip {
  
class CInArchiveException
{
public:
  enum ECauseType
  {
    kUnexpectedEndOfArchive = 0,
    kArchiceHeaderCRCError,
    kFileHeaderCRCError,
    kIncorrectArchive,
    kDataDescroptorsAreNotSupported,
    kMultiVolumeArchiveAreNotSupported,
    kReadStreamError,
    kSeekStreamError
  }
  Cause;
  CInArchiveException(ECauseType cause): Cause(cause) {}
};

class CInArchiveInfo
{
public:
  UInt64 Base;
  UInt64 StartPosition;
  CByteBuffer Comment;
  CInArchiveInfo(): Base(0), StartPosition(0) {}
  void Clear()
  {
    Base = 0;
    StartPosition = 0;
    Comment.SetCapacity(0);
  }
};

class CProgressVirt
{
public:
  STDMETHOD(SetTotal)(UInt64 numFiles) PURE;
  STDMETHOD(SetCompleted)(UInt64 numFiles) PURE;
};

struct CCdInfo
{
  // UInt64 NumEntries;
  UInt64 Size;
  UInt64 Offset;
};

class CInArchive
{
  CMyComPtr<IInStream> m_Stream;
  UInt32 m_Signature;
  UInt64 m_StreamStartPosition;
  UInt64 m_Position;
 
  bool _inBufMode;
  CInBuffer _inBuffer;
  
  HRESULT Seek(UInt64 offset);

  HRESULT FindAndReadMarker(IInStream *stream, const UInt64 *searchHeaderSizeLimit);
  void ReadFileName(UInt32 nameSize, AString &dest);
  
  HRESULT ReadBytes(void *data, UInt32 size, UInt32 *processedSize);
  bool ReadBytesAndTestSize(void *data, UInt32 size);
  void SafeReadBytes(void *data, UInt32 size);
  void ReadBuffer(CByteBuffer &buffer, UInt32 size);
  Byte ReadByte();
  UInt16 ReadUInt16();
  UInt32 ReadUInt32();
  UInt64 ReadUInt64();
  bool ReadUInt32(UInt32 &signature);
  
  void Skip(UInt64 num);
  void IncreaseRealPosition(UInt64 addValue);
 
  void ReadExtra(UInt32 extraSize, CExtraBlock &extraBlock,
      UInt64 &unpackSize, UInt64 &packSize, UInt64 &localHeaderOffset, UInt32 &diskStartNumber);
  HRESULT ReadLocalItem(CItemEx &item);
  HRESULT ReadLocalItemDescriptor(CItemEx &item);
  HRESULT ReadCdItem(CItemEx &item);
  HRESULT TryEcd64(UInt64 offset, CCdInfo &cdInfo);
  HRESULT FindCd(CCdInfo &cdInfo);
  HRESULT TryReadCd(CObjectVector<CItemEx> &items, UInt64 cdOffset, UInt64 cdSize, CProgressVirt *progress);
  HRESULT ReadCd(CObjectVector<CItemEx> &items, UInt64 &cdOffset, UInt64 &cdSize, CProgressVirt *progress);
  HRESULT ReadLocalsAndCd(CObjectVector<CItemEx> &items, CProgressVirt *progress, UInt64 &cdOffset, int &numCdItems);
public:
  CInArchiveInfo m_ArchiveInfo;
  bool IsZip64;
  bool IsOkHeaders;

  HRESULT ReadHeaders(CObjectVector<CItemEx> &items, CProgressVirt *progress);
  HRESULT ReadLocalItemAfterCdItem(CItemEx &item);
  HRESULT ReadLocalItemAfterCdItemFull(CItemEx &item);
  HRESULT Open(IInStream *stream, const UInt64 *searchHeaderSizeLimit);
  void Close();
  void GetArchiveInfo(CInArchiveInfo &archiveInfo) const;
  bool SeekInArchive(UInt64 position);
  ISequentialInStream *CreateLimitedStream(UInt64 position, UInt64 size);
  IInStream* CreateStream();

  bool IsOpen() const { return m_Stream != NULL; }
};
  
}}
  
#endif
<file_sep>/7-Zip/CPP/7zip/Archive/Cab/CabHandler.cpp
// CabHandler.cpp

#include "StdAfx.h"

#include "Common/Buffer.h"
#include "Common/ComTry.h"
#include "Common/Defs.h"
#include "Common/IntToString.h"
#include "Common/StringConvert.h"
#include "Common/UTFConvert.h"

#include "Windows/PropVariant.h"
#include "Windows/Time.h"

#include "../../Common/ProgressUtils.h"
#include "../../Common/StreamUtils.h"

#include "../../Compress/CopyCoder.h"
#include "../../Compress/DeflateDecoder.h"
#include "../../Compress/LzxDecoder.h"
#include "../../Compress/QuantumDecoder.h"

#include "../Common/ItemNameUtils.h"

#include "CabBlockInStream.h"
#include "CabHandler.h"

using namespace NWindows;

namespace NArchive {
namespace NCab {

// #define _CAB_DETAILS

static const UInt32 kMaxTempBufSize = 1 << 20;

#ifdef _CAB_DETAILS
enum
{
  kpidBlockReal = kpidUserDefined
};
#endif

STATPROPSTG kProps[] =
{
  { NULL, kpidPath, VT_BSTR},
  { NULL, kpidSize, VT_UI8},
  { NULL, kpidMTime, VT_FILETIME},
  { NULL, kpidAttrib, VT_UI4},
  { NULL, kpidMethod, VT_BSTR},
  { NULL, kpidBlock, VT_I4}
  #ifdef _CAB_DETAILS
  ,
  { L"BlockReal", kpidBlockReal, VT_UI4},
  { NULL, kpidOffset, VT_UI4},
  { NULL, kpidVolume, VT_UI4}
  #endif
};

static const wchar_t *kMethods[] =
{
  L"None",
  L"MSZip",
  L"Quantum",
  L"LZX"
};

static const int kNumMethods = sizeof(kMethods) / sizeof(kMethods[0]);
static const wchar_t *kUnknownMethod = L"Unknown";

STATPROPSTG kArcProps[] =
{
  { NULL, kpidMethod, VT_BSTR},
  // { NULL, kpidSolid, VT_BOOL},
  { NULL, kpidNumBlocks, VT_UI4},
  { NULL, kpidNumVolumes, VT_UI4}
};

IMP_IInArchive_Props
IMP_IInArchive_ArcProps

STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
{
  COM_TRY_BEGIN
  NWindows::NCOM::CPropVariant prop;
  switch(propID)
  {
    case kpidMethod:
    {
      UString resString;
      CRecordVector<Byte> ids;
      int i;
      for (int v = 0; v < m_Database.Volumes.Size(); v++)
      {
        const CDatabaseEx &de = m_Database.Volumes[v];
        for (i = 0; i < de.Folders.Size(); i++)
          ids.AddToUniqueSorted(de.Folders[i].GetCompressionMethod());
      }
      for (i = 0; i < ids.Size(); i++)
      {
        Byte id = ids[i];
        UString method = (id < kNumMethods) ? kMethods[id] : kUnknownMethod;
        if (!resString.IsEmpty())
          resString += L' ';
        resString += method;
      }
      prop = resString;
      break;
    }
    // case kpidSolid: prop = _database.IsSolid(); break;
    case kpidNumBlocks:
    {
      UInt32 numFolders = 0;
      for (int v = 0; v < m_Database.Volumes.Size(); v++)
        numFolders += m_Database.Volumes[v].Folders.Size();
      prop = numFolders;
      break;
    }
    case kpidNumVolumes:
    {
      prop = (UInt32)m_Database.Volumes.Size();
      break;
    }
  }
  prop.Detach(value);
  return S_OK;
  COM_TRY_END
}

STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID,  PROPVARIANT *value)
{
  COM_TRY_BEGIN
  NWindows::NCOM::CPropVariant prop;
  
  const CMvItem &mvItem = m_Database.Items[index];
  const CDatabaseEx &db = m_Database.Volumes[mvItem.VolumeIndex];
  int itemIndex = mvItem.ItemIndex;
  const CItem &item = db.Items[itemIndex];
  switch(propID)
  {
    case kpidPath:
    {
      UString unicodeName;
      if (item.IsNameUTF())
        ConvertUTF8ToUnicode(item.Name, unicodeName);
      else
        unicodeName = MultiByteToUnicodeString(item.Name, CP_ACP);
      prop = (const wchar_t *)NItemName::WinNameToOSName(unicodeName);
      break;
    }
    case kpidIsDir:  prop = item.IsDir(); break;
    case kpidSize:  prop = item.Size; break;
    case kpidAttrib:  prop = item.GetWinAttributes(); break;

    case kpidMTime:
    {
      FILETIME localFileTime, utcFileTime;
      if (NTime::DosTimeToFileTime(item.Time, localFileTime))
      {
        if (!LocalFileTimeToFileTime(&localFileTime, &utcFileTime))
          utcFileTime.dwHighDateTime = utcFileTime.dwLowDateTime = 0;
      }
      else
        utcFileTime.dwHighDateTime = utcFileTime.dwLowDateTime = 0;
      prop = utcFileTime;
      break;
    }

    case kpidMethod:
    {
      UInt32 realFolderIndex = item.GetFolderIndex(db.Folders.Size());
      const CFolder &folder = db.Folders[realFolderIndex];
      int methodIndex = folder.GetCompressionMethod();
      UString method = (methodIndex < kNumMethods) ? kMethods[methodIndex] : kUnknownMethod;
      if (methodIndex == NHeader::NCompressionMethodMajor::kLZX ||
        methodIndex == NHeader::NCompressionMethodMajor::kQuantum)
      {
        method += L":";
        wchar_t temp[32];
        ConvertUInt64ToString(folder.CompressionTypeMinor, temp);
        method += temp;
      }
      prop = method;
      break;
    }
    case kpidBlock:  prop = (Int32)m_Database.GetFolderIndex(&mvItem); break;
    
    #ifdef _CAB_DETAILS
    
    case kpidBlockReal:  prop = (UInt32)item.FolderIndex; break;
    case kpidOffset:  prop = (UInt32)item.Offset; break;
    case kpidVolume:  prop = (UInt32)mvItem.VolumeIndex; break;

    #endif
  }
  prop.Detach(value);
  return S_OK;
  COM_TRY_END
}

/*
class CProgressImp: public CProgressVirt
{
  CMyComPtr<IArchiveOpenCallback> m_OpenArchiveCallback;
public:
  STDMETHOD(SetTotal)(const UInt64 *numFiles);
  STDMETHOD(SetCompleted)(const UInt64 *numFiles);
  void Init(IArchiveOpenCallback *openArchiveCallback)
    { m_OpenArchiveCallback = openArchiveCallback; }
};

STDMETHODIMP CProgressImp::SetTotal(const UInt64 *numFiles)
{
  if (m_OpenArchiveCallback)
    return m_OpenArchiveCallback->SetCompleted(numFiles, NULL);
  return S_OK;
}

STDMETHODIMP CProgressImp::SetCompleted(const UInt64 *numFiles)
{
  if (m_OpenArchiveCallback)
    return m_OpenArchiveCallback->SetCompleted(numFiles, NULL);
  return S_OK;
}
*/

STDMETHODIMP CHandler::Open(IInStream *inStream,
    const UInt64 *maxCheckStartPosition,
    IArchiveOpenCallback *callback)
{
  COM_TRY_BEGIN
  Close();
  HRESULT res = S_FALSE;
  CInArchive archive;
  CMyComPtr<IArchiveOpenVolumeCallback> openVolumeCallback;
  callback->QueryInterface(IID_IArchiveOpenVolumeCallback, (void **)&openVolumeCallback);
  
  CMyComPtr<IInStream> nextStream = inStream;
  bool prevChecked = false;
  UInt64 numItems = 0;
  try
  {
    while (nextStream != 0)
    {
      CDatabaseEx db;
      db.Stream = nextStream;
      res = archive.Open(maxCheckStartPosition, db);
      if (res == S_OK)
      {
        if (!m_Database.Volumes.IsEmpty())
        {
          const CDatabaseEx &dbPrev = m_Database.Volumes[prevChecked ? m_Database.Volumes.Size() - 1 : 0];
          if (dbPrev.ArchiveInfo.SetID != db.ArchiveInfo.SetID ||
              dbPrev.ArchiveInfo.CabinetNumber + (prevChecked ? 1: - 1) !=
              db.ArchiveInfo.CabinetNumber)
            res = S_FALSE;
        }
      }
      if (res == S_OK)
        m_Database.Volumes.Insert(prevChecked ? m_Database.Volumes.Size() : 0, db);
      else if (res != S_FALSE)
        return res;
      else
      {
        if (m_Database.Volumes.IsEmpty())
          return S_FALSE;
        if (prevChecked)
          break;
        prevChecked = true;
      }

      numItems += db.Items.Size();
      RINOK(callback->SetCompleted(&numItems, NULL));
        
      nextStream = 0;
      for (;;)
      {
        const COtherArchive *otherArchive = 0;
        if (!prevChecked)
        {
          const CInArchiveInfo &ai = m_Database.Volumes.Front().ArchiveInfo;
          if (ai.IsTherePrev())
            otherArchive = &ai.PrevArc;
          else
            prevChecked = true;
        }
        if (otherArchive == 0)
        {
          const CInArchiveInfo &ai = m_Database.Volumes.Back().ArchiveInfo;
          if (ai.IsThereNext())
            otherArchive = &ai.NextArc;
        }
        if (!otherArchive)
          break;
        const UString fullName = MultiByteToUnicodeString(otherArchive->FileName, CP_ACP);
        if (!openVolumeCallback)
          break;

        HRESULT result = openVolumeCallback->GetStream(fullName, &nextStream);
        if (result == S_OK)
          break;
        if (result != S_FALSE)
          return result;
        if (prevChecked)
          break;
        prevChecked = true;
      }
    }
    if (res == S_OK)
    {
      m_Database.FillSortAndShrink();
      if (!m_Database.Check())
        res = S_FALSE;
    }
  }
  catch(...)
  {
    res = S_FALSE;
  }
  if (res != S_OK)
  {
    Close();
    return res;
  }
  COM_TRY_END
  return S_OK;
}

STDMETHODIMP CHandler::Close()
{
  m_Database.Clear();
  return S_OK;
}

class CFolderOutStream:
  public ISequentialOutStream,
  public CMyUnknownImp
{
public:
  MY_UNKNOWN_IMP

  STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
private:
  const CMvDatabaseEx *m_Database;
  const CRecordVector<bool> *m_ExtractStatuses;
  
  CByteBuffer TempBuf;
  bool TempBufMode;
  bool IsSupported;
  UInt32 m_BufStartFolderOffset;

  int m_StartIndex;
  int m_CurrentIndex;
  CMyComPtr<IArchiveExtractCallback> m_ExtractCallback;
  bool m_TestMode;

  CMyComPtr<ISequentialOutStream> m_RealOutStream;

  bool m_IsOk;
  bool m_FileIsOpen;
  UInt32 m_RemainFileSize;
  UInt64 m_FolderSize;
  UInt64 m_PosInFolder;

  HRESULT OpenFile();
  HRESULT CloseFile();
  HRESULT Write2(const void *data, UInt32 size, UInt32 *processedSize, bool isOK);
public:
  HRESULT WriteEmptyFiles();

  void Init(
      const CMvDatabaseEx *database,
      const CRecordVector<bool> *extractStatuses,
      int startIndex,
      UInt64 folderSize,
      IArchiveExtractCallback *extractCallback,
      bool testMode);
  HRESULT FlushCorrupted();
  HRESULT Unsupported();

  UInt64 GetRemain() const { return m_FolderSize - m_PosInFolder; }
  UInt64 GetPosInFolder() const { return m_PosInFolder; }
};

void CFolderOutStream::Init(
    const CMvDatabaseEx *database,
    const CRecordVector<bool> *extractStatuses,
    int startIndex,
    UInt64 folderSize,
    IArchiveExtractCallback *extractCallback,
    bool testMode)
{
  m_Database = database;
  m_ExtractStatuses = extractStatuses;
  m_StartIndex = startIndex;
  m_FolderSize = folderSize;

  m_ExtractCallback = extractCallback;
  m_TestMode = testMode;

  m_CurrentIndex = 0;
  m_PosInFolder = 0;
  m_FileIsOpen = false;
  m_IsOk = true;
  TempBufMode = false;
}

HRESULT CFolderOutStream::CloseFile()
{
  m_RealOutStream.Release();
  HRESULT res = m_ExtractCallback->SetOperationResult(m_IsOk ?
      NExtract::NOperationResult::kOK:
      NExtract::NOperationResult::kDataError);
  m_FileIsOpen = false;
  return res;
}

HRESULT CFolderOutStream::OpenFile()
{
  Int32 askMode = (*m_ExtractStatuses)[m_CurrentIndex] ? (m_TestMode ?
      NExtract::NAskMode::kTest :
      NExtract::NAskMode::kExtract) :
      NExtract::NAskMode::kSkip;
  
  if (!TempBufMode)
  {
    const CMvItem &mvItem = m_Database->Items[m_StartIndex + m_CurrentIndex];
    const CItem &item = m_Database->Volumes[mvItem.VolumeIndex].Items[mvItem.ItemIndex];
    int curIndex = m_CurrentIndex + 1;
    for (; curIndex < m_ExtractStatuses->Size(); curIndex++)
      if ((*m_ExtractStatuses)[curIndex])
      {
        const CMvItem &mvItem2 = m_Database->Items[m_StartIndex + curIndex];
        const CItem &item2 = m_Database->Volumes[mvItem2.VolumeIndex].Items[mvItem2.ItemIndex];
        if (item.Offset != item2.Offset ||
            item.Size != item2.Size ||
            item.Size == 0)
          break;
      }
    if (curIndex > m_CurrentIndex + 1)
    {
      size_t oldCapacity = TempBuf.GetCapacity();
      IsSupported = (item.Size <= kMaxTempBufSize);
      if (item.Size > oldCapacity && IsSupported)
      {
        TempBuf.SetCapacity(0);
        TempBuf.SetCapacity(item.Size);
      }
      TempBufMode = true;
      m_BufStartFolderOffset = item.Offset;
    }
  }

  RINOK(m_ExtractCallback->GetStream(m_StartIndex + m_CurrentIndex, &m_RealOutStream, askMode));
  if (!m_RealOutStream && !m_TestMode)
    askMode = NExtract::NAskMode::kSkip;
  return m_ExtractCallback->PrepareOperation(askMode);
}

HRESULT CFolderOutStream::WriteEmptyFiles()
{
  if (m_FileIsOpen)
    return S_OK;
  for (; m_CurrentIndex < m_ExtractStatuses->Size(); m_CurrentIndex++)
  {
    const CMvItem &mvItem = m_Database->Items[m_StartIndex + m_CurrentIndex];
    const CItem &item = m_Database->Volumes[mvItem.VolumeIndex].Items[mvItem.ItemIndex];
    UInt64 fileSize = item.Size;
    if (fileSize != 0)
      return S_OK;
    HRESULT result = OpenFile();
    m_RealOutStream.Release();
    RINOK(result);
    RINOK(m_ExtractCallback->SetOperationResult(NExtract::NOperationResult::kOK));
  }
  return S_OK;
}

// This is Write function
HRESULT CFolderOutStream::Write2(const void *data, UInt32 size, UInt32 *processedSize, bool isOK)
{
  COM_TRY_BEGIN
  UInt32 realProcessed = 0;
  if (processedSize != NULL)
   *processedSize = 0;
  while (size != 0)
  {
    if (m_FileIsOpen)
    {
      UInt32 numBytesToWrite = MyMin(m_RemainFileSize, size);
      HRESULT res = S_OK;
      if (numBytesToWrite > 0)
      {
        if (!isOK)
          m_IsOk = false;
        if (m_RealOutStream)
        {
          UInt32 processedSizeLocal = 0;
          res = m_RealOutStream->Write((const Byte *)data, numBytesToWrite, &processedSizeLocal);
          numBytesToWrite = processedSizeLocal;
        }
        if (TempBufMode && IsSupported)
          memcpy(TempBuf + (m_PosInFolder - m_BufStartFolderOffset), data, numBytesToWrite);
      }
      realProcessed += numBytesToWrite;
      if (processedSize != NULL)
        *processedSize = realProcessed;
      data = (const void *)((const Byte *)data + numBytesToWrite);
      size -= numBytesToWrite;
      m_RemainFileSize -= numBytesToWrite;
      m_PosInFolder += numBytesToWrite;
      if (res != S_OK)
        return res;
      if (m_RemainFileSize == 0)
      {
        m_RealOutStream.Release();
        RINOK(CloseFile());

        if (TempBufMode)
        {
          while (m_CurrentIndex < m_ExtractStatuses->Size())
          {
            const CMvItem &mvItem = m_Database->Items[m_StartIndex + m_CurrentIndex];
            const CItem &item = m_Database->Volumes[mvItem.VolumeIndex].Items[mvItem.ItemIndex];
            if (item.Offset != m_BufStartFolderOffset)
              break;
            HRESULT result = OpenFile();
            m_FileIsOpen = true;
            m_CurrentIndex++;
            m_IsOk = true;
            if (result == S_OK && m_RealOutStream && IsSupported)
              result = WriteStream(m_RealOutStream, TempBuf, item.Size);

            if (IsSupported)
            {
              RINOK(CloseFile());
              RINOK(result);
            }
            else
            {
              m_RealOutStream.Release();
              RINOK(m_ExtractCallback->SetOperationResult(NExtract::NOperationResult::kUnSupportedMethod));
              m_FileIsOpen = false;
            }
          }
          TempBufMode = false;
        }
      }
      if (realProcessed > 0)
        break; // with this break this function works as Write-Part
    }
    else
    {
      if (m_CurrentIndex >= m_ExtractStatuses->Size())
        return E_FAIL;

      const CMvItem &mvItem = m_Database->Items[m_StartIndex + m_CurrentIndex];
      const CItem &item = m_Database->Volumes[mvItem.VolumeIndex].Items[mvItem.ItemIndex];

      m_RemainFileSize = item.Size;

      UInt32 fileOffset = item.Offset;
      if (fileOffset < m_PosInFolder)
        return E_FAIL;
      if (fileOffset > m_PosInFolder)
      {
        UInt32 numBytesToWrite = MyMin(fileOffset - (UInt32)m_PosInFolder, size);
        realProcessed += numBytesToWrite;
        if (processedSize != NULL)
          *processedSize = realProcessed;
        data = (const void *)((const Byte *)data + numBytesToWrite);
        size -= numBytesToWrite;
        m_PosInFolder += numBytesToWrite;
      }
      if (fileOffset == m_PosInFolder)
      {
        RINOK(OpenFile());
        m_FileIsOpen = true;
        m_CurrentIndex++;
        m_IsOk = true;
      }
    }
  }
  return WriteEmptyFiles();
  COM_TRY_END
}

STDMETHODIMP CFolderOutStream::Write(const void *data, UInt32 size, UInt32 *processedSize)
{
  return Write2(data, size, processedSize, true);
}

HRESULT CFolderOutStream::FlushCorrupted()
{
  const UInt32 kBufferSize = (1 << 10);
  Byte buffer[kBufferSize];
  for (int i = 0; i < kBufferSize; i++)
    buffer[i] = 0;
  for (;;)
  {
    UInt64 remain = GetRemain();
    if (remain == 0)
      return S_OK;
    UInt32 size = (UInt32)MyMin(remain, (UInt64)kBufferSize);
    UInt32 processedSizeLocal = 0;
    RINOK(Write2(buffer, size, &processedSizeLocal, false));
  }
}

HRESULT CFolderOutStream::Unsupported()
{
  while(m_CurrentIndex < m_ExtractStatuses->Size())
  {
    HRESULT result = OpenFile();
    if (result != S_FALSE && result != S_OK)
      return result;
    m_RealOutStream.Release();
    RINOK(m_ExtractCallback->SetOperationResult(NExtract::NOperationResult::kUnSupportedMethod));
    m_CurrentIndex++;
  }
  return S_OK;
}


STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
    Int32 testModeSpec, IArchiveExtractCallback *extractCallback)
{
  COM_TRY_BEGIN
  bool allFilesMode = (numItems == (UInt32)-1);
  if (allFilesMode)
    numItems = m_Database.Items.Size();
  if(numItems == 0)
    return S_OK;
  bool testMode = (testModeSpec != 0);
  UInt64 totalUnPacked = 0;

  UInt32 i;
  int lastFolder = -2;
  UInt64 lastFolderSize = 0;
  for(i = 0; i < numItems; i++)
  {
    int index = allFilesMode ? i : indices[i];
    const CMvItem &mvItem = m_Database.Items[index];
    const CItem &item = m_Database.Volumes[mvItem.VolumeIndex].Items[mvItem.ItemIndex];
    if (item.IsDir())
      continue;
    int folderIndex = m_Database.GetFolderIndex(&mvItem);
    if (folderIndex != lastFolder)
      totalUnPacked += lastFolderSize;
    lastFolder = folderIndex;
    lastFolderSize = item.GetEndOffset();
  }
  totalUnPacked += lastFolderSize;

  extractCallback->SetTotal(totalUnPacked);

  totalUnPacked = 0;

  UInt64 totalPacked = 0;

  CLocalProgress *lps = new CLocalProgress;
  CMyComPtr<ICompressProgressInfo> progress = lps;
  lps->Init(extractCallback, false);

  NCompress::CCopyCoder *copyCoderSpec = new NCompress::CCopyCoder;
  CMyComPtr<ICompressCoder> copyCoder = copyCoderSpec;

  NCompress::NDeflate::NDecoder::CCOMCoder *deflateDecoderSpec = NULL;
  CMyComPtr<ICompressCoder> deflateDecoder;

  NCompress::NLzx::CDecoder *lzxDecoderSpec = NULL;
  CMyComPtr<ICompressCoder> lzxDecoder;

  NCompress::NQuantum::CDecoder *quantumDecoderSpec = NULL;
  CMyComPtr<ICompressCoder> quantumDecoder;

  CCabBlockInStream *cabBlockInStreamSpec = new CCabBlockInStream();
  CMyComPtr<ISequentialInStream> cabBlockInStream = cabBlockInStreamSpec;
  if (!cabBlockInStreamSpec->Create())
    return E_OUTOFMEMORY;

  CRecordVector<bool> extractStatuses;
  for(i = 0; i < numItems;)
  {
    int index = allFilesMode ? i : indices[i];

    const CMvItem &mvItem = m_Database.Items[index];
    const CDatabaseEx &db = m_Database.Volumes[mvItem.VolumeIndex];
    int itemIndex = mvItem.ItemIndex;
    const CItem &item = db.Items[itemIndex];

    i++;
    if (item.IsDir())
    {
      Int32 askMode = testMode ?
          NExtract::NAskMode::kTest :
          NExtract::NAskMode::kExtract;
      CMyComPtr<ISequentialOutStream> realOutStream;
      RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
      RINOK(extractCallback->PrepareOperation(askMode));
      realOutStream.Release();
      RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kOK));
      continue;
    }
    int folderIndex = m_Database.GetFolderIndex(&mvItem);
    if (folderIndex < 0)
    {
      // If we need previous archive
      Int32 askMode= testMode ?
          NExtract::NAskMode::kTest :
          NExtract::NAskMode::kExtract;
      CMyComPtr<ISequentialOutStream> realOutStream;
      RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
      RINOK(extractCallback->PrepareOperation(askMode));
      realOutStream.Release();
      RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kDataError));
      continue;
    }
    int startIndex2 = m_Database.FolderStartFileIndex[folderIndex];
    int startIndex = startIndex2;
    extractStatuses.Clear();
    for (; startIndex < index; startIndex++)
      extractStatuses.Add(false);
    extractStatuses.Add(true);
    startIndex++;
    UInt64 curUnpack = item.GetEndOffset();
    for(;i < numItems; i++)
    {
      int indexNext = allFilesMode ? i : indices[i];
      const CMvItem &mvItem = m_Database.Items[indexNext];
      const CItem &item = m_Database.Volumes[mvItem.VolumeIndex].Items[mvItem.ItemIndex];
      if (item.IsDir())
        continue;
      int newFolderIndex = m_Database.GetFolderIndex(&mvItem);

      if (newFolderIndex != folderIndex)
        break;
      for (; startIndex < indexNext; startIndex++)
        extractStatuses.Add(false);
      extractStatuses.Add(true);
      startIndex++;
      curUnpack = item.GetEndOffset();
    }

    lps->OutSize = totalUnPacked;
    lps->InSize = totalPacked;
    RINOK(lps->SetCur());

    CFolderOutStream *cabFolderOutStream = new CFolderOutStream;
    CMyComPtr<ISequentialOutStream> outStream(cabFolderOutStream);

    const CFolder &folder = db.Folders[item.GetFolderIndex(db.Folders.Size())];

    cabFolderOutStream->Init(&m_Database, &extractStatuses, startIndex2,
        curUnpack, extractCallback, testMode);

    cabBlockInStreamSpec->MsZip = false;
    switch(folder.GetCompressionMethod())
    {
      case NHeader::NCompressionMethodMajor::kNone:
        break;
      case NHeader::NCompressionMethodMajor::kMSZip:
        if(deflateDecoderSpec == NULL)
        {
          deflateDecoderSpec = new NCompress::NDeflate::NDecoder::CCOMCoder;
          deflateDecoder = deflateDecoderSpec;
        }
        cabBlockInStreamSpec->MsZip = true;
        break;
      case NHeader::NCompressionMethodMajor::kLZX:
        if(lzxDecoderSpec == NULL)
        {
          lzxDecoderSpec = new NCompress::NLzx::CDecoder;
          lzxDecoder = lzxDecoderSpec;
        }
        RINOK(lzxDecoderSpec->SetParams(folder.CompressionTypeMinor));
        break;
      case NHeader::NCompressionMethodMajor::kQuantum:
        if(quantumDecoderSpec == NULL)
        {
          quantumDecoderSpec = new NCompress::NQuantum::CDecoder;
          quantumDecoder = quantumDecoderSpec;
        }
        quantumDecoderSpec->SetParams(folder.CompressionTypeMinor);
        break;
      default:
      {
        RINOK(cabFolderOutStream->Unsupported());
        totalUnPacked += curUnpack;
        continue;
      }
    }

    cabBlockInStreamSpec->InitForNewFolder();

    HRESULT res = S_OK;

    {
      int volIndex = mvItem.VolumeIndex;
      int locFolderIndex = item.GetFolderIndex(db.Folders.Size());
      bool keepHistory = false;
      bool keepInputBuffer = false;
      for (UInt32 f = 0; cabFolderOutStream->GetRemain() != 0;)
      {
        if (volIndex >= m_Database.Volumes.Size())
        {
          res = S_FALSE;
          break;
        }

        const CDatabaseEx &db = m_Database.Volumes[volIndex];
        const CFolder &folder = db.Folders[locFolderIndex];
        if (f == 0)
        {
          cabBlockInStreamSpec->SetStream(db.Stream);
          cabBlockInStreamSpec->ReservedSize = db.ArchiveInfo.GetDataBlockReserveSize();
          RINOK(db.Stream->Seek(db.StartPosition + folder.DataStart, STREAM_SEEK_SET, NULL));
        }
        if (f == folder.NumDataBlocks)
        {
          volIndex++;
          locFolderIndex = 0;
          f = 0;
          continue;
        }
        f++;

        cabBlockInStreamSpec->DataError = false;
        
        if (!keepInputBuffer)
          cabBlockInStreamSpec->InitForNewBlock();

        UInt32 packSize, unpackSize;
        res = cabBlockInStreamSpec->PreRead(packSize, unpackSize);
        if (res == S_FALSE)
          break;
        RINOK(res);
        keepInputBuffer = (unpackSize == 0);
        if (keepInputBuffer)
          continue;

        UInt64 totalUnPacked2 = totalUnPacked + cabFolderOutStream->GetPosInFolder();
        totalPacked += packSize;

        lps->OutSize = totalUnPacked2;
        lps->InSize = totalPacked;
        RINOK(lps->SetCur());

        UInt64 unpackRemain = cabFolderOutStream->GetRemain();

        const UInt32 kBlockSizeMax = (1 << 15);
        if (unpackRemain > kBlockSizeMax)
          unpackRemain = kBlockSizeMax;
        if (unpackRemain > unpackSize)
          unpackRemain  = unpackSize;
   
        switch(folder.GetCompressionMethod())
        {
          case NHeader::NCompressionMethodMajor::kNone:
            res = copyCoder->Code(cabBlockInStream, outStream, NULL, &unpackRemain, NULL);
            break;
          case NHeader::NCompressionMethodMajor::kMSZip:
            deflateDecoderSpec->SetKeepHistory(keepHistory);
            res = deflateDecoder->Code(cabBlockInStream, outStream, NULL, &unpackRemain, NULL);
            break;
          case NHeader::NCompressionMethodMajor::kLZX:
            lzxDecoderSpec->SetKeepHistory(keepHistory);
            res = lzxDecoder->Code(cabBlockInStream, outStream, NULL, &unpackRemain, NULL);
            break;
          case NHeader::NCompressionMethodMajor::kQuantum:
            quantumDecoderSpec->SetKeepHistory(keepHistory);
            res = quantumDecoder->Code(cabBlockInStream, outStream, NULL, &unpackRemain, NULL);
          break;
        }
        if (res != S_OK)
        {
          if (res != S_FALSE)
            RINOK(res);
          break;
        }
        keepHistory = true;
      }
      if (res == S_OK)
      {
        RINOK(cabFolderOutStream->WriteEmptyFiles());
      }
    }
    if (res != S_OK || cabFolderOutStream->GetRemain() != 0)
    {
      RINOK(cabFolderOutStream->FlushCorrupted());
    }
    totalUnPacked += curUnpack;
  }
  return S_OK;
  COM_TRY_END
}

STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
{
  *numItems = m_Database.Items.Size();
  return S_OK;
}

}}
<file_sep>/FingerSuite/FingerMsgBox/MsgBoxWindow.h
// WTLApp1View.h : interface of the CWTLApp1View class
//
/////////////////////////////////////////////////////////////////////////////

#pragma once

//#include "..\Common\ext\RegionBuilder.h"

#ifndef __FNGRBTN_H__
	#error MsgBoxWindows.h requires fngrbtn.h to be included first
#endif

#define UM_STARTANIM    WM_USER + 1 
#define UM_MINIMIZE     WM_USER + 2
#define BORDER_WIDTH    8
#define BOTTOM_BORDER_HEIGHT    3
#define LEFT_BORDER_WIDTH       3 
#define MIN_HEIGHT              80


#define IDC_BTN_OK      10001
#define IDC_BTN_CANCEL  10002
#define IDC_BTN_YES     10003
#define IDC_BTN_NO      10004
#define IDC_BTN_ABORT   10005
#define IDC_BTN_IGNORE  10006
#define IDC_BTN_RETRY   10007



class CMsgBoxWindow : public CWindowImpl<CMsgBoxWindow>
{
public:
	DECLARE_WND_CLASS(NULL)

	typedef CWindowImpl<CMsgBoxWindow> Super;

	// controls
	CFingerButton m_btn1;
	CFingerButton m_btn2;
	CFingerButton m_btn3;

	BOOL PreTranslateMessage(MSG* pMsg)
	{
		pMsg;
		return FALSE;
	}

	CMsgBoxWindow ()
	{
		m_iScaleFactor = 1;
	}

	HWND Create(HWND hWndParent)
	{
		m_btn1.SetArrayImageSet(m_arrDynamicImages);
		m_btn2.SetArrayImageSet(m_arrDynamicImages);
		m_btn3.SetArrayImageSet(m_arrDynamicImages);

		return Super::Create(hWndParent, rcDefault, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN);  
	}

	void SetScaleFactor(int iScaleFactor)
	{
		m_iScaleFactor = iScaleFactor;
	}

	BOOL SetMsgBox(HWND hOwnrWnd, UINT uType, LPCTSTR pwszCaption, LPCTSTR pwszText)
	{
		m_hOwnrWnd = hOwnrWnd;
		m_uType = uType;

		lstrcpy(m_szCaption, pwszCaption);
		lstrcpy(m_szText, pwszText);

		ModifyShape();
		ModifyButtons();
		return TRUE;
	}

	HWND GetOwnerWnd()
	{
		return m_hOwnrWnd;
	}

	void DoPaint(CDCHandle dc)
	{
		RECT rc; GetClientRect(&rc);
	
		// fill background
		dc.FillSolidRect(&rc, m_clBkg);

		int sx = m_icnInfo.GetWidth();
		int sy = m_icnInfo.GetHeight();

		RECT rcHeader; 
		SetRect(&rcHeader, 0, 0, rc.right, m_imgHeader.GetHeight());
		m_imgHeader.Draw(dc, rcHeader);


		BOOL bIconDrawn = FALSE;
		if ((m_uType & MB_ICONEXCLAMATION) || (m_uType & MB_ICONWARNING))
		{
			m_icnWarning.Draw(dc);
			bIconDrawn = TRUE;
			goto iconend;
		}

		if ((m_uType & MB_ICONINFORMATION) || (m_uType & MB_ICONASTERISK))
		{
			m_icnInfo.Draw(dc);
			bIconDrawn = TRUE;
			goto iconend;
		}

		if (m_uType & MB_ICONQUESTION)
		{
			m_icnQuestion.Draw(dc);
			bIconDrawn = TRUE;
			goto iconend;
		}

		if ((m_uType & MB_ICONSTOP) || (m_uType & MB_ICONERROR) || (m_uType & MB_ICONHAND))
		{
			m_icnStop.Draw(dc);
			bIconDrawn = TRUE;
			goto iconend;
		}


iconend:

		// draw caption
		int border = BORDER_WIDTH * m_iScaleFactor / 2;
		RECT rcCaption;
		SetRect(&rcCaption, ((bIconDrawn) ? sx : border * m_iScaleFactor), 0, rc.right, sy);
		dc.SetBkMode(TRANSPARENT);
		dc.SetTextColor(m_clCaptionText);
		CFont oldFont = dc.SelectFont(m_fCaption);

		UINT uFormat = DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS;
		if (m_bCenterCaption)
		{
			uFormat |= DT_CENTER;
			rcCaption.left -= (bIconDrawn) ? sx : 0;
		}

		dc.DrawText(m_szCaption, -1, &rcCaption, uFormat);
		dc.SelectFont(oldFont);

		// draw text
//		dc.SetBkMode(TRANSPARENT);
		dc.SetBkColor( RGB(255,216,0) );
		dc.SetTextColor(m_clText);
		oldFont = dc.SelectFont(m_fText);
		dc.DrawText(m_szText, -1, &m_rcText, DT_LEFT | DT_WORDBREAK | DT_END_ELLIPSIS);
		dc.SelectFont(oldFont);

		// draw button line (dotted line 1px)
		CPen pen2; pen2.CreatePen(PS_DASH, 1, m_clLine);
		CPen penOld2 = dc.SelectPen(pen2);
		dc.MoveTo(rc.left, rc.bottom - m_arrDynamicImages[0].GetHeight() - BOTTOM_BORDER_HEIGHT * m_iScaleFactor - 2);
		dc.LineTo(rc.right, rc.bottom - m_arrDynamicImages[0].GetHeight() - BOTTOM_BORDER_HEIGHT * m_iScaleFactor - 2);
		dc.SelectPen(penOld2);	

	}


	BEGIN_MSG_MAP(CMsgBoxWindow)
		MESSAGE_HANDLER(WM_CREATE, OnCreate)
		MESSAGE_HANDLER(WM_SIZE, OnSize)
		MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBackground)
		MESSAGE_HANDLER(WM_PAINT, OnPaint)
		MESSAGE_HANDLER(WM_COMMAND, OnCommand)
	END_MSG_MAP()

	LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		//ModifyShape();
		return 0;
	}

	LRESULT OnSize(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled)
	{
		if(wParam != SIZE_MINIMIZED)
		{
			RECT rc; GetClientRect(&rc);
		}

		bHandled = FALSE;
		return 0;
	}

	LRESULT OnEraseBackground(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		return 1;
	}

	LRESULT OnPaint(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		if(wParam != NULL)
		{
			DoPaint((HDC)wParam);
		}
		else
		{
			//CPaintDC dc(m_hWnd);
			CBufferedPaintDC dc(m_hWnd, 0);
			DoPaint(dc.m_hDC);
		}
		return 0;
	}

	LRESULT OnCommand(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		int wID = LOWORD(wParam);
		switch (wID)
		{
		case IDC_BTN_YES:
			SetMsgBoxResult(IDYES);
			break;
		case IDC_BTN_NO:
			SetMsgBoxResult(IDNO);
			break;
		case IDC_BTN_OK:
			SetMsgBoxResult(IDOK);
			break;
		case IDC_BTN_CANCEL:
			SetMsgBoxResult(IDCANCEL);
			break;
		case IDC_BTN_ABORT:
			SetMsgBoxResult(IDABORT);
			break;
		case IDC_BTN_IGNORE:
			SetMsgBoxResult(IDIGNORE);
			break;
		case IDC_BTN_RETRY:
			SetMsgBoxResult(IDRETRY);
			break;
		}
		GetParent().SendMessage(UM_MINIMIZE, 0, 0);
		return 0;
	}

public:
	CxImage m_icnStop;
	CxImage m_icnWarning;
	CxImage m_icnQuestion;
	CxImage m_icnInfo;
	CxImage m_imgHeader;

	CFontHandle m_fText;
	CFontHandle m_fCaption;
	CFontHandle m_fBtn;

	int m_xCaption;
	int m_yCaption;
	int m_xText;
	int m_yText;
	COLORREF m_clCaptionText;
	COLORREF m_clText;
	COLORREF m_clBtnText;
	COLORREF m_clBtnSelText;
	COLORREF m_clBkg;
	COLORREF m_clLine;

	BOOL m_bDisabledTransp;
	COLORREF m_clNoTranspBackground;
	DWORD m_iTransp;
	BOOL m_bCenterCaption;

	CxImage m_arrDynamicImages[9];

private:
	HWND m_hOwnrWnd;
	UINT m_uType;
	WCHAR m_szText[500];
	WCHAR m_szCaption[500];

	int m_iScaleFactor;



	RECT m_rcText;

	int CalculateTextHeight()
	{
		/*
		RECT rcText;
		SetRect(&rcText, 0, 
			             sy, 
						 rc.right, 
						 rc.bottom - (m_arrImages[0].GetHeight() + BOTTOM_BORDER_HEIGHT * m_iScaleFactor));
		*/
		RECT rcParent; GetParent().GetClientRect(&rcParent);
		int iHeight = 0;
		int iWidth = rcParent.right - rcParent.left - 2 * BORDER_WIDTH * m_iScaleFactor - 2 * LEFT_BORDER_WIDTH * m_iScaleFactor;


//		RECT rc; GetClientRect(&rc);

		SetRect(&m_rcText, 0, 
			               0, 
					       iWidth, 
						   0);

		CDC dc = ::GetDC(m_hWnd);
		CFont oldFont = dc.SelectFont(m_fText);
		dc.DrawText(m_szText, -1, &m_rcText, DT_LEFT | DT_WORDBREAK | DT_END_ELLIPSIS | DT_CALCRECT);
		dc.SelectFont(oldFont);

		iHeight = m_rcText.bottom;

		OffsetRect(&m_rcText, LEFT_BORDER_WIDTH * m_iScaleFactor, m_imgHeader.GetHeight());

		return max( (int)((float)iHeight * 1.5f), MIN_HEIGHT * m_iScaleFactor );
	}

public:
	void ModifyShape()
	{	
		int nUsedRects = 3 * m_iScaleFactor;

		RECT rcParent; GetParent().GetClientRect(&rcParent);
		int iWidth = rcParent.right - rcParent.left - 2 * BORDER_WIDTH * m_iScaleFactor;
		int iHeight = CalculateTextHeight() + m_imgHeader.GetHeight() + m_arrDynamicImages[0].GetHeight() + BOTTOM_BORDER_HEIGHT * m_iScaleFactor;
		//iHeight = max( iHeight, 160 * m_iScaleFactor);

		iHeight = min(iHeight, rcParent.bottom - rcParent.top - 2 * m_iScaleFactor);
		
		// upper region
		RGNDATA *pRgnData;
		RECT *pRect;		
		DWORD dwTemp = sizeof(RGNDATAHEADER) + nUsedRects * sizeof(RECT);
		pRgnData = (RGNDATA*)malloc(dwTemp);	
		pRgnData->rdh.dwSize = sizeof(RGNDATAHEADER);
		pRgnData->rdh.iType = RDH_RECTANGLES;
		pRgnData->rdh.nCount = nUsedRects;
		pRgnData->rdh.nRgnSize = 0;
		pRgnData->rdh.rcBound.left = pRgnData->rdh.rcBound.top=0;
		pRgnData->rdh.rcBound.right = iWidth;
		pRgnData->rdh.rcBound.bottom = nUsedRects;		

		if (nUsedRects == 3)
		{
			// 1st
			pRect = &(((RECT *)&pRgnData->Buffer)[0]);
			pRect->top = 0;
			pRect->bottom = 1;
			pRect->left = 2;
			pRect->right = iWidth - 2;

			// 2nd
			pRect = &(((RECT *)&pRgnData->Buffer)[1]);
			pRect->top = 1;
			pRect->bottom = 2;
			pRect->left = 1;
			pRect->right = iWidth - 1;

			// 3rd
			pRect = &(((RECT *)&pRgnData->Buffer)[2]);
			pRect->top = 2;
			pRect->bottom = 3;
			pRect->left = 0;
			pRect->right = iWidth;
		}
		else if (nUsedRects == 6)
		{
			// 1st
			pRect = &(((RECT *)&pRgnData->Buffer)[0]);
			pRect->top = 0;
			pRect->bottom = 1;
			pRect->left = 5;
			pRect->right = iWidth - 5;

			// 2nd
			pRect = &(((RECT *)&pRgnData->Buffer)[1]);
			pRect->top = 1;
			pRect->bottom = 2;
			pRect->left = 3;
			pRect->right = iWidth - 3;

			// 3rd
			pRect = &(((RECT *)&pRgnData->Buffer)[2]);
			pRect->top = 2;
			pRect->bottom = 3;
			pRect->left = 2;
			pRect->right = iWidth - 2;

			// 4th
			pRect = &(((RECT *)&pRgnData->Buffer)[3]);
			pRect->top = 3;
			pRect->bottom = 4;
			pRect->left = 1;
			pRect->right = iWidth - 1;

			// 5th
			pRect = &(((RECT *)&pRgnData->Buffer)[4]);
			pRect->top = 4;
			pRect->bottom = 5;
			pRect->left = 1;
			pRect->right = iWidth - 1;

			// 6th
			pRect = &(((RECT *)&pRgnData->Buffer)[5]);
			pRect->top = 5;
			pRect->bottom = 6;
			pRect->left = 0;
			pRect->right = iWidth;

		}

		HRGN hrgnTop = ExtCreateRegion(NULL, dwTemp, pRgnData);
		free(pRgnData);
		
		// lower region
		dwTemp = sizeof(RGNDATAHEADER) + nUsedRects * sizeof(RECT);
		pRgnData = (RGNDATA*)malloc(dwTemp);	
		pRgnData->rdh.dwSize = sizeof(RGNDATAHEADER);
		pRgnData->rdh.iType = RDH_RECTANGLES;
		pRgnData->rdh.nCount = nUsedRects;
		pRgnData->rdh.nRgnSize = 0;
		pRgnData->rdh.rcBound.left = pRgnData->rdh.rcBound.top=0;
		pRgnData->rdh.rcBound.right = iWidth;
		pRgnData->rdh.rcBound.bottom = nUsedRects;		

		if (nUsedRects == 3)
		{
			// 1st
			pRect = &(((RECT *)&pRgnData->Buffer)[2]);
			pRect->top = 2;
			pRect->bottom = 3;
			pRect->left = 2;
			pRect->right = iWidth - 2;

			// 2nd
			pRect = &(((RECT *)&pRgnData->Buffer)[1]);
			pRect->top = 1;
			pRect->bottom = 2;
			pRect->left = 1;
			pRect->right = iWidth - 1;

			// 3rd
			pRect = &(((RECT *)&pRgnData->Buffer)[0]);
			pRect->top = 0;
			pRect->bottom = 1;
			pRect->left = 0;
			pRect->right = iWidth;
		}
		else if (nUsedRects == 6)
		{
			// 1st
			pRect = &(((RECT *)&pRgnData->Buffer)[5]);
			pRect->top = 5;
			pRect->bottom = 6;
			pRect->left = 5;
			pRect->right = iWidth - 5;

			// 2nd
			pRect = &(((RECT *)&pRgnData->Buffer)[4]);
			pRect->top = 4;
			pRect->bottom = 5;
			pRect->left = 3;
			pRect->right = iWidth - 3;

			// 3rd
			pRect = &(((RECT *)&pRgnData->Buffer)[3]);
			pRect->top = 3;
			pRect->bottom = 4;
			pRect->left = 2;
			pRect->right = iWidth - 2;

			// 4th
			pRect = &(((RECT *)&pRgnData->Buffer)[2]);
			pRect->top = 2;
			pRect->bottom = 3;
			pRect->left = 1;
			pRect->right = iWidth - 1;

			// 5th
			pRect = &(((RECT *)&pRgnData->Buffer)[1]);
			pRect->top = 1;
			pRect->bottom = 2;
			pRect->left = 1;
			pRect->right = iWidth - 1;

			// 6th
			pRect = &(((RECT *)&pRgnData->Buffer)[0]);
			pRect->top = 0;
			pRect->bottom = 1;
			pRect->left = 0;
			pRect->right = iWidth;

		}

		HRGN hrgnBottom = ExtCreateRegion(NULL, dwTemp, pRgnData);
		::OffsetRgn(hrgnBottom, 0, iHeight - nUsedRects);
		free(pRgnData);

		
		HRGN hrgnMiddle = ::CreateRectRgn(0, 0, iWidth, iHeight - 2 * nUsedRects);
		::OffsetRgn(hrgnMiddle, 0, nUsedRects);

		CombineRgn(hrgnMiddle, hrgnTop, hrgnMiddle, RGN_OR);
		CombineRgn(hrgnMiddle, hrgnBottom, hrgnMiddle, RGN_OR);

		SetWindowRgn(hrgnMiddle, FALSE);

		ResizeClient(iWidth, iHeight, FALSE);
		CenterWindow();
	}

	void ModifyButtons()
	{
		RECT rc; GetClientRect(&rc);
		int btnHeight = m_arrDynamicImages[0].GetHeight();
	
		if (m_btn1.IsWindow())
			m_btn1.DestroyWindow();
		if (m_btn2.IsWindow())
			m_btn2.DestroyWindow();
		if (m_btn3.IsWindow())
			m_btn3.DestroyWindow();

		int type = m_uType & 0x000F;

		if (type == MB_OKCANCEL)
		{
			RECT rcBtn; 
			SetRect(&rcBtn, 0, rc.bottom - btnHeight - BOTTOM_BORDER_HEIGHT * m_iScaleFactor, rc.right / 2, rc.bottom);

			RECT rcBtn1; CopyRect(&rcBtn1, &rcBtn);
			InflateRect(&rcBtn1, -5, 0);

			m_btn1.Create(m_hWnd, FNGRBTN_TYPE_DYNAMIC, TRUE, m_clBkg, m_clBtnText, m_clBtnSelText, LoadResourceString(IDS_OK), m_fBtn, IDC_BTN_OK);
			m_btn1.MoveWindow(&rcBtn1);

			RECT rcBtn2; CopyRect(&rcBtn2, &rcBtn);
			OffsetRect(&rcBtn2, rc.right/2, 0);
			InflateRect(&rcBtn2, -4, 0);

			m_btn2.Create(m_hWnd, FNGRBTN_TYPE_DYNAMIC, TRUE, m_clBkg, m_clBtnText, m_clBtnSelText, LoadResourceString(IDS_CANCEL), m_fBtn, IDC_BTN_CANCEL);
			m_btn2.MoveWindow(&rcBtn2);		
		}

		if (type == MB_YESNO)
		{
			RECT rcBtn; 
			SetRect(&rcBtn, 0, rc.bottom - btnHeight - BOTTOM_BORDER_HEIGHT * m_iScaleFactor, rc.right / 2, rc.bottom);

			RECT rcBtn1; CopyRect(&rcBtn1, &rcBtn);
			InflateRect(&rcBtn1, -5, 0);

			m_btn1.Create(m_hWnd, FNGRBTN_TYPE_DYNAMIC, TRUE, m_clBkg, m_clBtnText, m_clBtnSelText, LoadResourceString(IDS_YES), m_fBtn, IDC_BTN_YES);
			m_btn1.MoveWindow(&rcBtn1);

			RECT rcBtn2; CopyRect(&rcBtn2, &rcBtn);
			OffsetRect(&rcBtn2, rc.right/2, 0);
			InflateRect(&rcBtn2, -4, 0);

			m_btn2.Create(m_hWnd, FNGRBTN_TYPE_DYNAMIC, TRUE, m_clBkg, m_clBtnText, m_clBtnSelText, LoadResourceString(IDS_NO), m_fBtn, IDC_BTN_NO);
			m_btn2.MoveWindow(&rcBtn2);
		}

		if (type == MB_YESNOCANCEL)
		{
			RECT rcBtn; 
			SetRect(&rcBtn, 0, rc.bottom - btnHeight - BOTTOM_BORDER_HEIGHT * m_iScaleFactor, rc.right / 3, rc.bottom);

			RECT rcBtn1; CopyRect(&rcBtn1, &rcBtn);
			InflateRect(&rcBtn1, -5, 0);

			m_btn1.Create(m_hWnd, FNGRBTN_TYPE_DYNAMIC, TRUE, m_clBkg, m_clBtnText, m_clBtnSelText, LoadResourceString(IDS_YES), m_fBtn, IDC_BTN_YES);
			m_btn1.MoveWindow(&rcBtn1);

			RECT rcBtn2; CopyRect(&rcBtn2, &rcBtn);
			OffsetRect(&rcBtn2, rc.right / 3, 0);
			InflateRect(&rcBtn2, -4, 0);

			m_btn2.Create(m_hWnd, FNGRBTN_TYPE_DYNAMIC, TRUE, m_clBkg, m_clBtnText, m_clBtnSelText, LoadResourceString(IDS_NO), m_fBtn, IDC_BTN_NO);
			m_btn2.MoveWindow(&rcBtn2);

			RECT rcBtn3; CopyRect(&rcBtn3, &rcBtn);
			OffsetRect(&rcBtn3, 2 * rc.right / 3, 0);
			InflateRect(&rcBtn3, -4, 0);

			m_btn3.Create(m_hWnd, FNGRBTN_TYPE_DYNAMIC, TRUE, m_clBkg, m_clBtnText, m_clBtnSelText, LoadResourceString(IDS_CANCEL), m_fBtn, IDC_BTN_CANCEL);
			m_btn3.MoveWindow(&rcBtn3);
		}

		if (type == MB_OK)
		{
			RECT rcBtn; 
			SetRect(&rcBtn, 0, rc.bottom - btnHeight - BOTTOM_BORDER_HEIGHT * m_iScaleFactor, rc.right, rc.bottom);
			InflateRect(&rcBtn, -5, 0);

			m_btn1.Create(m_hWnd, FNGRBTN_TYPE_DYNAMIC, TRUE, m_clBkg, m_clBtnText, m_clBtnSelText, LoadResourceString(IDS_OK), m_fBtn, IDC_BTN_OK);
			m_btn1.MoveWindow(&rcBtn);
		}


		if (type == MB_RETRYCANCEL)
		{
			RECT rcBtn; 
			SetRect(&rcBtn, 0, rc.bottom - btnHeight - BOTTOM_BORDER_HEIGHT * m_iScaleFactor, rc.right / 2, rc.bottom);

			RECT rcBtn1; CopyRect(&rcBtn1, &rcBtn);
			InflateRect(&rcBtn1, -5, 0);

			m_btn1.Create(m_hWnd, FNGRBTN_TYPE_DYNAMIC, TRUE, m_clBkg, m_clBtnText, m_clBtnSelText, LoadResourceString(IDS_RETRY), m_fBtn, IDC_BTN_RETRY);
			m_btn1.MoveWindow(&rcBtn1);

			RECT rcBtn2; CopyRect(&rcBtn2, &rcBtn);
			OffsetRect(&rcBtn2, rc.right/2, 0);
			InflateRect(&rcBtn2, -4, 0);

			m_btn2.Create(m_hWnd, FNGRBTN_TYPE_DYNAMIC, TRUE, m_clBkg, m_clBtnText, m_clBtnSelText, LoadResourceString(IDS_CANCEL), m_fBtn, IDC_BTN_CANCEL);
			m_btn2.MoveWindow(&rcBtn2);
		}

		if (type == MB_ABORTRETRYIGNORE)
		{
			RECT rcBtn; 
			SetRect(&rcBtn, 0, rc.bottom - btnHeight - BOTTOM_BORDER_HEIGHT * m_iScaleFactor, rc.right / 3, rc.bottom);

			RECT rcBtn1; CopyRect(&rcBtn1, &rcBtn);
			InflateRect(&rcBtn1, -5, 0);

			m_btn1.Create(m_hWnd, FNGRBTN_TYPE_DYNAMIC, TRUE, m_clBkg, m_clBtnText, m_clBtnSelText, LoadResourceString(IDS_ABORT), m_fBtn, IDC_BTN_ABORT);
			m_btn1.MoveWindow(&rcBtn1);

			RECT rcBtn2; CopyRect(&rcBtn2, &rcBtn);
			OffsetRect(&rcBtn2, rc.right / 3, 0);
			InflateRect(&rcBtn2, -4, 0);

			m_btn2.Create(m_hWnd, FNGRBTN_TYPE_DYNAMIC, TRUE, m_clBkg, m_clBtnText, m_clBtnSelText, LoadResourceString(IDS_RETRY), m_fBtn, IDC_BTN_RETRY);
			m_btn2.MoveWindow(&rcBtn2);

			RECT rcBtn3; CopyRect(&rcBtn3, &rcBtn);
			OffsetRect(&rcBtn3, 2 * rc.right / 3, 0);
			InflateRect(&rcBtn3, -4, 0);

			m_btn3.Create(m_hWnd, FNGRBTN_TYPE_DYNAMIC, TRUE, m_clBkg, m_clBtnText, m_clBtnSelText, LoadResourceString(IDS_IGNORE), m_fBtn, IDC_BTN_IGNORE);
			m_btn3.MoveWindow(&rcBtn3);
		}

		//return TRUE;
	}

};








<file_sep>/7-Zip/CPP/7zip/Archive/Zip/ZipIn.cpp
// Archive/ZipIn.cpp

#include "StdAfx.h"

#include "../../../../C/CpuArch.h"

#include "Common/DynamicBuffer.h"

#include "../../Common/LimitedStreams.h"
#include "../../Common/StreamUtils.h"

#include "ZipIn.h"

#define Get16(p) GetUi16(p)
#define Get32(p) GetUi32(p)
#define Get64(p) GetUi64(p)

namespace NArchive {
namespace NZip {
 
HRESULT CInArchive::Open(IInStream *stream, const UInt64 *searchHeaderSizeLimit)
{
  _inBufMode = false;
  Close();
  RINOK(stream->Seek(0, STREAM_SEEK_CUR, &m_StreamStartPosition));
  m_Position = m_StreamStartPosition;
  RINOK(FindAndReadMarker(stream, searchHeaderSizeLimit));
  RINOK(stream->Seek(m_Position, STREAM_SEEK_SET, NULL));
  m_Stream = stream;
  return S_OK;
}

void CInArchive::Close()
{
  _inBuffer.ReleaseStream();
  m_Stream.Release();
}

HRESULT CInArchive::Seek(UInt64 offset)
{
  return m_Stream->Seek(offset, STREAM_SEEK_SET, NULL);
}

//////////////////////////////////////
// Markers

static inline bool TestMarkerCandidate(const Byte *p, UInt32 &value)
{
  value = Get32(p);
  return
    (value == NSignature::kLocalFileHeader) ||
    (value == NSignature::kEndOfCentralDir);
}

static const UInt32 kNumMarkerAddtionalBytes = 2;
static inline bool TestMarkerCandidate2(const Byte *p, UInt32 &value)
{
  value = Get32(p);
  if (value == NSignature::kEndOfCentralDir)
    return (Get16(p + 4) == 0);
  return (value == NSignature::kLocalFileHeader && p[4] < 128);
}

HRESULT CInArchive::FindAndReadMarker(IInStream *stream, const UInt64 *searchHeaderSizeLimit)
{
  m_ArchiveInfo.Clear();
  m_Position = m_StreamStartPosition;

  Byte marker[NSignature::kMarkerSize];
  RINOK(ReadStream_FALSE(stream, marker, NSignature::kMarkerSize));
  m_Position += NSignature::kMarkerSize;
  if (TestMarkerCandidate(marker, m_Signature))
    return S_OK;

  CByteDynamicBuffer dynamicBuffer;
  const UInt32 kSearchMarkerBufferSize = 0x10000;
  dynamicBuffer.EnsureCapacity(kSearchMarkerBufferSize);
  Byte *buffer = dynamicBuffer;
  UInt32 numBytesPrev = NSignature::kMarkerSize - 1;
  memcpy(buffer, marker + 1, numBytesPrev);
  UInt64 curTestPos = m_StreamStartPosition + 1;
  for (;;)
  {
    if (searchHeaderSizeLimit != NULL)
      if (curTestPos - m_StreamStartPosition > *searchHeaderSizeLimit)
        break;
    size_t numReadBytes = kSearchMarkerBufferSize - numBytesPrev;
    RINOK(ReadStream(stream, buffer + numBytesPrev, &numReadBytes));
    m_Position += numReadBytes;
    UInt32 numBytesInBuffer = numBytesPrev + (UInt32)numReadBytes;
    const UInt32 kMarker2Size = NSignature::kMarkerSize + kNumMarkerAddtionalBytes;
    if (numBytesInBuffer < kMarker2Size)
      break;
    UInt32 numTests = numBytesInBuffer - kMarker2Size + 1;
    for (UInt32 pos = 0; pos < numTests; pos++)
    {
      if (buffer[pos] != 0x50)
        continue;
      if (TestMarkerCandidate2(buffer + pos, m_Signature))
      {
        curTestPos += pos;
        m_ArchiveInfo.StartPosition = curTestPos;
        m_Position = curTestPos + NSignature::kMarkerSize;
        return S_OK;
      }
    }
    curTestPos += numTests;
    numBytesPrev = numBytesInBuffer - numTests;
    memmove(buffer, buffer + numTests, numBytesPrev);
  }
  return S_FALSE;
}

HRESULT CInArchive::ReadBytes(void *data, UInt32 size, UInt32 *processedSize)
{
  size_t realProcessedSize = size;
  HRESULT result = S_OK;
  if (_inBufMode)
  {
    try { realProcessedSize = _inBuffer.ReadBytes((Byte *)data, size); }
    catch (const CInBufferException &e) { return e.ErrorCode; }
  }
  else
    result = ReadStream(m_Stream, data, &realProcessedSize);
  if (processedSize != NULL)
    *processedSize = (UInt32)realProcessedSize;
  m_Position += realProcessedSize;
  return result;
}

void CInArchive::Skip(UInt64 num)
{
  for (UInt64 i = 0; i < num; i++)
    ReadByte();
}

void CInArchive::IncreaseRealPosition(UInt64 addValue)
{
  if (m_Stream->Seek(addValue, STREAM_SEEK_CUR, &m_Position) != S_OK)
    throw CInArchiveException(CInArchiveException::kSeekStreamError);
}

bool CInArchive::ReadBytesAndTestSize(void *data, UInt32 size)
{
  UInt32 realProcessedSize;
  if (ReadBytes(data, size, &realProcessedSize) != S_OK)
    throw CInArchiveException(CInArchiveException::kReadStreamError);
  return (realProcessedSize == size);
}

void CInArchive::SafeReadBytes(void *data, UInt32 size)
{
  if (!ReadBytesAndTestSize(data, size))
    throw CInArchiveException(CInArchiveException::kUnexpectedEndOfArchive);
}

void CInArchive::ReadBuffer(CByteBuffer &buffer, UInt32 size)
{
  buffer.SetCapacity(size);
  if (size > 0)
    SafeReadBytes(buffer, size);
}

Byte CInArchive::ReadByte()
{
  Byte b;
  SafeReadBytes(&b, 1);
  return b;
}

UInt16 CInArchive::ReadUInt16()
{
  Byte buf[2];
  SafeReadBytes(buf, 2);
  return Get16(buf);
}

UInt32 CInArchive::ReadUInt32()
{
  Byte buf[4];
  SafeReadBytes(buf, 4);
  return Get32(buf);
}

UInt64 CInArchive::ReadUInt64()
{
  Byte buf[8];
  SafeReadBytes(buf, 8);
  return Get64(buf);
}

bool CInArchive::ReadUInt32(UInt32 &value)
{
  Byte buf[4];
  if (!ReadBytesAndTestSize(buf, 4))
    return false;
  value = Get32(buf);
  return true;
}

void CInArchive::ReadFileName(UInt32 nameSize, AString &dest)
{
  if (nameSize == 0)
    dest.Empty();
  char *p = dest.GetBuffer((int)nameSize);
  SafeReadBytes(p, nameSize);
  p[nameSize] = 0;
  dest.ReleaseBuffer();
}

void CInArchive::GetArchiveInfo(CInArchiveInfo &archiveInfo) const
{
  archiveInfo = m_ArchiveInfo;
}

void CInArchive::ReadExtra(UInt32 extraSize, CExtraBlock &extraBlock,
    UInt64 &unpackSize, UInt64 &packSize, UInt64 &localHeaderOffset, UInt32 &diskStartNumber)
{
  extraBlock.Clear();
  UInt32 remain = extraSize;
  while(remain >= 4)
  {
    CExtraSubBlock subBlock;
    subBlock.ID = ReadUInt16();
    UInt32 dataSize = ReadUInt16();
    remain -= 4;
    if (dataSize > remain) // it's bug
      dataSize = remain;
    if (subBlock.ID == NFileHeader::NExtraID::kZip64)
    {
      if (unpackSize == 0xFFFFFFFF)
      {
        if (dataSize < 8)
          break;
        unpackSize = ReadUInt64();
        remain -= 8;
        dataSize -= 8;
      }
      if (packSize == 0xFFFFFFFF)
      {
        if (dataSize < 8)
          break;
        packSize = ReadUInt64();
        remain -= 8;
        dataSize -= 8;
      }
      if (localHeaderOffset == 0xFFFFFFFF)
      {
        if (dataSize < 8)
          break;
        localHeaderOffset = ReadUInt64();
        remain -= 8;
        dataSize -= 8;
      }
      if (diskStartNumber == 0xFFFF)
      {
        if (dataSize < 4)
          break;
        diskStartNumber = ReadUInt32();
        remain -= 4;
        dataSize -= 4;
      }
      for (UInt32 i = 0; i < dataSize; i++)
        ReadByte();
    }
    else
    {
      ReadBuffer(subBlock.Data, dataSize);
      extraBlock.SubBlocks.Add(subBlock);
    }
    remain -= dataSize;
  }
  Skip(remain);
}

HRESULT CInArchive::ReadLocalItem(CItemEx &item)
{
  const int kBufSize = 26;
  Byte p[kBufSize];
  SafeReadBytes(p, kBufSize);

  item.ExtractVersion.Version = p[0];
  item.ExtractVersion.HostOS = p[1];
  item.Flags = Get16(p + 2);
  item.CompressionMethod = Get16(p + 4);
  item.Time = Get32(p + 6);
  item.FileCRC = Get32(p + 10);
  item.PackSize = Get32(p + 14);
  item.UnPackSize = Get32(p + 18);
  UInt32 fileNameSize = Get16(p + 22);
  item.LocalExtraSize = Get16(p + 24);
  ReadFileName(fileNameSize, item.Name);
  item.FileHeaderWithNameSize = 4 + NFileHeader::kLocalBlockSize + fileNameSize;
  if (item.LocalExtraSize > 0)
  {
    UInt64 localHeaderOffset = 0;
    UInt32 diskStartNumber = 0;
    ReadExtra(item.LocalExtraSize, item.LocalExtra, item.UnPackSize, item.PackSize,
      localHeaderOffset, diskStartNumber);
  }
  /*
  if (item.IsDir())
    item.UnPackSize = 0;       // check It
  */
  return S_OK;
}

static bool FlagsAreSame(CItem &i1, CItem &i2)
{
  if (i1.CompressionMethod != i2.CompressionMethod)
    return false;
  // i1.Time

  if (i1.Flags == i2.Flags)
    return true;
  UInt32 mask = 0xFFFF;
  switch(i1.CompressionMethod)
  {
    case NFileHeader::NCompressionMethod::kDeflated:
      mask = 0x7FF9;
      break;
    default:
      if (i1.CompressionMethod <= NFileHeader::NCompressionMethod::kImploded)
        mask = 0x7FFF;
  }
  return ((i1.Flags & mask) == (i2.Flags & mask));
}

HRESULT CInArchive::ReadLocalItemAfterCdItem(CItemEx &item)
{
  if (item.FromLocal)
    return S_OK;
  try
  {
    RINOK(Seek(m_ArchiveInfo.Base + item.LocalHeaderPosition));
    CItemEx localItem;
    if (ReadUInt32() != NSignature::kLocalFileHeader)
      return S_FALSE;
    RINOK(ReadLocalItem(localItem));
    if (!FlagsAreSame(item, localItem))
      return S_FALSE;

    if ((!localItem.HasDescriptor() &&
          (
            item.FileCRC != localItem.FileCRC ||
            item.PackSize != localItem.PackSize ||
            item.UnPackSize != localItem.UnPackSize
          )
        ) ||
        item.Name.Length() != localItem.Name.Length()
        )
      return S_FALSE;
    item.FileHeaderWithNameSize = localItem.FileHeaderWithNameSize;
    item.LocalExtraSize = localItem.LocalExtraSize;
    item.LocalExtra = localItem.LocalExtra;
    item.FromLocal = true;
  }
  catch(...) { return S_FALSE; }
  return S_OK;
}

HRESULT CInArchive::ReadLocalItemDescriptor(CItemEx &item)
{
  if (item.HasDescriptor())
  {
    const int kBufferSize = (1 << 12);
    Byte buffer[kBufferSize];
    
    UInt32 numBytesInBuffer = 0;
    UInt32 packedSize = 0;
    
    bool descriptorWasFound = false;
    for (;;)
    {
      UInt32 processedSize;
      RINOK(ReadBytes(buffer + numBytesInBuffer, kBufferSize - numBytesInBuffer, &processedSize));
      numBytesInBuffer += processedSize;
      if (numBytesInBuffer < NFileHeader::kDataDescriptorSize)
        return S_FALSE;
      UInt32 i;
      for (i = 0; i <= numBytesInBuffer - NFileHeader::kDataDescriptorSize; i++)
      {
        // descriptorSignature field is Info-ZIP's extension
        // to Zip specification.
        UInt32 descriptorSignature = Get32(buffer + i);
        
        // !!!! It must be fixed for Zip64 archives
        UInt32 descriptorPackSize = Get32(buffer + i + 8);
        if (descriptorSignature== NSignature::kDataDescriptor && descriptorPackSize == packedSize + i)
        {
          descriptorWasFound = true;
          item.FileCRC = Get32(buffer + i + 4);
          item.PackSize = descriptorPackSize;
          item.UnPackSize = Get32(buffer + i + 12);
          IncreaseRealPosition(Int64(Int32(0 - (numBytesInBuffer - i - NFileHeader::kDataDescriptorSize))));
          break;
        }
      }
      if (descriptorWasFound)
        break;
      packedSize += i;
      int j;
      for (j = 0; i < numBytesInBuffer; i++, j++)
        buffer[j] = buffer[i];
      numBytesInBuffer = j;
    }
  }
  else
    IncreaseRealPosition(item.PackSize);
  return S_OK;
}

HRESULT CInArchive::ReadLocalItemAfterCdItemFull(CItemEx &item)
{
  if (item.FromLocal)
    return S_OK;
  try
  {
    RINOK(ReadLocalItemAfterCdItem(item));
    if (item.HasDescriptor())
    {
      RINOK(Seek(m_ArchiveInfo.Base + item.GetDataPosition() + item.PackSize));
      if (ReadUInt32() != NSignature::kDataDescriptor)
        return S_FALSE;
      UInt32 crc = ReadUInt32();
      UInt64 packSize, unpackSize;

      /*
      if (IsZip64)
      {
        packSize = ReadUInt64();
        unpackSize = ReadUInt64();
      }
      else
      */
      {
        packSize = ReadUInt32();
        unpackSize = ReadUInt32();
      }

      if (crc != item.FileCRC || item.PackSize != packSize || item.UnPackSize != unpackSize)
        return S_FALSE;
    }
  }
  catch(...) { return S_FALSE; }
  return S_OK;
}
  
HRESULT CInArchive::ReadCdItem(CItemEx &item)
{
  item.FromCentral = true;
  const int kBufSize = 42;
  Byte p[kBufSize];
  SafeReadBytes(p, kBufSize);
  item.MadeByVersion.Version = p[0];
  item.MadeByVersion.HostOS = p[1];
  item.ExtractVersion.Version = p[2];
  item.ExtractVersion.HostOS = p[3];
  item.Flags = Get16(p + 4);
  item.CompressionMethod = Get16(p + 6);
  item.Time = Get32(p + 8);
  item.FileCRC = Get32(p + 12);
  item.PackSize = Get32(p + 16);
  item.UnPackSize = Get32(p + 20);
  UInt16 headerNameSize = Get16(p + 24);
  UInt16 headerExtraSize = Get16(p + 26);
  UInt16 headerCommentSize = Get16(p + 28);
  UInt32 headerDiskNumberStart = Get16(p + 30);
  item.InternalAttributes = Get16(p + 32);
  item.ExternalAttributes = Get32(p + 34);
  item.LocalHeaderPosition = Get32(p + 38);
  ReadFileName(headerNameSize, item.Name);
  
  if (headerExtraSize > 0)
  {
    ReadExtra(headerExtraSize, item.CentralExtra, item.UnPackSize, item.PackSize,
        item.LocalHeaderPosition, headerDiskNumberStart);
  }

  if (headerDiskNumberStart != 0)
    throw CInArchiveException(CInArchiveException::kMultiVolumeArchiveAreNotSupported);
  
  // May be these strings must be deleted
  /*
  if (item.IsDir())
    item.UnPackSize = 0;
  */
  
  ReadBuffer(item.Comment, headerCommentSize);
  return S_OK;
}

HRESULT CInArchive::TryEcd64(UInt64 offset, CCdInfo &cdInfo)
{
  RINOK(Seek(offset));
  const UInt32 kEcd64Size = 56;
  Byte buf[kEcd64Size];
  if (!ReadBytesAndTestSize(buf, kEcd64Size))
    return S_FALSE;
  if (Get32(buf) != NSignature::kZip64EndOfCentralDir)
    return S_FALSE;
  // cdInfo.NumEntries = Get64(buf + 24);
  cdInfo.Size = Get64(buf + 40);
  cdInfo.Offset = Get64(buf + 48);
  return S_OK;
}

HRESULT CInArchive::FindCd(CCdInfo &cdInfo)
{
  UInt64 endPosition;
  RINOK(m_Stream->Seek(0, STREAM_SEEK_END, &endPosition));
  const UInt32 kBufSizeMax = (1 << 16) + kEcdSize + kZip64EcdLocatorSize;
  CByteBuffer byteBuffer;
  byteBuffer.SetCapacity(kBufSizeMax);
  Byte *buf = byteBuffer;
  UInt32 bufSize = (endPosition < kBufSizeMax) ? (UInt32)endPosition : kBufSizeMax;
  if (bufSize < kEcdSize)
    return S_FALSE;
  UInt64 startPosition = endPosition - bufSize;
  RINOK(m_Stream->Seek(startPosition, STREAM_SEEK_SET, &m_Position));
  if (m_Position != startPosition)
    return S_FALSE;
  if (!ReadBytesAndTestSize(buf, bufSize))
    return S_FALSE;
  for (int i = (int)(bufSize - kEcdSize); i >= 0; i--)
  {
    if (Get32(buf + i) == NSignature::kEndOfCentralDir)
    {
      if (i >= kZip64EcdLocatorSize)
      {
        const Byte *locator = buf + i - kZip64EcdLocatorSize;
        if (Get32(locator) == NSignature::kZip64EndOfCentralDirLocator)
        {
          UInt64 ecd64Offset = Get64(locator + 8);
          if (TryEcd64(ecd64Offset, cdInfo) == S_OK)
            return S_OK;
          if (TryEcd64(m_ArchiveInfo.StartPosition + ecd64Offset, cdInfo) == S_OK)
          {
            m_ArchiveInfo.Base = m_ArchiveInfo.StartPosition;
            return S_OK;
          }
        }
      }
      if (Get32(buf + i + 4) == 0)
      {
        // cdInfo.NumEntries = GetUInt16(buf + i + 10);
        cdInfo.Size = Get32(buf + i + 12);
        cdInfo.Offset = Get32(buf + i + 16);
        UInt64 curPos = endPosition - bufSize + i;
        UInt64 cdEnd = cdInfo.Size + cdInfo.Offset;
        if (curPos > cdEnd)
          m_ArchiveInfo.Base = curPos - cdEnd;
        return S_OK;
      }
    }
  }
  return S_FALSE;
}

HRESULT CInArchive::TryReadCd(CObjectVector<CItemEx> &items, UInt64 cdOffset, UInt64 cdSize, CProgressVirt *progress)
{
  items.Clear();
  RINOK(m_Stream->Seek(cdOffset, STREAM_SEEK_SET, &m_Position));
  if (m_Position != cdOffset)
    return S_FALSE;

  if (!_inBuffer.Create(1 << 15))
    return E_OUTOFMEMORY;
  _inBuffer.SetStream(m_Stream);
  _inBuffer.Init();
  _inBufMode = true;

  while(m_Position - cdOffset < cdSize)
  {
    if (ReadUInt32() != NSignature::kCentralFileHeader)
      return S_FALSE;
    CItemEx cdItem;
    RINOK(ReadCdItem(cdItem));
    items.Add(cdItem);
    if (progress && items.Size() % 1000 == 0)
      RINOK(progress->SetCompleted(items.Size()));
  }
  return (m_Position - cdOffset == cdSize) ? S_OK : S_FALSE;
}

HRESULT CInArchive::ReadCd(CObjectVector<CItemEx> &items, UInt64 &cdOffset, UInt64 &cdSize, CProgressVirt *progress)
{
  m_ArchiveInfo.Base = 0;
  CCdInfo cdInfo;
  RINOK(FindCd(cdInfo));
  HRESULT res = S_FALSE;
  cdSize = cdInfo.Size;
  cdOffset = cdInfo.Offset;
  res = TryReadCd(items, m_ArchiveInfo.Base + cdOffset, cdSize, progress);
  if (res == S_FALSE && m_ArchiveInfo.Base == 0)
  {
    res = TryReadCd(items, cdInfo.Offset + m_ArchiveInfo.StartPosition, cdSize, progress);
    if (res == S_OK)
      m_ArchiveInfo.Base = m_ArchiveInfo.StartPosition;
  }
  if (!ReadUInt32(m_Signature))
    return S_FALSE;
  return res;
}

HRESULT CInArchive::ReadLocalsAndCd(CObjectVector<CItemEx> &items, CProgressVirt *progress, UInt64 &cdOffset, int &numCdItems)
{
  items.Clear();
  numCdItems = 0;
  while (m_Signature == NSignature::kLocalFileHeader)
  {
    // FSeek points to next byte after signature
    // NFileHeader::CLocalBlock localHeader;
    CItemEx item;
    item.LocalHeaderPosition = m_Position - m_StreamStartPosition - 4; // points to signature;
    RINOK(ReadLocalItem(item));
    item.FromLocal = true;
    ReadLocalItemDescriptor(item);
    items.Add(item);
    if (progress && items.Size() % 100 == 0)
      RINOK(progress->SetCompleted(items.Size()));
    if (!ReadUInt32(m_Signature))
      break;
  }
  cdOffset = m_Position - 4;
  int i;
  for (i = 0; i < items.Size(); i++, numCdItems++)
  {
    if (progress && i % 1000 == 0)
      RINOK(progress->SetCompleted(items.Size()));
    if (m_Signature == NSignature::kEndOfCentralDir)
      break;

    if (m_Signature != NSignature::kCentralFileHeader)
      return S_FALSE;

    CItemEx cdItem;
    RINOK(ReadCdItem(cdItem));

    if (i == 0)
    {
      int j;
      for (j = 0; j < items.Size(); j++)
      {
        CItemEx &item = items[j];
        if (item.Name == cdItem.Name)
        {
          m_ArchiveInfo.Base = item.LocalHeaderPosition - cdItem.LocalHeaderPosition;
          break;
        }
      }
      if (j == items.Size())
        return S_FALSE;
    }

    int index;
    int left = 0, right = items.Size();
    for (;;)
    {
      if (left >= right)
        return S_FALSE;
      index = (left + right) / 2;
      UInt64 position = items[index].LocalHeaderPosition - m_ArchiveInfo.Base;
      if (cdItem.LocalHeaderPosition == position)
        break;
      if (cdItem.LocalHeaderPosition < position)
        right = index;
      else
        left = index + 1;
    }
    CItemEx &item = items[index];
    // item.LocalHeaderPosition = cdItem.LocalHeaderPosition;
    item.MadeByVersion = cdItem.MadeByVersion;
    item.CentralExtra = cdItem.CentralExtra;

    if (
        // item.ExtractVersion != cdItem.ExtractVersion ||
        !FlagsAreSame(item, cdItem) ||
        item.FileCRC != cdItem.FileCRC)
      return S_FALSE;

    if (item.Name.Length() != cdItem.Name.Length() ||
        item.PackSize != cdItem.PackSize ||
        item.UnPackSize != cdItem.UnPackSize
      )
      return S_FALSE;
    item.Name = cdItem.Name;
    item.InternalAttributes = cdItem.InternalAttributes;
    item.ExternalAttributes = cdItem.ExternalAttributes;
    item.Comment = cdItem.Comment;
    item.FromCentral = cdItem.FromCentral;
    if (!ReadUInt32(m_Signature))
      return S_FALSE;
  }
  for (i = 0; i < items.Size(); i++)
    items[i].LocalHeaderPosition -= m_ArchiveInfo.Base;
  return S_OK;
}

struct CEcd
{
  UInt16 thisDiskNumber;
  UInt16 startCDDiskNumber;
  UInt16 numEntriesInCDOnThisDisk;
  UInt16 numEntriesInCD;
  UInt32 cdSize;
  UInt32 cdStartOffset;
  UInt16 commentSize;
  void Parse(const Byte *p);
};

void CEcd::Parse(const Byte *p)
{
  thisDiskNumber = Get16(p);
  startCDDiskNumber = Get16(p + 2);
  numEntriesInCDOnThisDisk = Get16(p + 4);
  numEntriesInCD = Get16(p + 6);
  cdSize = Get32(p + 8);
  cdStartOffset = Get32(p + 12);
  commentSize = Get16(p + 16);
}

struct CEcd64
{
  UInt16 versionMade;
  UInt16 versionNeedExtract;
  UInt32 thisDiskNumber;
  UInt32 startCDDiskNumber;
  UInt64 numEntriesInCDOnThisDisk;
  UInt64 numEntriesInCD;
  UInt64 cdSize;
  UInt64 cdStartOffset;
  void Parse(const Byte *p);
  CEcd64() { memset(this, 0, sizeof(*this)); }
};

void CEcd64::Parse(const Byte *p)
{
  versionMade = Get16(p);
  versionNeedExtract = Get16(p + 2);
  thisDiskNumber = Get32(p + 4);
  startCDDiskNumber = Get32(p + 8);
  numEntriesInCDOnThisDisk = Get64(p + 12);
  numEntriesInCD = Get64(p + 20);
  cdSize = Get64(p + 28);
  cdStartOffset = Get64(p + 36);
}

#define COPY_ECD_ITEM_16(n) if (!isZip64 || ecd. n != 0xFFFF)     ecd64. n = ecd. n;
#define COPY_ECD_ITEM_32(n) if (!isZip64 || ecd. n != 0xFFFFFFFF) ecd64. n = ecd. n;

HRESULT CInArchive::ReadHeaders(CObjectVector<CItemEx> &items, CProgressVirt *progress)
{
  // m_Signature must be kLocalFileHeaderSignature or
  // kEndOfCentralDirSignature
  // m_Position points to next byte after signature

  IsZip64 = false;
  items.Clear();

  UInt64 cdSize, cdStartOffset;
  HRESULT res;
  try
  {
    res = ReadCd(items, cdStartOffset, cdSize, progress);
  }
  catch(CInArchiveException &)
  {
    res = S_FALSE;
  }
  if (res != S_FALSE && res != S_OK)
    return res;

  /*
  if (res != S_OK)
    return res;
  res = S_FALSE;
  */

  int numCdItems = items.Size();
  if (res == S_FALSE)
  {
    _inBufMode = false;
    m_ArchiveInfo.Base = 0;
    RINOK(m_Stream->Seek(m_ArchiveInfo.StartPosition, STREAM_SEEK_SET, &m_Position));
    if (m_Position != m_ArchiveInfo.StartPosition)
      return S_FALSE;
    if (!ReadUInt32(m_Signature))
      return S_FALSE;
    RINOK(ReadLocalsAndCd(items, progress, cdStartOffset, numCdItems));
    cdSize = (m_Position - 4) - cdStartOffset;
    cdStartOffset -= m_ArchiveInfo.Base;
  }

  CEcd64 ecd64;
  bool isZip64 = false;
  UInt64 zip64EcdStartOffset = m_Position - 4 - m_ArchiveInfo.Base;
  if (m_Signature == NSignature::kZip64EndOfCentralDir)
  {
    IsZip64 = isZip64 = true;
    UInt64 recordSize = ReadUInt64();

    const int kBufSize = kZip64EcdSize;
    Byte buf[kBufSize];
    SafeReadBytes(buf, kBufSize);
    ecd64.Parse(buf);

    Skip(recordSize - kZip64EcdSize);
    if (!ReadUInt32(m_Signature))
      return S_FALSE;
    if (ecd64.thisDiskNumber != 0 || ecd64.startCDDiskNumber != 0)
      throw CInArchiveException(CInArchiveException::kMultiVolumeArchiveAreNotSupported);
    if (ecd64.numEntriesInCDOnThisDisk != numCdItems ||
        ecd64.numEntriesInCD != numCdItems ||
        ecd64.cdSize != cdSize ||
        (ecd64.cdStartOffset != cdStartOffset &&
        (!items.IsEmpty())))
      return S_FALSE;
  }
  if (m_Signature == NSignature::kZip64EndOfCentralDirLocator)
  {
    /* UInt32 startEndCDDiskNumber = */ ReadUInt32();
    UInt64 endCDStartOffset = ReadUInt64();
    /* UInt32 numberOfDisks = */ ReadUInt32();
    if (zip64EcdStartOffset != endCDStartOffset)
      return S_FALSE;
    if (!ReadUInt32(m_Signature))
      return S_FALSE;
  }
  if (m_Signature != NSignature::kEndOfCentralDir)
    return S_FALSE;

  const int kBufSize = kEcdSize - 4;
  Byte buf[kBufSize];
  SafeReadBytes(buf, kBufSize);
  CEcd ecd;
  ecd.Parse(buf);

  COPY_ECD_ITEM_16(thisDiskNumber);
  COPY_ECD_ITEM_16(startCDDiskNumber);
  COPY_ECD_ITEM_16(numEntriesInCDOnThisDisk);
  COPY_ECD_ITEM_16(numEntriesInCD);
  COPY_ECD_ITEM_32(cdSize);
  COPY_ECD_ITEM_32(cdStartOffset);

  ReadBuffer(m_ArchiveInfo.Comment, ecd.commentSize);

  if (ecd64.thisDiskNumber != 0 || ecd64.startCDDiskNumber != 0)
    throw CInArchiveException(CInArchiveException::kMultiVolumeArchiveAreNotSupported);
  if ((UInt16)ecd64.numEntriesInCDOnThisDisk != ((UInt16)numCdItems) ||
      (UInt16)ecd64.numEntriesInCD != ((UInt16)numCdItems) ||
      (UInt32)ecd64.cdSize != (UInt32)cdSize ||
      ((UInt32)(ecd64.cdStartOffset) != (UInt32)cdStartOffset &&
        (!items.IsEmpty())))
    return S_FALSE;
  
  _inBufMode = false;
  _inBuffer.Free();
  IsOkHeaders = (numCdItems == items.Size());
  return S_OK;
}

ISequentialInStream* CInArchive::CreateLimitedStream(UInt64 position, UInt64 size)
{
  CLimitedSequentialInStream *streamSpec = new CLimitedSequentialInStream;
  CMyComPtr<ISequentialInStream> stream(streamSpec);
  SeekInArchive(m_ArchiveInfo.Base + position);
  streamSpec->SetStream(m_Stream);
  streamSpec->Init(size);
  return stream.Detach();
}

IInStream* CInArchive::CreateStream()
{
  CMyComPtr<IInStream> stream = m_Stream;
  return stream.Detach();
}

bool CInArchive::SeekInArchive(UInt64 position)
{
  UInt64 newPosition;
  if (m_Stream->Seek(position, STREAM_SEEK_SET, &newPosition) != S_OK)
    return false;
  return (newPosition == position);
}

}}
<file_sep>/7-Zip/CPP/7zip/Compress/PpmdDecoder.cpp
// PpmdDecoder.cpp
// 2009-05-30 : <NAME> : Public domain

#include "StdAfx.h"

#include "Common/Defs.h"
#include "Windows/Defs.h"

#include "PpmdDecoder.h"

namespace NCompress {
namespace NPpmd {

const int kLenIdFinished = -1;
const int kLenIdNeedInit = -2;

STDMETHODIMP CDecoder::SetDecoderProperties2(const Byte *properties, UInt32 size)
{
  if (size < 5)
    return E_INVALIDARG;
  _order = properties[0];
  _usedMemorySize = 0;
  for (int i = 0; i < 4; i++)
    _usedMemorySize += ((UInt32)(properties[1 + i])) << (i * 8);

  if (_usedMemorySize > kMaxMemBlockSize)
    return E_NOTIMPL;

  if (!_rangeDecoder.Create(1 << 20))
    return E_OUTOFMEMORY;
  if (!_info.SubAllocator.StartSubAllocator(_usedMemorySize))
    return E_OUTOFMEMORY;

  return S_OK;
}

class CDecoderFlusher
{
  CDecoder *_coder;
public:
  bool NeedFlush;
  CDecoderFlusher(CDecoder *coder): _coder(coder), NeedFlush(true) {}
  ~CDecoderFlusher()
  {
    if (NeedFlush)
      _coder->Flush();
    _coder->ReleaseStreams();
  }
};

HRESULT CDecoder::CodeSpec(UInt32 size, Byte *memStream)
{
  if (_outSizeDefined)
  {
    const UInt64 rem = _outSize - _processedSize;
    if (size > rem)
      size = (UInt32)rem;
  }
  const UInt32 startSize = size;

  if (_remainLen == kLenIdFinished)
    return S_OK;
  if (_remainLen == kLenIdNeedInit)
  {
    _rangeDecoder.Init();
    _remainLen = 0;
    _info.MaxOrder = 0;
    _info.StartModelRare(_order);
  }
  while (size != 0)
  {
    int symbol = _info.DecodeSymbol(&_rangeDecoder);
    if (symbol < 0)
    {
      _remainLen = kLenIdFinished;
      break;
    }
    if (memStream != 0)
      *memStream++ = (Byte)symbol;
    else
      _outStream.WriteByte((Byte)symbol);
    size--;
  }
  _processedSize += startSize - size;
  return S_OK;
}

STDMETHODIMP CDecoder::CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
    const UInt64 * /* inSize */, const UInt64 *outSize, ICompressProgressInfo *progress)
{
  if (!_outStream.Create(1 << 20))
    return E_OUTOFMEMORY;
  
  SetInStream(inStream);
  _outStream.SetStream(outStream);
  SetOutStreamSize(outSize);
  CDecoderFlusher flusher(this);

  for (;;)
  {
    _processedSize = _outStream.GetProcessedSize();
    UInt32 curSize = (1 << 18);
    RINOK(CodeSpec(curSize, NULL));
    if (_remainLen == kLenIdFinished)
      break;
    if (progress != NULL)
    {
      UInt64 inSize = _rangeDecoder.GetProcessedSize();
      RINOK(progress->SetRatioInfo(&inSize, &_processedSize));
    }
    if (_outSizeDefined)
      if (_outStream.GetProcessedSize() >= _outSize)
        break;
  }
  flusher.NeedFlush = false;
  return Flush();
}

#ifdef _NO_EXCEPTIONS

#define PPMD_TRY_BEGIN
#define PPMD_TRY_END

#else

#define PPMD_TRY_BEGIN try {
#define PPMD_TRY_END } \
  catch(const CInBufferException &e)  { return e.ErrorCode; } \
  catch(const COutBufferException &e)  { return e.ErrorCode; } \
  catch(...) { return S_FALSE; }

#endif


STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
    const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress)
{
  PPMD_TRY_BEGIN
  return CodeReal(inStream, outStream, inSize, outSize, progress);
  PPMD_TRY_END
}

STDMETHODIMP CDecoder::SetInStream(ISequentialInStream *inStream)
{
  _rangeDecoder.SetStream(inStream);
  return S_OK;
}

STDMETHODIMP CDecoder::ReleaseInStream()
{
  _rangeDecoder.ReleaseStream();
  return S_OK;
}

STDMETHODIMP CDecoder::SetOutStreamSize(const UInt64 *outSize)
{
  _outSizeDefined = (outSize != NULL);
  if (_outSizeDefined)
    _outSize = *outSize;
  _processedSize = 0;
  _remainLen = kLenIdNeedInit;
  _outStream.Init();
  return S_OK;
}

#ifndef NO_READ_FROM_CODER

STDMETHODIMP CDecoder::Read(void *data, UInt32 size, UInt32 *processedSize)
{
  PPMD_TRY_BEGIN
  if (processedSize)
    *processedSize = 0;
  const UInt64 startPos = _processedSize;
  RINOK(CodeSpec(size, (Byte *)data));
  if (processedSize)
    *processedSize = (UInt32)(_processedSize - startPos);
  return Flush();
  PPMD_TRY_END
}

#endif

}}
<file_sep>/SQLCEHelper/Source/SqlCeHelper.cpp
#include "StdAfx.h"
#include "../Include/SqlCeHelper.h"

/*
TO-DO-LIST
**Support to create database file programmatically
**Support to open the database with password
**Support to specify the Open Mode
**Support to load Ole Db without COM registry.
	//http://social.msdn.microsoft.com/Forums/en-US/sqlce/thread/35db5fb8-443c-4b87-bda7-68fc7df6c6e6
**Support Transactions
**Support Parameters

*/

//http://www.microsoft.com/downloads/details.aspx?FamilyID=1ff0529a-eb1f-4044-b4b7-40b00710f7b7&displaylang=en
//Microsoft SQL Server Compact 3.5 Books Online and Samples

//C:\Program Files\Microsoft SQL Server Compact Edition\v3.5\Devices\wce500\armv4i
//sqlce.ppc.wce5.armv4i.CAB
//sqlce.repl.ppc.wce5.armv4i.CAB


SqlCeHelper::SqlCeHelper(void):
isOpen(false),
currentRowCount(0)
{
}

SqlCeHelper::~SqlCeHelper(void)
{
	Close();
}


bool SqlCeHelper::CreateDatabase(const CString& dbPath)
{
	HRESULT hr =		-1;
	DBPROP				dbprop[1];					// property used in property set to initialize provider
	DBPROPSET			dbpropset[1];				// Property Set used to initialize provider

	// Initialize environment
	//
	hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
	if(FAILED(hr))
	{
         goto Exit;
	}

	VariantInit(&dbprop[0].vValue);	

	HANDLE				hFind;							// File handle
	WIN32_FIND_DATA		FindFileData;					// The file structure description 
	hFind = FindFirstFile(dbPath, &FindFileData);
	if (INVALID_HANDLE_VALUE != hFind)
	{
		FindClose(hFind);
		DeleteDatabase(dbPath);
	}

	// Initialize a property with name of database
	//
    dbprop[0].dwPropertyID	= DBPROP_INIT_DATASOURCE;
	dbprop[0].dwOptions		= DBPROPOPTIONS_REQUIRED;
    dbprop[0].vValue.vt		= VT_BSTR;
	dbprop[0].vValue.bstrVal= SysAllocString(dbPath);
	if(NULL == dbprop[0].vValue.bstrVal)
	{
		goto Exit;
	}

	// Initialize the property set
	//
	dbpropset[0].guidPropertySet = DBPROPSET_DBINIT;
	dbpropset[0].rgProperties	 = dbprop;
	dbpropset[0].cProperties	 = sizeof(dbprop)/sizeof(dbprop[0]);

	hr = dataSource.Create(CLSID_SQLSERVERCE, 1, dbpropset, &session);
	if(FAILED(hr))
	{
		goto Exit;
	}

Exit:
	VariantClear(&dbprop[0].vValue);
	return (hr >= 0);
}

bool SqlCeHelper::DeleteDatabase(const CString& dbPath)
{
	BOOL r = DeleteFile(dbPath);
	return r?true:false;
}

bool SqlCeHelper::Open(const CString& dbPath)
{
	HRESULT hr =		-1;
	DBPROP				dbprop[1];					// property used in property set to initialize provider
	DBPROPSET			dbpropset[1];				// Property Set used to initialize provider

	// Initialize environment
	//
	hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
	if(FAILED(hr))
	{
         goto Exit;
	}
	
	HANDLE				hFind;							// File handle
	WIN32_FIND_DATA		FindFileData;					// The file structure description 
	hFind = FindFirstFile(dbPath, &FindFileData);
	if (INVALID_HANDLE_VALUE == hFind)
	{
		goto Exit;
	}

	// Initialize a property with name of database
	//
    dbprop[0].dwPropertyID	= DBPROP_INIT_DATASOURCE;
	dbprop[0].dwOptions		= DBPROPOPTIONS_REQUIRED;
    dbprop[0].vValue.vt		= VT_BSTR;
	dbprop[0].vValue.bstrVal= SysAllocString(dbPath);
	if(NULL == dbprop[0].vValue.bstrVal)
	{
		goto Exit;
	}

	// Initialize the property set
	//
	dbpropset[0].guidPropertySet = DBPROPSET_DBINIT;
	dbpropset[0].rgProperties	 = dbprop;
	dbpropset[0].cProperties	 = sizeof(dbprop)/sizeof(dbprop[0]);

	hr = dataSource.Open(CLSID_SQLSERVERCE, 1, dbpropset);
	if(FAILED(hr))
	{
		goto Exit;
	}
	
	hr = session.Open(dataSource);
	if(FAILED(hr))
	{
		goto Exit;
	}
	
Exit:
	VariantClear(&dbprop[0].vValue);
	return (hr >= 0);
}

void SqlCeHelper::Close()
{
	if(!isOpen)
	{
		return;
	}

	CloseReader();
	session.Close();
	dataSource.Close();
	
	// Uninitialize the environment
	CoUninitialize();
	isOpen = false;
}

int SqlCeHelper::ExecuteNonQuery(const CString& sql)
{
	CCommand command(session);
	command.SetText(sql);
	LONG rowsAffected;
	command.Execute(&rowsAffected);
	
	return (int)rowsAffected;
}


void SqlCeHelper::BeginTransaction()
{
}

void SqlCeHelper::CommitTransaction()
{
}

void SqlCeHelper::RollbackTransaction()
{
}

//Changed from
//ms-help://MS.SSC.v35/MS.SSC.v35.EN/ssctechref/html/a25fafe1-e90a-4545-8836-749dd44135c0.htm
CString SqlCeHelper::GetErrorsMessage()
{
    static CString sErrIErrorInfo     = L"IErrorInfo interface";
    static CString sErrIErrorRecords  = L"IErrorRecords interface";
    static CString sErrRecordCount    = L"error record count";
    static CString sErrInfo           = L"ERRORINFO structure";
    static CString sErrStandardInfo   = L"standard error info";
    static CString sErrDescription    = L"standard error description";
    static CString sErrNoSource       = L"error source";

    HRESULT hr                          = S_OK;
    IErrorInfo       *pIErrorInfo       = NULL;
    IErrorRecords    *pIErrorRecords    = NULL;
    ERRORINFO        errorInfo          = { 0 };
    IErrorInfo       *pIErrorInfoRecord = NULL;
	
	CString message = L"";
	char str[255];
    try
    {
        // This interface supports returning error information.
        // Get the error object from the system for the current
        // thread.
        hr = GetErrorInfo(0, &pIErrorInfo);
        if ( hr == S_FALSE )
        {
            message = "No error occured.";
            return message;
        }

        if(FAILED(hr) || NULL == pIErrorInfo)
            throw sErrIErrorInfo;

        // The error records are retrieved from the IIErrorRecords
        // interface, which can be obtained from the IErrorInfo
        // interface.
        hr = pIErrorInfo->QueryInterface(IID_IErrorRecords,
            (void **) &pIErrorRecords);
        if ( FAILED(hr) || NULL == pIErrorRecords )
            throw sErrIErrorRecords;

        // The IErrorInfo interface is no longer required because
        // we have the IErrorRecords interface, relase it.
        pIErrorInfo->Release();
        pIErrorInfo = NULL;

        ULONG ulNumErrorRecs = 0;

        // Determine the number of records in this error object
        hr = pIErrorRecords->GetRecordCount(&ulNumErrorRecs);
        if ( FAILED(hr) )
            throw sErrRecordCount;


        // Loop over each error record in the error object to display 
        // information about each error. Errors are returned. 
        for (DWORD dwErrorIndex = 0;
             dwErrorIndex < ulNumErrorRecs;
             dwErrorIndex++)
        {
            // Retrieve basic error information for this error.
            hr = pIErrorRecords->GetBasicErrorInfo(dwErrorIndex,
              &errorInfo);
            if ( FAILED(hr) )
                throw sErrInfo;

            TCHAR szCLSID[64]  = { 0 };
            TCHAR szIID[64]    = { 0 };
            TCHAR szDISPID[64] = { 0 };

            StringFromGUID2(errorInfo.clsid, (LPOLESTR)szCLSID,
                sizeof(szCLSID));
            StringFromGUID2(errorInfo.iid, (LPOLESTR)szIID,
                sizeof(szIID));

            sprintf(str, "HRESULT           = %lx\n", errorInfo.hrError);
            message += str;
			sprintf(str, "clsid             = %S\n", szCLSID);
            message += str;
            sprintf(str, "iid               = %S\n", szIID);
            message += str;
            sprintf(str, "dispid            = %ld\n", errorInfo.dispid);
            message += str;
            sprintf(str, "Native Error Code = %lx\n", errorInfo.dwMinor);
            message += str;

            // Retrieve standard error information for this error.
            hr = pIErrorRecords->GetErrorInfo(dwErrorIndex, NULL,
                &pIErrorInfoRecord);

            if ( FAILED(hr) )
                throw sErrStandardInfo;

            BSTR bstrDescriptionOfError;
            BSTR bstrSourceOfError;

            // Get the description of the error.
            hr = pIErrorInfoRecord->GetDescription(
                   &bstrDescriptionOfError);
            if ( FAILED(hr) )
                throw sErrDescription;

            sprintf(str, "Description = %S\n", bstrDescriptionOfError);
            message += str;
			
            // Get the source of the error.
            hr = pIErrorInfoRecord->GetSource(&bstrSourceOfError);
            if ( FAILED(hr) )
                throw sErrNoSource;

            sprintf(str, "Description = %S\n", bstrSourceOfError);
            message += str;
			
            // This interface variable will be used the next time 
            // though this loop. In the last error case this interface 
            // is no longer needed so we must release it.
            if(NULL != pIErrorInfoRecord)
                pIErrorInfoRecord->Release();
            pIErrorInfoRecord = NULL;
        }
    }
	catch( CString& szMsg )
    {
        message = L"Failed to retrieve " + szMsg;
    }

    if( pIErrorInfoRecord )
        pIErrorInfoRecord->Release();

    if ( pIErrorInfo )
        pIErrorInfo->Release();

    if ( pIErrorRecords )
        pIErrorRecords->Release();

    return message;
}

int SqlCeHelper::ExecuteReader(const CString& sql)
{
	CCommand command(session);
	command.SetText(sql);
	ULONG rows;
	command.Execute(rowset);
	rowset.GetRowCount(&rows);
	currentRowCount = 0;
	totalRowCount = (int)rows;

	rowset.MoveFirst();
	return totalRowCount;
}


bool SqlCeHelper::IsEndOfRecordSet()
{
	return (currentRowCount == totalRowCount);
}

void SqlCeHelper::MoveNext()
{
	++currentRowCount;
	rowset.MoveNext();
}

void SqlCeHelper::CloseReader()
{
	currentRowCount = 0;
	totalRowCount = 0;
	rowset.Close();
}

int SqlCeHelper::GetRowInt(const long ordinal)
{
	int i;
	rowset.GetValue(ordinal, i);
	return i;
}

double SqlCeHelper::GetRowDouble(const long ordinal)
{	
	double d;
	rowset.GetValue(ordinal, d);
	return d;
}

CString SqlCeHelper::GetRowStr(const long ordinal)
{
	CString s;
	rowset.GetValue(ordinal, s);
	return s;
}
<file_sep>/SQLCEHelper/Include/BlobStream.h
#ifndef __BLOBSTREAM_H__
#define __BLOBSTREAM_H__

class CBlobStream : public ISequentialStream
{
public:
	CBlobStream();
	virtual ~CBlobStream();

	void Clear();

	//
	// ISequentialStream interface implementation.
	//
    virtual HRESULT STDMETHODCALLTYPE QueryInterface( 
        /* [in] */ REFIID riid,
        /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
    
    virtual ULONG STDMETHODCALLTYPE AddRef( void);
    
    virtual ULONG STDMETHODCALLTYPE Release( void);
 
    virtual /* [local] */ HRESULT STDMETHODCALLTYPE Read( 
        /* [length_is][size_is][out] */ void __RPC_FAR *pv,
        /* [in] */ ULONG cb,
        /* [out] */ ULONG __RPC_FAR *pcbRead);
    
    virtual /* [local] */ HRESULT STDMETHODCALLTYPE Write( 
        /* [size_is][in] */ const void __RPC_FAR *pv,
        /* [in] */ ULONG cb,
        /* [out] */ ULONG __RPC_FAR *pcbWritten);

	HRESULT WriteFromStream(IStream *pStream, ULONG cb, ULONG *pcbWritten);
	HRESULT WriteFromStream(ISequentialStream *pStream, ULONG cb, ULONG *pcbWritten);

	ULONG	GetSize	()	{ return m_nLength;	}
	BYTE*	GetData	()	{ return m_pBuffer;	}

protected:
	BYTE*		m_pBuffer;
	ULONG		m_nLength,
				m_iPosRead,
				m_iPosWrite,
				m_nRef;
	DBSTATUS	m_dbStatus;
};

#endif<file_sep>/7-Zip/CPP/7zip/Archive/Udf/UdfHandler.h
// Udf/Handler.h

#ifndef __UDF_HANDLER_H
#define __UDF_HANDLER_H

#include "Common/MyCom.h"
#include "../IArchive.h"

#include "UdfIn.h"

namespace NArchive {
namespace NUdf {

struct CRef2
{
  int Vol;
  int Fs;
  int Ref;
};

class CHandler:
  public IInArchive,
  public IInArchiveGetStream,
  public CMyUnknownImp
{
  CMyComPtr<IInStream> _inStream;
  CInArchive _archive;
  CRecordVector<CRef2> _refs2;
public:
  MY_UNKNOWN_IMP2(IInArchive, IInArchiveGetStream)
  INTERFACE_IInArchive(;)
  STDMETHOD(GetStream)(UInt32 index, ISequentialInStream **stream);
};

}}

#endif
  <file_sep>/7-Zip/CPP/7zip/UI/Far/Plugin.cpp
// Plugin.cpp

#include "StdAfx.h"

#include "Common/IntToString.h"
#include "Common/StringConvert.h"
#include "Common/Wildcard.h"

#include "Windows/FileDir.h"
#include "Windows/PropVariantConversions.h"

#include "../Common/PropIDUtils.h"

#include "FarUtils.h"
#include "Messages.h"
#include "Plugin.h"

using namespace NWindows;
using namespace NFar;

CPlugin::CPlugin(const UString &fileName, IInFolderArchive *archiveHandler, UString archiveTypeName):
    m_ArchiveHandler(archiveHandler),
    m_FileName(fileName),
    _archiveTypeName(archiveTypeName)
{
  if (!m_FileInfo.Find(m_FileName))
    throw "error";
  archiveHandler->BindToRootFolder(&_folder);
}

CPlugin::~CPlugin() {}

static void MyGetFileTime(IFolderFolder *anArchiveFolder, UInt32 itemIndex,
    PROPID propID, FILETIME &fileTime)
{
  NCOM::CPropVariant prop;
  if (anArchiveFolder->GetProperty(itemIndex, propID, &prop) != S_OK)
    throw 271932;
  if (prop.vt == VT_EMPTY)
  {
    fileTime.dwHighDateTime = 0;
    fileTime.dwLowDateTime = 0;
  }
  else
  {
    if (prop.vt != VT_FILETIME)
      throw 4191730;
    fileTime = prop.filetime;
  }
}

#define kDotsReplaceString "[[..]]"
#define kDotsReplaceStringU L"[[..]]"
  
static void CopyStrLimited(char *dest, const AString &src, int len)
{
  len--;
  if (src.Length() < len)
    len = src.Length();
  memcpy(dest, src, sizeof(dest[0]) * len);
  dest[len] = 0;
}

#define COPY_STR_LIMITED(dest, src) CopyStrLimited(dest, src, sizeof(dest) / sizeof(dest[0]))

void CPlugin::ReadPluginPanelItem(PluginPanelItem &panelItem, UInt32 itemIndex)
{
  NCOM::CPropVariant prop;
  if (_folder->GetProperty(itemIndex, kpidName, &prop) != S_OK)
    throw 271932;

  if (prop.vt != VT_BSTR)
    throw 272340;

  CSysString oemString = UnicodeStringToMultiByte(prop.bstrVal, CP_OEMCP);
  if (oemString == "..")
    oemString = kDotsReplaceString;

  COPY_STR_LIMITED(panelItem.FindData.cFileName, oemString);
  panelItem.FindData.cAlternateFileName[0] = 0;

  if (_folder->GetProperty(itemIndex, kpidAttrib, &prop) != S_OK)
    throw 271932;
  if (prop.vt == VT_UI4)
    panelItem.FindData.dwFileAttributes  = prop.ulVal;
  else if (prop.vt == VT_EMPTY)
    panelItem.FindData.dwFileAttributes = m_FileInfo.Attrib;
  else
    throw 21631;

  if (_folder->GetProperty(itemIndex, kpidIsDir, &prop) != S_OK)
    throw 271932;
  if (prop.vt == VT_BOOL)
  {
    if (VARIANT_BOOLToBool(prop.boolVal))
      panelItem.FindData.dwFileAttributes |= FILE_ATTRIBUTE_DIRECTORY;
  }
  else if (prop.vt != VT_EMPTY)
    throw 21632;

  if (_folder->GetProperty(itemIndex, kpidSize, &prop) != S_OK)
    throw 271932;
  UInt64 length;
  if (prop.vt == VT_EMPTY)
    length = 0;
  else
    length = ::ConvertPropVariantToUInt64(prop);
  panelItem.FindData.nFileSizeLow = (UInt32)length;
  panelItem.FindData.nFileSizeHigh = (UInt32)(length >> 32);

  MyGetFileTime(_folder, itemIndex, kpidCTime, panelItem.FindData.ftCreationTime);
  MyGetFileTime(_folder, itemIndex, kpidATime, panelItem.FindData.ftLastAccessTime);
  MyGetFileTime(_folder, itemIndex, kpidMTime, panelItem.FindData.ftLastWriteTime);

  if (panelItem.FindData.ftLastWriteTime.dwHighDateTime == 0 &&
      panelItem.FindData.ftLastWriteTime.dwLowDateTime == 0)
    panelItem.FindData.ftLastWriteTime = m_FileInfo.MTime;

  if (_folder->GetProperty(itemIndex, kpidPackSize, &prop) != S_OK)
    throw 271932;
  if (prop.vt == VT_EMPTY)
    length = 0;
  else
    length = ::ConvertPropVariantToUInt64(prop);
  panelItem.PackSize = UInt32(length);
  panelItem.PackSizeHigh = UInt32(length >> 32);

  panelItem.Flags = 0;
  panelItem.NumberOfLinks = 0;

  panelItem.Description = NULL;
  panelItem.Owner = NULL;
  panelItem.CustomColumnData = NULL;
  panelItem.CustomColumnNumber = 0;

  panelItem.Reserved[0] = 0;
  panelItem.Reserved[1] = 0;
  panelItem.Reserved[2] = 0;
}

int CPlugin::GetFindData(PluginPanelItem **panelItems, int *itemsNumber, int opMode)
{
  // CScreenRestorer screenRestorer;
  if ((opMode & OPM_SILENT) == 0 && (opMode & OPM_FIND ) == 0)
  {
    /*
    screenRestorer.Save();
    const char *msgItems[]=
    {
      g_StartupInfo.GetMsgString(NMessageID::kWaitTitle),
        g_StartupInfo.GetMsgString(NMessageID::kReadingList)
    };
    g_StartupInfo.ShowMessage(0, NULL, msgItems,
      sizeof(msgItems) / sizeof(msgItems[0]), 0);
    */
  }

  UInt32 numItems;
  _folder->GetNumberOfItems(&numItems);
  *panelItems = new PluginPanelItem[numItems];
  try
  {
    for (UInt32 i = 0; i < numItems; i++)
    {
      PluginPanelItem &panelItem = (*panelItems)[i];
      ReadPluginPanelItem(panelItem, i);
      panelItem.UserData = i;
    }
  }
  catch(...)
  {
    delete [](*panelItems);
    throw;
  }
  *itemsNumber = numItems;
  return(TRUE);
}

void CPlugin::FreeFindData(struct PluginPanelItem *panelItems, int itemsNumber)
{
  for (int i = 0; i < itemsNumber; i++)
    if (panelItems[i].Description != NULL)
      delete []panelItems[i].Description;
  delete []panelItems;
}

void CPlugin::EnterToDirectory(const UString &dirName)
{
  CMyComPtr<IFolderFolder> newFolder;
  UString s = dirName;
  if (dirName == kDotsReplaceStringU)
    s = L"..";
  _folder->BindToFolder(s, &newFolder);
  if (newFolder == NULL)
    if (dirName.IsEmpty())
      return;
    else
      throw 40325;
  _folder = newFolder;
}

int CPlugin::SetDirectory(const char *aszDir, int /* opMode */)
{
  UString path = MultiByteToUnicodeString(aszDir, CP_OEMCP);
  if (path == WSTRING_PATH_SEPARATOR)
  {
    _folder.Release();
    m_ArchiveHandler->BindToRootFolder(&_folder);
  }
  else if (path == L"..")
  {
    CMyComPtr<IFolderFolder> newFolder;
    _folder->BindToParentFolder(&newFolder);
    if (newFolder == NULL)
      throw 40312;
    _folder = newFolder;
  }
  else if (path.IsEmpty())
    EnterToDirectory(path);
  else
  {
    if (path[0] == WCHAR_PATH_SEPARATOR)
    {
      _folder.Release();
      m_ArchiveHandler->BindToRootFolder(&_folder);
      path = path.Mid(1);
    }
    UStringVector pathParts;
    SplitPathToParts(path, pathParts);
    for (int i = 0; i < pathParts.Size(); i++)
      EnterToDirectory(pathParts[i]);
  }
  GetCurrentDir();
  return TRUE;
}

void CPlugin::GetPathParts(UStringVector &pathParts)
{
  pathParts.Clear();
  CMyComPtr<IFolderFolder> folderItem = _folder;
  for (;;)
  {
    CMyComPtr<IFolderFolder> newFolder;
    folderItem->BindToParentFolder(&newFolder);
    if (newFolder == NULL)
      break;
    NCOM::CPropVariant prop;
    if (folderItem->GetFolderProperty(kpidName, &prop) == S_OK)
      if (prop.vt == VT_BSTR)
        pathParts.Insert(0, (const wchar_t *)prop.bstrVal);
    folderItem = newFolder;
  }
}

void CPlugin::GetCurrentDir()
{
  m_CurrentDir.Empty();
  UStringVector pathParts;
  GetPathParts(pathParts);
  for (int i = 0; i < pathParts.Size(); i++)
  {
    m_CurrentDir += WCHAR_PATH_SEPARATOR;
    m_CurrentDir += pathParts[i];
  }
}

static char *kPluginFormatName = "7-ZIP";


struct CPROPIDToName
{
  PROPID PropID;
  int PluginID;
};

static CPROPIDToName kPROPIDToName[] =
{
  { kpidName, NMessageID::kName },
  { kpidExtension, NMessageID::kExtension },
  { kpidIsDir, NMessageID::kIsFolder },
  { kpidSize, NMessageID::kSize },
  { kpidPackSize, NMessageID::kPackSize },
  { kpidAttrib, NMessageID::kAttributes },
  { kpidCTime, NMessageID::kCTime },
  { kpidATime, NMessageID::kATime },
  { kpidMTime, NMessageID::kMTime },
  { kpidSolid, NMessageID::kSolid },
  { kpidCommented, NMessageID::kCommented },
  { kpidEncrypted, NMessageID::kEncrypted },
  { kpidSplitBefore, NMessageID::kSplitBefore },
  { kpidSplitAfter, NMessageID::kSplitAfter },
  { kpidDictionarySize, NMessageID::kDictionarySize },
  { kpidCRC, NMessageID::kCRC },
  { kpidType, NMessageID::kType },
  { kpidIsAnti, NMessageID::kAnti },
  { kpidMethod, NMessageID::kMethod },
  { kpidHostOS, NMessageID::kHostOS },
  { kpidFileSystem, NMessageID::kFileSystem },
  { kpidUser, NMessageID::kUser },
  { kpidGroup, NMessageID::kGroup },
  { kpidBlock, NMessageID::kBlock },
  { kpidComment, NMessageID::kComment },
  { kpidPosition, NMessageID::kPosition },
  { kpidNumSubDirs, NMessageID::kNumSubFolders },
  { kpidNumSubFiles, NMessageID::kNumSubFiles },
  { kpidUnpackVer, NMessageID::kUnpackVer },
  { kpidVolume, NMessageID::kVolume },
  { kpidIsVolume, NMessageID::kIsVolume },
  { kpidOffset, NMessageID::kOffset },
  { kpidLinks, NMessageID::kLinks },
  { kpidNumBlocks, NMessageID::kNumBlocks },
  { kpidNumVolumes, NMessageID::kNumVolumes },
  
  { kpidBit64, NMessageID::kBit64 },
  { kpidBigEndian, NMessageID::kBigEndian },
  { kpidCpu, NMessageID::kCpu },
  { kpidPhySize, NMessageID::kPhySize },
  { kpidHeadersSize, NMessageID::kHeadersSize },
  { kpidChecksum, NMessageID::kChecksum },
  { kpidCharacts, NMessageID::kCharacts },
  { kpidVa, NMessageID::kVa },
  { kpidId, NMessageID::kId },
  { kpidShortName, NMessageID::kShortName},
  { kpidCreatorApp, NMessageID::kCreatorApp },
  { kpidSectorSize, NMessageID::kSectorSize },
  { kpidPosixAttrib, NMessageID::kPosixAttrib },
  { kpidLink, NMessageID::kLink },

  { kpidTotalSize, NMessageID::kTotalSize },
  { kpidFreeSpace, NMessageID::kFreeSpace },
  { kpidClusterSize, NMessageID::kClusterSize },
  { kpidVolumeName, NMessageID::kLabel }
};

static const int kNumPROPIDToName = sizeof(kPROPIDToName) /  sizeof(kPROPIDToName[0]);

static int FindPropertyToName(PROPID propID)
{
  for (int i = 0; i < kNumPROPIDToName; i++)
    if (kPROPIDToName[i].PropID == propID)
      return i;
  return -1;
}

/*
struct CPropertyIDInfo
{
  PROPID PropID;
  const char *FarID;
  int Width;
  // char CharID;
};

static CPropertyIDInfo kPropertyIDInfos[] =
{
  { kpidName, "N", 0},
  { kpidSize, "S", 8},
  { kpidPackedSize, "P", 8},
  { kpidAttrib, "A", 0},
  { kpidCTime, "DC", 14},
  { kpidATime, "DA", 14},
  { kpidMTime, "DM", 14},
  
  { kpidSolid, NULL, 0, 'S'},
  { kpidEncrypted, NULL, 0, 'P'}

  { kpidDictionarySize, IDS_PROPERTY_DICTIONARY_SIZE },
  { kpidSplitBefore, NULL, 'B'},
  { kpidSplitAfter, NULL, 'A'},
  { kpidComment, , NULL, 'C'},
  { kpidCRC, IDS_PROPERTY_CRC }
  // { kpidType, L"Type" }
};

static const int kNumPropertyIDInfos = sizeof(kPropertyIDInfos) /
    sizeof(kPropertyIDInfos[0]);

static int FindPropertyInfo(PROPID propID)
{
  for (int i = 0; i < kNumPropertyIDInfos; i++)
    if (kPropertyIDInfos[i].PropID == propID)
      return i;
  return -1;
}
*/

// char *g_Titles[] = { "a", "f", "v" };
/*
static void SmartAddToString(AString &destString, const char *srcString)
{
  if (!destString.IsEmpty())
    destString += ',';
  destString += srcString;
}
*/

/*
void CPlugin::AddColumn(PROPID propID)
{
  int index = FindPropertyInfo(propID);
  if (index >= 0)
  {
    for (int i = 0; i < m_ProxyHandler->m_InternalProperties.Size(); i++)
    {
      const CArchiveItemProperty &aHandlerProperty = m_ProxyHandler->m_InternalProperties[i];
      if (aHandlerProperty.ID == propID)
        break;
    }
    if (i == m_ProxyHandler->m_InternalProperties.Size())
      return;

    const CPropertyIDInfo &propertyIDInfo = kPropertyIDInfos[index];
    SmartAddToString(PanelModeColumnTypes, propertyIDInfo.FarID);
    char tmp[32];
    itoa(propertyIDInfo.Width, tmp, 10);
    SmartAddToString(PanelModeColumnWidths, tmp);
    return;
  }
}
*/

static AString GetNameOfProp(PROPID propID, const wchar_t *name)
{
  int index = FindPropertyToName(propID);
  if (index < 0)
  {
    if (name)
      return UnicodeStringToMultiByte((const wchar_t *)name, CP_OEMCP);
    char s[32];
    ConvertUInt64ToString(propID, s);
    return s;
  }
  return g_StartupInfo.GetMsgString(kPROPIDToName[index].PluginID);
}

static AString GetNameOfProp2(PROPID propID, const wchar_t *name)
{
  AString s = GetNameOfProp(propID, name);
  if (s.Length() > (kInfoPanelLineSize - 1))
    s = s.Left(kInfoPanelLineSize - 1);
  return s;
}

static AString ConvertSizeToString(UInt64 value)
{
  char s[32];
  ConvertUInt64ToString(value, s);
  int i = MyStringLen(s);
  int pos = sizeof(s) / sizeof(s[0]);
  s[--pos] = L'\0';
  while (i > 3)
  {
    s[--pos] = s[--i];
    s[--pos] = s[--i];
    s[--pos] = s[--i];
    s[--pos] = ' ';
  }
  while (i > 0)
    s[--pos] = s[--i];
  return s + pos;
}

static AString PropToString(const NCOM::CPropVariant &prop, PROPID propID)
{
  AString s;

  if (prop.vt == VT_BSTR)
    s = GetSystemString(prop.bstrVal, CP_OEMCP);
  else if (prop.vt == VT_BOOL)
  {
    int messageID = VARIANT_BOOLToBool(prop.boolVal) ?
      NMessageID::kYes : NMessageID::kNo;
    return g_StartupInfo.GetMsgString(messageID);
  }
  else if (prop.vt != VT_EMPTY)
  {
    if ((
        propID == kpidSize ||
        propID == kpidPackSize ||
        propID == kpidNumSubDirs ||
        propID == kpidNumSubFiles ||
        propID == kpidNumBlocks ||
        propID == kpidPhySize ||
        propID == kpidHeadersSize ||
        propID == kpidClusterSize
        ) && (prop.vt == VT_UI8 || prop.vt == VT_UI4))
      s = ConvertSizeToString(ConvertPropVariantToUInt64(prop));
    else
      s = UnicodeStringToMultiByte(ConvertPropertyToString(prop, propID), CP_OEMCP);
  }
  s.Replace((char)0xA, ' ');
  s.Replace((char)0xD, ' ');
  return s;
}

static AString PropToString2(const NCOM::CPropVariant &prop, PROPID propID)
{
  AString s = PropToString(prop, propID);
  if (s.Length() > (kInfoPanelLineSize - 1))
    s = s.Left(kInfoPanelLineSize - 1);
  return s;
}

void CPlugin::GetOpenPluginInfo(struct OpenPluginInfo *info)
{
  info->StructSize = sizeof(*info);
  info->Flags = OPIF_USEFILTER | OPIF_USESORTGROUPS| OPIF_USEHIGHLIGHTING|
              OPIF_ADDDOTS | OPIF_COMPAREFATTIME;

  COPY_STR_LIMITED(m_FileNameBuffer, UnicodeStringToMultiByte(m_FileName, CP_OEMCP));
  info->HostFile = m_FileNameBuffer; // test it it is not static
  
  COPY_STR_LIMITED(m_CurrentDirBuffer, UnicodeStringToMultiByte(m_CurrentDir, CP_OEMCP));
  info->CurDir = m_CurrentDirBuffer;

  info->Format = kPluginFormatName;

  UString name;
  {
    UString fullName;
    int index;
    NFile::NDirectory::MyGetFullPathName(m_FileName, fullName, index);
    name = fullName.Mid(index);
  }

  m_PannelTitle =
      UString(L' ') +
      _archiveTypeName +
      UString(L':') +
      name +
      UString(L' ');
  if (!m_CurrentDir.IsEmpty())
  {
    // m_PannelTitle += '\\';
    m_PannelTitle += m_CurrentDir;
  }
 
  COPY_STR_LIMITED(m_PannelTitleBuffer, UnicodeStringToMultiByte(m_PannelTitle, CP_OEMCP));
  info->PanelTitle = m_PannelTitleBuffer;

  memset(m_InfoLines, 0, sizeof(m_InfoLines));
  MyStringCopy(m_InfoLines[0].Text, "");
  m_InfoLines[0].Separator = TRUE;

  MyStringCopy(m_InfoLines[1].Text, g_StartupInfo.GetMsgString(NMessageID::kArchiveType));
  MyStringCopy(m_InfoLines[1].Data, (const char *)UnicodeStringToMultiByte(_archiveTypeName, CP_OEMCP));

  int numItems = 2;

  {
    CMyComPtr<IFolderProperties> folderProperties;
    _folder.QueryInterface(IID_IFolderProperties, &folderProperties);
    if (folderProperties)
    {
      UInt32 numProps;
      if (folderProperties->GetNumberOfFolderProperties(&numProps) == S_OK)
      {
        for (UInt32 i = 0; i < numProps && numItems < kNumInfoLinesMax; i++)
        {
          CMyComBSTR name;
          PROPID propID;
          VARTYPE vt;
          if (folderProperties->GetFolderPropertyInfo(i, &name, &propID, &vt) != S_OK)
            continue;
          NCOM::CPropVariant prop;
          if (_folder->GetFolderProperty(propID, &prop) != S_OK || prop.vt == VT_EMPTY)
            continue;
          
          InfoPanelLine &item = m_InfoLines[numItems++];
          COPY_STR_LIMITED(item.Text, GetNameOfProp2(propID, name));
          COPY_STR_LIMITED(item.Data, PropToString2(prop, propID));
        }
      }
    }
  }

  if (numItems < kNumInfoLinesMax)
  {
    InfoPanelLine &item = m_InfoLines[numItems++];
    MyStringCopy(item.Text, "");
    MyStringCopy(item.Data, "");
    item.Separator = TRUE;
  }

  {
    CMyComPtr<IGetFolderArchiveProperties> getFolderArchiveProperties;
    _folder.QueryInterface(IID_IGetFolderArchiveProperties, &getFolderArchiveProperties);
    if (getFolderArchiveProperties)
    {
      CMyComPtr<IFolderArchiveProperties> getProps;
      getFolderArchiveProperties->GetFolderArchiveProperties(&getProps);
      if (getProps)
      {
        UInt32 numProps;
        if (getProps->GetNumberOfArchiveProperties(&numProps) == S_OK)
        {
          /*
          if (numProps > 0)
            message += kSeparator;
          */
          for (UInt32 i = 0; i < numProps && numItems < kNumInfoLinesMax; i++)
          {
            CMyComBSTR name;
            PROPID propID;
            VARTYPE vt;
            if (getProps->GetArchivePropertyInfo(i, &name, &propID, &vt) != S_OK)
              continue;
            NCOM::CPropVariant prop;
            if (getProps->GetArchiveProperty(propID, &prop) != S_OK || prop.vt == VT_EMPTY)
              continue;
            InfoPanelLine &item = m_InfoLines[numItems++];
            COPY_STR_LIMITED(item.Text, GetNameOfProp2(propID, name));
            COPY_STR_LIMITED(item.Data, PropToString2(prop, propID));

          }
        }
      }
    }
  }

  //m_InfoLines[1].Separator = 0;

  info->InfoLines = m_InfoLines;
  info->InfoLinesNumber = numItems;

  
  info->DescrFiles = NULL;
  info->DescrFilesNumber = 0;

  PanelModeColumnTypes.Empty();
  PanelModeColumnWidths.Empty();

  /*
  AddColumn(kpidName);
  AddColumn(kpidSize);
  AddColumn(kpidPackedSize);
  AddColumn(kpidMTime);
  AddColumn(kpidCTime);
  AddColumn(kpidATime);
  AddColumn(kpidAttrib);
  
  PanelMode.ColumnTypes = (char *)(const char *)PanelModeColumnTypes;
  PanelMode.ColumnWidths = (char *)(const char *)PanelModeColumnWidths;
  PanelMode.ColumnTitles = NULL;
  PanelMode.FullScreen = TRUE;
  PanelMode.DetailedStatus = FALSE;
  PanelMode.AlignExtensions = FALSE;
  PanelMode.CaseConversion = FALSE;
  PanelMode.StatusColumnTypes = "N";
  PanelMode.StatusColumnWidths = "0";
  PanelMode.Reserved[0] = 0;
  PanelMode.Reserved[1] = 0;

  info->PanelModesArray = &PanelMode;
  info->PanelModesNumber = 1;
  */

  info->PanelModesArray = NULL;
  info->PanelModesNumber = 0;

  info->StartPanelMode = 0;
  info->StartSortMode = 0;
  info->KeyBar = NULL;
  info->ShortcutData = NULL;
}

struct CArchiveItemProperty
{
  AString Name;
  PROPID ID;
  VARTYPE Type;
};

HRESULT CPlugin::ShowAttributesWindow()
{
  PluginPanelItem pluginPanelItem;
  if (!g_StartupInfo.ControlGetActivePanelCurrentItemInfo(pluginPanelItem))
    return S_FALSE;
  if (strcmp(pluginPanelItem.FindData.cFileName, "..") == 0 &&
        NFile::NFind::NAttributes::IsDir(pluginPanelItem.FindData.dwFileAttributes))
    return S_FALSE;
  int itemIndex = pluginPanelItem.UserData;

  CObjectVector<CArchiveItemProperty> properties;
  UInt32 numProps;
  RINOK(_folder->GetNumberOfProperties(&numProps));
  int i;
  for (i = 0; i < (int)numProps; i++)
  {
    CMyComBSTR name;
    PROPID propID;
    VARTYPE vt;
    RINOK(_folder->GetPropertyInfo(i, &name, &propID, &vt));
    CArchiveItemProperty prop;
    prop.Type = vt;
    prop.ID = propID;
    if (prop.ID  == kpidPath)
      prop.ID  = kpidName;
    prop.Name = GetNameOfProp(propID, name);
    properties.Add(prop);
  }

  int size = 2;
  CRecordVector<CInitDialogItem> initDialogItems;
  
  int xSize = 70;
  CInitDialogItem idi =
  { DI_DOUBLEBOX, 3, 1, xSize - 4, size - 2, false, false, 0, false, NMessageID::kProperties, NULL, NULL };
  initDialogItems.Add(idi);
  AStringVector values;

  for (i = 0; i < properties.Size(); i++)
  {
    const CArchiveItemProperty &property = properties[i];

    CInitDialogItem idi =
      { DI_TEXT, 5, 3 + i, 0, 0, false, false, 0, false, 0, NULL, NULL };
    int index = FindPropertyToName(property.ID);
    if (index < 0)
    {
      idi.DataMessageId = -1;
      idi.DataString = property.Name;
    }
    else
      idi.DataMessageId = kPROPIDToName[index].PluginID;
    initDialogItems.Add(idi);
    
    NCOM::CPropVariant prop;
    RINOK(_folder->GetProperty(itemIndex, property.ID, &prop));
    CSysString s = PropToString(prop, property.ID);
    values.Add(s);
    
    {
      CInitDialogItem idi =
      { DI_TEXT, 30, 3 + i, 0, 0, false, false, 0, false, -1, NULL, NULL };
      initDialogItems.Add(idi);
    }
  }

  int numLines = values.Size();
  for (i = 0; i < numLines; i++)
  {
    CInitDialogItem &idi = initDialogItems[1 + i * 2 + 1];
    idi.DataString = values[i];
  }
  
  int numDialogItems = initDialogItems.Size();
  
  CRecordVector<FarDialogItem> dialogItems;
  dialogItems.Reserve(numDialogItems);
  for (i = 0; i < numDialogItems; i++)
    dialogItems.Add(FarDialogItem());
  g_StartupInfo.InitDialogItems(&initDialogItems.Front(),
      &dialogItems.Front(), numDialogItems);
  
  int maxLen = 0;
  for (i = 0; i < numLines; i++)
  {
    FarDialogItem &dialogItem = dialogItems[1 + i * 2];
    int len = (int)strlen(dialogItem.Data);
    if (len > maxLen)
      maxLen = len;
  }
  int maxLen2 = 0;
  const int kSpace = 10;
  for (i = 0; i < numLines; i++)
  {
    FarDialogItem &dialogItem = dialogItems[1 + i * 2 + 1];
    int len = (int)strlen(dialogItem.Data);
    if (len > maxLen2)
      maxLen2 = len;
    dialogItem.X1 = maxLen + kSpace;
  }
  size = numLines + 6;
  xSize = maxLen + kSpace + maxLen2 + 5;
  FarDialogItem &firstDialogItem = dialogItems.Front();
  firstDialogItem.Y2 = size - 2;
  firstDialogItem.X2 = xSize - 4;
  
  /* int askCode = */ g_StartupInfo.ShowDialog(xSize, size, NULL, &dialogItems.Front(), numDialogItems);
  return S_OK;
}

int CPlugin::ProcessKey(int key, unsigned int controlState)
{
  if (controlState == PKF_CONTROL && key == 'A')
  {
    HRESULT result = ShowAttributesWindow();
    if (result == S_OK)
      return TRUE;
    if (result == S_FALSE)
      return FALSE;
    throw "Error";
  }
  if ((controlState & PKF_ALT) != 0 && key == VK_F6)
  {
    UString folderPath;
    if (!NFile::NDirectory::GetOnlyDirPrefix(m_FileName, folderPath))
      return FALSE;
    PanelInfo panelInfo;
    g_StartupInfo.ControlGetActivePanelInfo(panelInfo);
    GetFilesReal(panelInfo.SelectedItems,
        panelInfo.SelectedItemsNumber, FALSE,
        UnicodeStringToMultiByte(folderPath, CP_OEMCP), OPM_SILENT, true);
    g_StartupInfo.Control(this, FCTL_UPDATEPANEL, NULL);
    g_StartupInfo.Control(this, FCTL_REDRAWPANEL, NULL);
    g_StartupInfo.Control(this, FCTL_UPDATEANOTHERPANEL, NULL);
    g_StartupInfo.Control(this, FCTL_REDRAWANOTHERPANEL, NULL);
    return TRUE;
  }

  return FALSE;
}
<file_sep>/FingerSuite/FingerMenuDLL/InterceptEngine.h
#ifndef _INTERCEPT_ENGINE_H_
#define _INTERCEPT_ENGINE_H_

//Redefinitions for some CE internal structures and undocumented APIs
#include "hook\SysDecls.h" 

#define UWM_INTERCEPT_MENU_MSG             _T("UWM_INTERCEPT_MENU_MSG-44E531B1_14D3_11d5_A025_006067718D04")
#define UWM_INTERCEPT_MSGBOX_MSG           _T("UWM_INTERCEPT_MSGBOX_MSG-44E531B1_14D3_11d5_A025_006067718D04")
#define UWM_INTERCEPT_NOTIF_MSG            _T("UWM_INTERCEPT_NOTIF_MSG-44E531B1_14D3_11d5_A025_006067718D04")
#define UWM_NOTIF_POPUP_MSG                _T("UWM_NOTIF_POPUP_MSG-44E531B1_14D3_11d5_A025_006067718D04")
#define EVT_FNGRMENU                       _T("FNGRMENUWAITEVT")
#define EVT_FNGRMSGBOX                     _T("FNGRMSGBOXWAITEVT")

#define NOTIF_ADD   1
#define NOTIF_UPD   2
#define NOTIF_DEL   3


/*
struct HookedAPI holds information for one system API, 
which is hooked by us.
*/
struct HookedAPI
{
    BOOL    m_bUsed;
    BOOL    m_bSwapped;
    int     m_iOrigApiSetId;
    CINFO * m_pOrigApiSet;
    CINFO * m_pOurApiSet;
};

struct ProcessInfo
{
    DWORD          dwID;
    DWORD          dwTrust;
    
    HINSTANCE      hSpyDllLoaded;
    WCHAR          szExeFile[_MAX_PATH];  //Points into array m_szExeFile
};

typedef struct tagTRACKPOPUPMENUINFO
{
    HMENU       hMenu;
    UINT        uFlags;
    HWND        hWnd;
} TRACKPOPUPMENUINFO, *LPTRACKPOPUPMENUINFO;

typedef struct tagMSGBOXINFO
{
	HWND        hWnd;
	UINT        uType;
	WCHAR       szCaption[128];
	WCHAR       szText[1024];
} MSGBOXINFO, *LPMSGBOXINFO;

typedef struct tagNOTIFICATIONINFO
{
	SHNOTIFICATIONDATA nd;
	WCHAR szTitle[256];
	WCHAR szHTML[512];
	SOFTKEYCMD rgskc[30];
	WCHAR sk1Title[50];
	WCHAR sk2Title[50];
	DWORD grfFlagsOriginal;
	BOOL isManaged;
} NOTIFICATIONINFO, *LPNOTIFICATIONINFO;

#define MANAGED_NOTIF_SIZE 7

WCHAR g_szManagedNotificationCLSID[MANAGED_NOTIF_SIZE][39] = 
			{
				L"{a877d65b-239c-47a7-9304-0d347f580408}", // new text message
				L"{a877d660-239c-47a7-9304-0d347f580408}", // missed call
				L"{f528c2e3-17da-4248-88dd-38c4cdcf0d20}", // customer experience
				L"{15f11f90-8a5f-454c-89fc-ba9b7aab0cad}", // reminder
				L"{a877d663-239c-47a7-9304-0d347f580408}",  // main battery very low
				L"{1ee011d2-f265-4214-a4ed-f0ea2e827f2a}",  // bluetooth utiliry
				L"{0d3132c4-1298-469c-b2b8-f28ce2d649d0}"  // bluetooth 1
			};


extern "C" __declspec(dllexport) BOOL SetHWndServer(HWND hWndServer);
extern "C" __declspec(dllexport) BOOL SetHWndServerMsgBox(HWND hWndServer);
extern "C" __declspec(dllexport) BOOL StartHookOnServer();
extern "C" __declspec(dllexport) BOOL StartHookOnShellServer();
extern "C" __declspec(dllexport) BOOL StopHookOnServer();
extern "C" __declspec(dllexport) BOOL InstallHook();
extern "C" __declspec(dllexport) BOOL InstallHookOnShell();
extern "C" __declspec(dllexport) BOOL RemoveHook();
extern "C" __declspec(dllexport) BOOL SignalWaitEvent(LPTSTR szEvt);
extern "C" __declspec(dllexport) void SetTrackPopupMenuExResult(int bResult);
extern "C" __declspec(dllexport) void SetMsgBoxResult(int iResult);

extern "C" __declspec(dllexport) BOOL SetHWndServerNotif(HWND hWndServer);

extern "C" __declspec(dllexport) BOOL StartHookOnSIP();
extern "C" __declspec(dllexport) BOOL StopHookOnSIP();
extern "C" __declspec(dllexport) BOOL InstallHookOnSIP();

extern "C" __declspec(dllexport) BOOL StartHookOnHHTaskBar();
extern "C" __declspec(dllexport) BOOL InstallHookOnHHTaskBar();

extern "C" __declspec(dllexport) BOOL IsManagedNotification(REFCLSID clsid);


#endif // _INTERCEPT_ENGINE_H_<file_sep>/7-Zip/CPP/7zip/Archive/CpioHandler.cpp
// CpioHandler.cpp

#include "StdAfx.h"

#include "Common/ComTry.h"
#include "Common/StringToInt.h"
#include "Common/StringConvert.h"

#include "Windows/PropVariant.h"
#include "Windows/Time.h"

#include "../Common/LimitedStreams.h"
#include "../Common/ProgressUtils.h"
#include "../Common/RegisterArc.h"
#include "../Common/StreamUtils.h"

#include "../Compress/CopyCoder.h"

#include "Common/ItemNameUtils.h"

namespace NArchive {
namespace NCpio {

namespace NFileHeader
{
  namespace NMagic
  {
    extern const char *kMagic1 = "070701";
    extern const char *kMagic2 = "070702";
    extern const char *kMagic3 = "070707";
    extern const char *kEndName = "TRAILER!!!";

    const Byte kMagicForRecord2[2] = { 0xC7, 0x71 };
  }

  const UInt32 kRecord2Size = 26;
  /*
  struct CRecord2
  {
    unsigned short c_magic;
    short c_dev;
    unsigned short c_ino;
    unsigned short c_mode;
    unsigned short c_uid;
    unsigned short c_gid;
    unsigned short c_nlink;
    short c_rdev;
    unsigned short c_mtimes[2];
    unsigned short c_namesize;
    unsigned short c_filesizes[2];
  };
  */
 
  const UInt32 kRecordSize = 110;
  /*
  struct CRecord
  {
    char Magic[6];  // "070701" for "new" portable format, "070702" for CRC format
    char inode[8];
    char Mode[8];
    char UID[8];
    char GID[8];
    char nlink[8];
    char mtime[8];
    char Size[8]; // must be 0 for FIFOs and directories
    char DevMajor[8];
    char DevMinor[8];
    char RDevMajor[8];  //only valid for chr and blk special files
    char RDevMinor[8];  //only valid for chr and blk special files
    char NameSize[8]; // count includes terminating NUL in pathname
    char ChkSum[8];  // 0 for "new" portable format; for CRC format the sum of all the bytes in the file
    bool CheckMagic() const
    { return memcmp(Magic, NMagic::kMagic1, 6) == 0 ||
             memcmp(Magic, NMagic::kMagic2, 6) == 0; };
  };
  */

  const UInt32 kOctRecordSize = 76;
 
}

struct CItem
{
  AString Name;
  UInt32 inode;
  UInt32 Mode;
  UInt32 UID;
  UInt32 GID;
  UInt32 Size;
  UInt32 MTime;

  // char LinkFlag;
  // AString LinkName; ?????
  char Magic[8];
  UInt32 NumLinks;
  UInt32 DevMajor;
  UInt32 DevMinor;
  UInt32 RDevMajor;
  UInt32 RDevMinor;
  UInt32 ChkSum;

  UInt32 Align;

  bool IsDir() const { return (Mode & 0170000) == 0040000; }
};

class CItemEx: public CItem
{
public:
  UInt64 HeaderPosition;
  UInt32 HeaderSize;
  UInt64 GetDataPosition() const { return HeaderPosition + HeaderSize; };
};

const UInt32 kMaxBlockSize = NFileHeader::kRecordSize;

class CInArchive
{
  CMyComPtr<IInStream> m_Stream;
  UInt64 m_Position;

  UInt16 _blockSize;
  Byte _block[kMaxBlockSize];
  UInt32 _blockPos;
  Byte ReadByte();
  UInt16 ReadUInt16();
  UInt32 ReadUInt32();
  
  bool ReadNumber(UInt32 &resultValue);
  bool ReadOctNumber(int size, UInt32 &resultValue);

  HRESULT ReadBytes(void *data, UInt32 size, UInt32 &processedSize);
public:
  HRESULT Open(IInStream *inStream);
  HRESULT GetNextItem(bool &filled, CItemEx &itemInfo);
  HRESULT Skip(UInt64 numBytes);
  HRESULT SkipDataRecords(UInt64 dataSize, UInt32 align);
};

HRESULT CInArchive::ReadBytes(void *data, UInt32 size, UInt32 &processedSize)
{
  size_t realProcessedSize = size;
  RINOK(ReadStream(m_Stream, data, &realProcessedSize));
  processedSize = (UInt32)realProcessedSize;
  m_Position += processedSize;
  return S_OK;
}

Byte CInArchive::ReadByte()
{
  if (_blockPos >= _blockSize)
    throw "Incorrect cpio archive";
  return _block[_blockPos++];
}

UInt16 CInArchive::ReadUInt16()
{
  UInt16 value = 0;
  for (int i = 0; i < 2; i++)
  {
    Byte b = ReadByte();
    value |= (UInt16(b) << (8 * i));
  }
  return value;
}

UInt32 CInArchive::ReadUInt32()
{
  UInt32 value = 0;
  for (int i = 0; i < 4; i++)
  {
    Byte b = ReadByte();
    value |= (UInt32(b) << (8 * i));
  }
  return value;
}

HRESULT CInArchive::Open(IInStream *inStream)
{
  RINOK(inStream->Seek(0, STREAM_SEEK_CUR, &m_Position));
  m_Stream = inStream;
  return S_OK;
}

bool CInArchive::ReadNumber(UInt32 &resultValue)
{
  resultValue = 0;
  for (int i = 0; i < 8; i++)
  {
    char c = char(ReadByte());
    int d;
    if (c >= '0' && c <= '9')
      d = c - '0';
    else if (c >= 'A' && c <= 'F')
      d = 10 + c - 'A';
    else if (c >= 'a' && c <= 'f')
      d = 10 + c - 'a';
    else
      return false;
    resultValue *= 0x10;
    resultValue += d;
  }
  return true;
}

static bool OctalToNumber(const char *s, UInt64 &res)
{
  const char *end;
  res = ConvertOctStringToUInt64(s, &end);
  return (*end == ' ' || *end == 0);
}

static bool OctalToNumber32(const char *s, UInt32 &res)
{
  UInt64 res64;
  if (!OctalToNumber(s, res64))
    return false;
  res = (UInt32)res64;
  return (res64 <= 0xFFFFFFFF);
}

bool CInArchive::ReadOctNumber(int size, UInt32 &resultValue)
{
  char sz[32 + 4];
  int i;
  for (i = 0; i < size && i < 32; i++)
    sz[i] = (char)ReadByte();
  sz[i] = 0;
  return OctalToNumber32(sz, resultValue);
}

#define GetFromHex(y) { if (!ReadNumber(y)) return S_FALSE; }
#define GetFromOct6(y) { if (!ReadOctNumber(6, y)) return S_FALSE; }
#define GetFromOct11(y) { if (!ReadOctNumber(11, y)) return S_FALSE; }

static unsigned short ConvertValue(unsigned short value, bool convert)
{
  if (!convert)
    return value;
  return (unsigned short)((((unsigned short)(value & 0xFF)) << 8) | (value >> 8));
}

static UInt32 GetAlignedSize(UInt32 size, UInt32 align)
{
  while ((size & (align - 1)) != 0)
    size++;
  return size;
}


HRESULT CInArchive::GetNextItem(bool &filled, CItemEx &item)
{
  filled = false;

  UInt32 processedSize;
  item.HeaderPosition = m_Position;

  _blockSize = kMaxBlockSize;
  RINOK(ReadBytes(_block, 2, processedSize));
  if (processedSize != 2)
    return S_FALSE;
  _blockPos = 0;

  UInt32 nameSize;

  bool oldBE =
    _block[0] == NFileHeader::NMagic::kMagicForRecord2[1] &&
    _block[1] == NFileHeader::NMagic::kMagicForRecord2[0];

  bool binMode = (_block[0] == NFileHeader::NMagic::kMagicForRecord2[0] &&
    _block[1] == NFileHeader::NMagic::kMagicForRecord2[1]) ||
    oldBE;

  if (binMode)
  {
    RINOK(ReadBytes(_block + 2, NFileHeader::kRecord2Size - 2, processedSize));
    if (processedSize != NFileHeader::kRecord2Size - 2)
      return S_FALSE;
    item.Align = 2;
    _blockPos = 2;
    item.DevMajor = 0;
    item.DevMinor = ConvertValue(ReadUInt16(), oldBE);
    item.inode = ConvertValue(ReadUInt16(), oldBE);
    item.Mode = ConvertValue(ReadUInt16(), oldBE);
    item.UID = ConvertValue(ReadUInt16(), oldBE);
    item.GID = ConvertValue(ReadUInt16(), oldBE);
    item.NumLinks = ConvertValue(ReadUInt16(), oldBE);
    item.RDevMajor =0;
    item.RDevMinor = ConvertValue(ReadUInt16(), oldBE);
    UInt16 timeHigh = ConvertValue(ReadUInt16(), oldBE);
    UInt16 timeLow = ConvertValue(ReadUInt16(), oldBE);
    item.MTime = (UInt32(timeHigh) << 16) + timeLow;
    nameSize = ConvertValue(ReadUInt16(), oldBE);
    UInt16 sizeHigh = ConvertValue(ReadUInt16(), oldBE);
    UInt16 sizeLow = ConvertValue(ReadUInt16(), oldBE);
    item.Size = (UInt32(sizeHigh) << 16) + sizeLow;

    item.ChkSum = 0;
    item.HeaderSize = GetAlignedSize(
        nameSize + NFileHeader::kRecord2Size, item.Align);
    nameSize = item.HeaderSize - NFileHeader::kRecord2Size;
  }
  else
  {
    RINOK(ReadBytes(_block + 2, 4, processedSize));
    if (processedSize != 4)
      return S_FALSE;

    bool magicOK =
        memcmp(_block, NFileHeader::NMagic::kMagic1, 6) == 0 ||
        memcmp(_block, NFileHeader::NMagic::kMagic2, 6) == 0;
    _blockPos = 6;
    if (magicOK)
    {
      RINOK(ReadBytes(_block + 6, NFileHeader::kRecordSize - 6, processedSize));
      if (processedSize != NFileHeader::kRecordSize - 6)
        return S_FALSE;
      item.Align = 4;

      GetFromHex(item.inode);
      GetFromHex(item.Mode);
      GetFromHex(item.UID);
      GetFromHex(item.GID);
      GetFromHex(item.NumLinks);
      UInt32 mTime;
      GetFromHex(mTime);
      item.MTime = mTime;
      GetFromHex(item.Size);
      GetFromHex(item.DevMajor);
      GetFromHex(item.DevMinor);
      GetFromHex(item.RDevMajor);
      GetFromHex(item.RDevMinor);
      GetFromHex(nameSize);
      GetFromHex(item.ChkSum);
      item.HeaderSize = GetAlignedSize(
          nameSize + NFileHeader::kRecordSize, item.Align);
      nameSize = item.HeaderSize - NFileHeader::kRecordSize;
    }
    else
    {
      if (!memcmp(_block, NFileHeader::NMagic::kMagic3, 6) == 0)
        return S_FALSE;
      RINOK(ReadBytes(_block + 6, NFileHeader::kOctRecordSize - 6, processedSize));
      if (processedSize != NFileHeader::kOctRecordSize - 6)
        return S_FALSE;
      item.Align = 1;
      item.DevMajor = 0;
      GetFromOct6(item.DevMinor);
      GetFromOct6(item.inode);
      GetFromOct6(item.Mode);
      GetFromOct6(item.UID);
      GetFromOct6(item.GID);
      GetFromOct6(item.NumLinks);
      item.RDevMajor = 0;
      GetFromOct6(item.RDevMinor);
      UInt32 mTime;
      GetFromOct11(mTime);
      item.MTime = mTime;
      GetFromOct6(nameSize);
      GetFromOct11(item.Size);  // ?????
      item.HeaderSize = GetAlignedSize(
          nameSize + NFileHeader::kOctRecordSize, item.Align);
      nameSize = item.HeaderSize - NFileHeader::kOctRecordSize;
    }
  }
  if (nameSize == 0 || nameSize >= (1 << 27))
    return E_FAIL;
  RINOK(ReadBytes(item.Name.GetBuffer(nameSize), nameSize, processedSize));
  if (processedSize != nameSize)
    return E_FAIL;
  item.Name.ReleaseBuffer();
  if (strcmp(item.Name, NFileHeader::NMagic::kEndName) == 0)
    return S_OK;
  filled = true;
  return S_OK;
}

HRESULT CInArchive::Skip(UInt64 numBytes)
{
  UInt64 newPostion;
  RINOK(m_Stream->Seek(numBytes, STREAM_SEEK_CUR, &newPostion));
  m_Position += numBytes;
  if (m_Position != newPostion)
    return E_FAIL;
  return S_OK;
}

HRESULT CInArchive::SkipDataRecords(UInt64 dataSize, UInt32 align)
{
  while ((dataSize & (align - 1)) != 0)
    dataSize++;
  return Skip(dataSize);
}


class CHandler:
  public IInArchive,
  public IInArchiveGetStream,
  public CMyUnknownImp
{
  CObjectVector<CItemEx> _items;
  CMyComPtr<IInStream> _stream;
public:
  MY_UNKNOWN_IMP2(IInArchive, IInArchiveGetStream)
  INTERFACE_IInArchive(;)
  STDMETHOD(GetStream)(UInt32 index, ISequentialInStream **stream);
};

/*
enum
{
  kpidinode = kpidUserDefined,
  kpidiChkSum
};
*/

STATPROPSTG kProps[] =
{
  { NULL, kpidPath, VT_BSTR},
  { NULL, kpidIsDir, VT_BOOL},
  { NULL, kpidSize, VT_UI8},
  { NULL, kpidPackSize, VT_UI8},
  { NULL, kpidMTime, VT_FILETIME},
  { NULL, kpidPosixAttrib, VT_UI4},
  // { L"inode", kpidinode, VT_UI4}
  // { L"CheckSum", kpidiChkSum, VT_UI4}
};

IMP_IInArchive_Props
IMP_IInArchive_ArcProps_NO

STDMETHODIMP CHandler::Open(IInStream *stream, const UInt64 *, IArchiveOpenCallback *callback)
{
  COM_TRY_BEGIN
  // try
  {
    CInArchive archive;

    UInt64 endPos = 0;
    bool needSetTotal = true;

    if (callback != NULL)
    {
      RINOK(stream->Seek(0, STREAM_SEEK_END, &endPos));
      RINOK(stream->Seek(0, STREAM_SEEK_SET, NULL));
    }

    RINOK(archive.Open(stream));

    _items.Clear();

    for (;;)
    {
      CItemEx item;
      bool filled;
      HRESULT result = archive.GetNextItem(filled, item);
      if (result == S_FALSE)
        return S_FALSE;
      if (result != S_OK)
        return S_FALSE;
      if (!filled)
        break;
      _items.Add(item);
      archive.SkipDataRecords(item.Size, item.Align);
      if (callback != NULL)
      {
        if (needSetTotal)
        {
          RINOK(callback->SetTotal(NULL, &endPos));
          needSetTotal = false;
        }
        if (_items.Size() % 100 == 0)
        {
          UInt64 numFiles = _items.Size();
          UInt64 numBytes = item.HeaderPosition;
          RINOK(callback->SetCompleted(&numFiles, &numBytes));
        }
      }
    }
    if (_items.Size() == 0)
      return S_FALSE;

    _stream = stream;
  }
  /*
  catch(...)
  {
    return S_FALSE;
  }
  */
  return S_OK;
  COM_TRY_END
}

STDMETHODIMP CHandler::Close()
{
  _items.Clear();
  _stream.Release();
  return S_OK;
}

STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
{
  *numItems = _items.Size();
  return S_OK;
}

STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
{
  COM_TRY_BEGIN
  NWindows::NCOM::CPropVariant prop;
  const CItemEx &item = _items[index];

  switch(propID)
  {
    case kpidPath: prop = NItemName::GetOSName(MultiByteToUnicodeString(item.Name, CP_OEMCP)); break;
    case kpidIsDir: prop = item.IsDir(); break;
    case kpidSize:
    case kpidPackSize:
      prop = (UInt64)item.Size;
      break;
    case kpidMTime:
    {
      if (item.MTime != 0)
      {
        FILETIME utc;
        NWindows::NTime::UnixTimeToFileTime(item.MTime, utc);
        prop = utc;
      }
      break;
    }
    case kpidPosixAttrib: prop = item.Mode; break;
    /*
    case kpidinode:  prop = item.inode; break;
    case kpidiChkSum:  prop = item.ChkSum; break;
    */
  }
  prop.Detach(value);
  return S_OK;
  COM_TRY_END
}

STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
    Int32 testMode, IArchiveExtractCallback *extractCallback)
{
  COM_TRY_BEGIN
  bool allFilesMode = (numItems == (UInt32)-1);
  if (allFilesMode)
    numItems = _items.Size();
  if (numItems == 0)
    return S_OK;
  UInt64 totalSize = 0;
  UInt32 i;
  for (i = 0; i < numItems; i++)
    totalSize += _items[allFilesMode ? i : indices[i]].Size;
  extractCallback->SetTotal(totalSize);

  UInt64 currentTotalSize = 0;
  
  NCompress::CCopyCoder *copyCoderSpec = new NCompress::CCopyCoder();
  CMyComPtr<ICompressCoder> copyCoder = copyCoderSpec;

  CLocalProgress *lps = new CLocalProgress;
  CMyComPtr<ICompressProgressInfo> progress = lps;
  lps->Init(extractCallback, false);

  CLimitedSequentialInStream *streamSpec = new CLimitedSequentialInStream;
  CMyComPtr<ISequentialInStream> inStream(streamSpec);
  streamSpec->SetStream(_stream);

  for (i = 0; i < numItems; i++)
  {
    lps->InSize = lps->OutSize = currentTotalSize;
    RINOK(lps->SetCur());
    CMyComPtr<ISequentialOutStream> outStream;
    Int32 askMode = testMode ?
        NExtract::NAskMode::kTest :
        NExtract::NAskMode::kExtract;
    Int32 index = allFilesMode ? i : indices[i];
    const CItemEx &item = _items[index];
    RINOK(extractCallback->GetStream(index, &outStream, askMode));
    currentTotalSize += item.Size;
    if (item.IsDir())
    {
      RINOK(extractCallback->PrepareOperation(askMode));
      RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kOK));
      continue;
    }
    if (!testMode && !outStream)
      continue;
    RINOK(extractCallback->PrepareOperation(askMode));
    if (testMode)
    {
      RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kOK));
      continue;
    }
    RINOK(_stream->Seek(item.GetDataPosition(), STREAM_SEEK_SET, NULL));
    streamSpec->Init(item.Size);
    RINOK(copyCoder->Code(inStream, outStream, NULL, NULL, progress));
    outStream.Release();
    RINOK(extractCallback->SetOperationResult((copyCoderSpec->TotalSize == item.Size) ?
        NExtract::NOperationResult::kOK:
        NExtract::NOperationResult::kDataError));
  }
  return S_OK;
  COM_TRY_END
}

STDMETHODIMP CHandler::GetStream(UInt32 index, ISequentialInStream **stream)
{
  COM_TRY_BEGIN
  const CItemEx &item = _items[index];
  return CreateLimitedInStream(_stream, item.GetDataPosition(), item.Size, stream);
  COM_TRY_END
}

static IInArchive *CreateArc() { return new NArchive::NCpio::CHandler; }

static CArcInfo g_ArcInfo =
  { L"Cpio", L"cpio", 0, 0xED, { 0 }, 0, false, CreateArc, 0 };

REGISTER_ARC(Cpio)

}}
<file_sep>/SQLCEHelper/Source/DbMemory.cpp

#include "stdafx.h"

using namespace OLEDBCLI;


// CDbMemory::Free(DBPROP* pProp)
//
//		Frees a single DBPROP value
//
void CDbMemory::Free(DBPROP* pProp)
{
	ATLASSERT(pProp != NULL);

	VariantClear(&pProp->vValue);
	Free(pProp->colid);
}


// CDbMemory::Free
//
//		Frees a provider-allocated DBPROPSET
//
void CDbMemory::Free(DBPROPSET* pPropSet)
{
	ULONG iProp;

	ATLASSERT(pPropSet != NULL);

	for(iProp = 0; iProp < pPropSet->cProperties; ++iProp)
		Free(&pPropSet->rgProperties[iProp]);

	if(pPropSet->rgProperties != NULL)
		CoTaskMemFree(pPropSet->rgProperties);
}


void CDbMemory::Free(DBID &dbid)
{
	switch(dbid.eKind)
	{
	case DBKIND_GUID_NAME:
		if(dbid.uName.pwszName != NULL)
			CoTaskMemFree(dbid.uName.pwszName);
		break;

	case DBKIND_NAME:
		if(dbid.uName.pwszName != NULL)
			CoTaskMemFree(dbid.uName.pwszName);
		break;

	case DBKIND_PGUID_NAME:
		if(dbid.uName.pwszName != NULL)
			CoTaskMemFree(dbid.uName.pwszName);
		if(dbid.uGuid.pguid != NULL)
			CoTaskMemFree(dbid.uGuid.pguid);
		break;

	case DBKIND_PGUID_PROPID:
		if(dbid.uGuid.pguid != NULL)
			CoTaskMemFree(dbid.uGuid.pguid);
		break;

	}
}


void CDbMemory::Free(DBINDEXCOLUMNDESC *pKeyColumnDesc, ULONG nKeys)
{
	ULONG	i;

	for(i = 0; i < nKeys; ++i)
		Free(*pKeyColumnDesc[i].pColumnID);
	CoTaskMemFree(pKeyColumnDesc);
}
<file_sep>/7-Zip/CPP/7zip/Archive/Rar/RarHandler.cpp
// RarHandler.cpp

#include "StdAfx.h"

#include "Common/ComTry.h"
#include "Common/IntToString.h"
#include "Common/StringConvert.h"

#include "Windows/PropVariant.h"
#include "Windows/Time.h"

#include "../../IPassword.h"

#include "../../Common/CreateCoder.h"
#include "../../Common/FilterCoder.h"
#include "../../Common/MethodId.h"
#include "../../Common/ProgressUtils.h"

#include "../../Compress/CopyCoder.h"

#include "../../Crypto/Rar20Crypto.h"
#include "../../Crypto/RarAes.h"

#include "../Common/ItemNameUtils.h"
#include "../Common/OutStreamWithCRC.h"

#include "RarHandler.h"

using namespace NWindows;
using namespace NTime;

namespace NArchive {
namespace NRar {

static const wchar_t *kHostOS[] =
{
  L"MS DOS",
  L"OS/2",
  L"Win32",
  L"Unix",
  L"Mac OS",
  L"BeOS"
};

static const int kNumHostOSes = sizeof(kHostOS) / sizeof(kHostOS[0]);

static const wchar_t *kUnknownOS = L"Unknown";

STATPROPSTG kProps[] =
{
  { NULL, kpidPath, VT_BSTR},
  { NULL, kpidIsDir, VT_BOOL},
  { NULL, kpidSize, VT_UI8},
  { NULL, kpidPackSize, VT_UI8},
  { NULL, kpidMTime, VT_FILETIME},
  { NULL, kpidCTime, VT_FILETIME},
  { NULL, kpidATime, VT_FILETIME},
  { NULL, kpidAttrib, VT_UI4},

  { NULL, kpidEncrypted, VT_BOOL},
  { NULL, kpidSolid, VT_BOOL},
  { NULL, kpidCommented, VT_BOOL},
  { NULL, kpidSplitBefore, VT_BOOL},
  { NULL, kpidSplitAfter, VT_BOOL},
  { NULL, kpidCRC, VT_UI4},
  { NULL, kpidHostOS, VT_BSTR},
  { NULL, kpidMethod, VT_BSTR},
  { NULL, kpidUnpackVer, VT_UI1}
};

STATPROPSTG kArcProps[] =
{
  { NULL, kpidSolid, VT_BOOL},
  { NULL, kpidNumBlocks, VT_UI4},
  // { NULL, kpidEncrypted, VT_BOOL},
  { NULL, kpidIsVolume, VT_BOOL},
  { NULL, kpidNumVolumes, VT_UI4},
  { NULL, kpidPhySize, VT_UI8}
  // { NULL, kpidCommented, VT_BOOL}
};

IMP_IInArchive_Props
IMP_IInArchive_ArcProps

UInt64 CHandler::GetPackSize(int refIndex) const
{
  const CRefItem &refItem = _refItems[refIndex];
  UInt64 totalPackSize = 0;
  for (int i = 0; i < refItem.NumItems; i++)
    totalPackSize += _items[refItem.ItemIndex + i].PackSize;
  return totalPackSize;
}

STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
{
  // COM_TRY_BEGIN
  NWindows::NCOM::CPropVariant prop;
  switch(propID)
  {
    case kpidSolid: prop = _archiveInfo.IsSolid(); break;
    // case kpidEncrypted: prop = _archiveInfo.IsEncrypted(); break; // it's for encrypted names.
    case kpidIsVolume: prop = _archiveInfo.IsVolume(); break;
    case kpidNumVolumes: prop = (UInt32)_archives.Size(); break;
    case kpidOffset: if (_archiveInfo.StartPosition != 0) prop = _archiveInfo.StartPosition; break;
    // case kpidCommented: prop = _archiveInfo.IsCommented(); break;
    case kpidNumBlocks:
    {
      UInt32 numBlocks = 0;
      for (int i = 0; i < _refItems.Size(); i++)
        if (!IsSolid(i))
          numBlocks++;
      prop = (UInt32)numBlocks;
      break;
    }
  }
  prop.Detach(value);
  return S_OK;
  // COM_TRY_END
}

STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
{
  *numItems = _refItems.Size();
  return S_OK;
}

static bool RarTimeToFileTime(const CRarTime &rarTime, FILETIME &result)
{
  if (!DosTimeToFileTime(rarTime.DosTime, result))
    return false;
  UInt64 value =  (((UInt64)result.dwHighDateTime) << 32) + result.dwLowDateTime;
  value += (UInt64)rarTime.LowSecond * 10000000;
  value += ((UInt64)rarTime.SubTime[2] << 16) +
    ((UInt64)rarTime.SubTime[1] << 8) +
    ((UInt64)rarTime.SubTime[0]);
  result.dwLowDateTime = (DWORD)value;
  result.dwHighDateTime = DWORD(value >> 32);
  return true;
}

static void RarTimeToProp(const CRarTime &rarTime, NWindows::NCOM::CPropVariant &prop)
{
  FILETIME localFileTime, utcFileTime;
  if (RarTimeToFileTime(rarTime, localFileTime))
  {
    if (!LocalFileTimeToFileTime(&localFileTime, &utcFileTime))
      utcFileTime.dwHighDateTime = utcFileTime.dwLowDateTime = 0;
  }
  else
    utcFileTime.dwHighDateTime = utcFileTime.dwLowDateTime = 0;
  prop = utcFileTime;
}

STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID,  PROPVARIANT *value)
{
  COM_TRY_BEGIN
  NWindows::NCOM::CPropVariant prop;
  const CRefItem &refItem = _refItems[index];
  const CItemEx &item = _items[refItem.ItemIndex];
  switch(propID)
  {
    case kpidPath:
    {
      UString u;
      if (item.HasUnicodeName() && !item.UnicodeName.IsEmpty())
        u = item.UnicodeName;
      else
        u = MultiByteToUnicodeString(item.Name, CP_OEMCP);
      prop = (const wchar_t *)NItemName::WinNameToOSName(u);
      break;
    }
    case kpidIsDir: prop = item.IsDir(); break;
    case kpidSize: prop = item.Size; break;
    case kpidPackSize: prop = GetPackSize(index); break;
    case kpidMTime: RarTimeToProp(item.MTime, prop); break;
    case kpidCTime: if (item.CTimeDefined) RarTimeToProp(item.CTime, prop); break;
    case kpidATime: if (item.ATimeDefined) RarTimeToProp(item.ATime, prop); break;
    case kpidAttrib: prop = item.GetWinAttributes(); break;
    case kpidEncrypted: prop = item.IsEncrypted(); break;
    case kpidSolid: prop = IsSolid(index); break;
    case kpidCommented: prop = item.IsCommented(); break;
    case kpidSplitBefore: prop = item.IsSplitBefore(); break;
    case kpidSplitAfter: prop = _items[refItem.ItemIndex + refItem.NumItems - 1].IsSplitAfter(); break;
    case kpidCRC:
    {
      const CItemEx &lastItem = _items[refItem.ItemIndex + refItem.NumItems - 1];
      prop = ((lastItem.IsSplitAfter()) ? item.FileCRC : lastItem.FileCRC);
      break;
    }
    case kpidUnpackVer: prop = item.UnPackVersion; break;
    case kpidMethod:
    {
      UString method;
      if (item.Method >= Byte('0') && item.Method <= Byte('5'))
      {
        method = L"m";
        wchar_t temp[32];
        ConvertUInt64ToString(item.Method - Byte('0'), temp);
        method += temp;
        if (!item.IsDir())
        {
          method += L":";
          ConvertUInt64ToString(16 + item.GetDictSize(), temp);
          method += temp;
        }
      }
      else
      {
        wchar_t temp[32];
        ConvertUInt64ToString(item.Method, temp);
        method += temp;
      }
      prop = method;
      break;
    }
    case kpidHostOS: prop = (item.HostOS < kNumHostOSes) ? (kHostOS[item.HostOS]) : kUnknownOS; break;
  }
  prop.Detach(value);
  return S_OK;
  COM_TRY_END
}

class CVolumeName
{
  bool _first;
  bool _newStyle;
  UString _unchangedPart;
  UString _changedPart;
  UString _afterPart;
public:
  CVolumeName(): _newStyle(true) {};

  bool InitName(const UString &name, bool newStyle)
  {
    _first = true;
    _newStyle = newStyle;
    int dotPos = name.ReverseFind('.');
    UString basePart = name;
    if (dotPos >= 0)
    {
      UString ext = name.Mid(dotPos + 1);
      if (ext.CompareNoCase(L"rar") == 0)
      {
        _afterPart = name.Mid(dotPos);
        basePart = name.Left(dotPos);
      }
      else if (ext.CompareNoCase(L"exe") == 0)
      {
        _afterPart = L".rar";
        basePart = name.Left(dotPos);
      }
      else if (!_newStyle)
      {
        if (ext.CompareNoCase(L"000") == 0 ||
            ext.CompareNoCase(L"001") == 0 ||
            ext.CompareNoCase(L"r00") == 0 ||
            ext.CompareNoCase(L"r01") == 0)
        {
          _afterPart.Empty();
          _first = false;
          _changedPart = ext;
          _unchangedPart = name.Left(dotPos + 1);
          return true;
        }
      }
    }

    if (!_newStyle)
    {
      _afterPart.Empty();
      _unchangedPart = basePart + UString(L".");
      _changedPart = L"r00";
      return true;
    }

    int numLetters = 1;
    if (basePart.Right(numLetters) == L"1" || basePart.Right(numLetters) == L"0")
    {
      while (numLetters < basePart.Length())
      {
        if (basePart[basePart.Length() - numLetters - 1] != '0')
          break;
        numLetters++;
      }
    }
    else
      return false;
    _unchangedPart = basePart.Left(basePart.Length() - numLetters);
    _changedPart = basePart.Right(numLetters);
    return true;
  }

  UString GetNextName()
  {
    UString newName;
    if (_newStyle || !_first)
    {
      int i;
      int numLetters = _changedPart.Length();
      for (i = numLetters - 1; i >= 0; i--)
      {
        wchar_t c = _changedPart[i];
        if (c == L'9')
        {
          c = L'0';
          newName = c + newName;
          if (i == 0)
            newName = UString(L'1') + newName;
          continue;
        }
        c++;
        newName = UString(c) + newName;
        i--;
        for (; i >= 0; i--)
          newName = _changedPart[i] + newName;
        break;
      }
      _changedPart = newName;
    }
    _first = false;
    return _unchangedPart + _changedPart + _afterPart;
  }
};

HRESULT CHandler::Open2(IInStream *stream,
    const UInt64 *maxCheckStartPosition,
    IArchiveOpenCallback *openArchiveCallback)
{
  {
    CMyComPtr<IArchiveOpenVolumeCallback> openVolumeCallback;
    CMyComPtr<ICryptoGetTextPassword> getTextPassword;
    CMyComPtr<IArchiveOpenCallback> openArchiveCallbackWrap = openArchiveCallback;
    
    CVolumeName seqName;

    UInt64 totalBytes = 0;
    UInt64 curBytes = 0;

    if (openArchiveCallback != NULL)
    {
      openArchiveCallbackWrap.QueryInterface(IID_IArchiveOpenVolumeCallback, &openVolumeCallback);
      openArchiveCallbackWrap.QueryInterface(IID_ICryptoGetTextPassword, &getTextPassword);
    }

    for (;;)
    {
      CMyComPtr<IInStream> inStream;
      if (!_archives.IsEmpty())
      {
        if (!openVolumeCallback)
          break;
        
        if (_archives.Size() == 1)
        {
          if (!_archiveInfo.IsVolume())
            break;
          UString baseName;
          {
            NCOM::CPropVariant prop;
            RINOK(openVolumeCallback->GetProperty(kpidName, &prop));
            if (prop.vt != VT_BSTR)
              break;
            baseName = prop.bstrVal;
          }
          seqName.InitName(baseName, _archiveInfo.HaveNewVolumeName());
        }

        UString fullName = seqName.GetNextName();
        HRESULT result = openVolumeCallback->GetStream(fullName, &inStream);
        if (result == S_FALSE)
          break;
        if (result != S_OK)
          return result;
        if (!stream)
          break;
      }
      else
        inStream = stream;

      UInt64 endPos = 0;
      if (openArchiveCallback != NULL)
      {
        RINOK(stream->Seek(0, STREAM_SEEK_END, &endPos));
        RINOK(stream->Seek(0, STREAM_SEEK_SET, NULL));
        totalBytes += endPos;
        RINOK(openArchiveCallback->SetTotal(NULL, &totalBytes));
      }
      
      NArchive::NRar::CInArchive archive;
      RINOK(archive.Open(inStream, maxCheckStartPosition));

      if (_archives.IsEmpty())
        archive.GetArchiveInfo(_archiveInfo);
     
      CItemEx item;
      for (;;)
      {
        bool decryptionError;
        HRESULT result = archive.GetNextItem(item, getTextPassword, decryptionError);
        if (result == S_FALSE)
        {
          if (decryptionError && _items.IsEmpty())
            return S_FALSE;
          break;
        }
        RINOK(result);
        if (item.IgnoreItem())
          continue;

        bool needAdd = true;
        if (item.IsSplitBefore())
        {
          if (!_refItems.IsEmpty())
          {
            CRefItem &refItem = _refItems.Back();
            refItem.NumItems++;
            needAdd = false;
          }
        }
        if (needAdd)
        {
          CRefItem refItem;
          refItem.ItemIndex = _items.Size();
          refItem.NumItems = 1;
          refItem.VolumeIndex = _archives.Size();
          _refItems.Add(refItem);
        }
        _items.Add(item);
        if (openArchiveCallback != NULL && _items.Size() % 100 == 0)
        {
          UInt64 numFiles = _items.Size();
          UInt64 numBytes = curBytes + item.Position;
          RINOK(openArchiveCallback->SetCompleted(&numFiles, &numBytes));
        }
      }
      curBytes += endPos;
      _archives.Add(archive);
    }
  }
  return S_OK;
}

STDMETHODIMP CHandler::Open(IInStream *stream,
    const UInt64 *maxCheckStartPosition,
    IArchiveOpenCallback *openArchiveCallback)
{
  COM_TRY_BEGIN
  Close();
  try
  {
    HRESULT res = Open2(stream, maxCheckStartPosition, openArchiveCallback);
    if (res != S_OK)
      Close();
    return res;
  }
  catch(const CInArchiveException &) { Close(); return S_FALSE; }
  catch(...) { Close(); throw; }
  COM_TRY_END
}

STDMETHODIMP CHandler::Close()
{
  COM_TRY_BEGIN
  _refItems.Clear();
  _items.Clear();
  _archives.Clear();
  return S_OK;
  COM_TRY_END
}

struct CMethodItem
{
  Byte RarUnPackVersion;
  CMyComPtr<ICompressCoder> Coder;
};


STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
    Int32 testMode, IArchiveExtractCallback *extractCallback)
{
  COM_TRY_BEGIN
  CMyComPtr<ICryptoGetTextPassword> getTextPassword;
  UInt64 censoredTotalUnPacked = 0,
        // censoredTotalPacked = 0,
        importantTotalUnPacked = 0;
        // importantTotalPacked = 0;
  bool allFilesMode = (numItems == (UInt32)-1);
  if (allFilesMode)
    numItems = _refItems.Size();
  if (numItems == 0)
    return S_OK;
  int lastIndex = 0;
  CRecordVector<int> importantIndexes;
  CRecordVector<bool> extractStatuses;

  for (UInt32 t = 0; t < numItems; t++)
  {
    int index = allFilesMode ? t : indices[t];
    const CRefItem &refItem = _refItems[index];
    const CItemEx &item = _items[refItem.ItemIndex];
    censoredTotalUnPacked += item.Size;
    // censoredTotalPacked += item.PackSize;
    int j;
    for (j = lastIndex; j <= index; j++)
      // if (!_items[_refItems[j].ItemIndex].IsSolid())
      if (!IsSolid(j))
        lastIndex = j;
    for (j = lastIndex; j <= index; j++)
    {
      const CRefItem &refItem = _refItems[j];
      const CItemEx &item = _items[refItem.ItemIndex];

      // const CItemEx &item = _items[j];

      importantTotalUnPacked += item.Size;
      // importantTotalPacked += item.PackSize;
      importantIndexes.Add(j);
      extractStatuses.Add(j == index);
    }
    lastIndex = index + 1;
  }

  extractCallback->SetTotal(importantTotalUnPacked);
  UInt64 currentImportantTotalUnPacked = 0;
  UInt64 currentImportantTotalPacked = 0;
  UInt64 currentUnPackSize, currentPackSize;

  CObjectVector<CMethodItem> methodItems;

  NCompress::CCopyCoder *copyCoderSpec = new NCompress::CCopyCoder;
  CMyComPtr<ICompressCoder> copyCoder = copyCoderSpec;

  CFilterCoder *filterStreamSpec = new CFilterCoder;
  CMyComPtr<ISequentialInStream> filterStream = filterStreamSpec;

  NCrypto::NRar20::CDecoder *rar20CryptoDecoderSpec = NULL;
  CMyComPtr<ICompressFilter> rar20CryptoDecoder;
  NCrypto::NRar29::CDecoder *rar29CryptoDecoderSpec = NULL;
  CMyComPtr<ICompressFilter> rar29CryptoDecoder;

  CFolderInStream *folderInStreamSpec = NULL;
  CMyComPtr<ISequentialInStream> folderInStream;

  CLocalProgress *lps = new CLocalProgress;
  CMyComPtr<ICompressProgressInfo> progress = lps;
  lps->Init(extractCallback, false);

  bool solidStart = true;
  for (int i = 0; i < importantIndexes.Size(); i++,
      currentImportantTotalUnPacked += currentUnPackSize,
      currentImportantTotalPacked += currentPackSize)
  {
    lps->InSize = currentImportantTotalPacked;
    lps->OutSize = currentImportantTotalUnPacked;
    RINOK(lps->SetCur());
    CMyComPtr<ISequentialOutStream> realOutStream;

    Int32 askMode;
    if (extractStatuses[i])
      askMode = testMode ?
          NExtract::NAskMode::kTest :
          NExtract::NAskMode::kExtract;
    else
      askMode = NExtract::NAskMode::kSkip;

    UInt32 index = importantIndexes[i];

    const CRefItem &refItem = _refItems[index];
    const CItemEx &item = _items[refItem.ItemIndex];

    currentUnPackSize = item.Size;

    currentPackSize = GetPackSize(index);

    if (item.IgnoreItem())
      continue;

    RINOK(extractCallback->GetStream(index, &realOutStream, askMode));

    if (!IsSolid(index))
      solidStart = true;
    if (item.IsDir())
    {
      RINOK(extractCallback->PrepareOperation(askMode));
      RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kOK));
      continue;
    }

    bool mustBeProcessedAnywhere = false;
    if (i < importantIndexes.Size() - 1)
    {
      // const CRefItem &nextRefItem = _refItems[importantIndexes[i + 1]];
      // const CItemEx &nextItemInfo = _items[nextRefItem.ItemIndex];
      // mustBeProcessedAnywhere = nextItemInfo.IsSolid();
      mustBeProcessedAnywhere = IsSolid(importantIndexes[i + 1]);
    }
    
    if (!mustBeProcessedAnywhere && !testMode && !realOutStream)
      continue;
    
    if (!realOutStream && !testMode)
      askMode = NExtract::NAskMode::kSkip;

    RINOK(extractCallback->PrepareOperation(askMode));

    COutStreamWithCRC *outStreamSpec = new COutStreamWithCRC;
    CMyComPtr<ISequentialOutStream> outStream(outStreamSpec);
    outStreamSpec->SetStream(realOutStream);
    outStreamSpec->Init();
    realOutStream.Release();
    
    /*
    for (int partIndex = 0; partIndex < 1; partIndex++)
    {
    CMyComPtr<ISequentialInStream> inStream;

    // item redefinition
    const CItemEx &item = _items[refItem.ItemIndex + partIndex];

    NArchive::NRar::CInArchive &archive = _archives[refItem.VolumeIndex + partIndex];

    inStream.Attach(archive.CreateLimitedStream(item.GetDataPosition(),
      item.PackSize));
    */
    if (!folderInStream)
    {
      folderInStreamSpec = new CFolderInStream;
      folderInStream = folderInStreamSpec;
    }

    folderInStreamSpec->Init(&_archives, &_items, refItem);

    UInt64 packSize = currentPackSize;

    // packedPos += item.PackSize;
    // unpackedPos += 0;
    
    CMyComPtr<ISequentialInStream> inStream;
    if (item.IsEncrypted())
    {
      CMyComPtr<ICryptoSetPassword> cryptoSetPassword;
      if (item.UnPackVersion >= 29)
      {
        if (!rar29CryptoDecoder)
        {
          rar29CryptoDecoderSpec = new NCrypto::NRar29::CDecoder;
          rar29CryptoDecoder = rar29CryptoDecoderSpec;
          // RINOK(rar29CryptoDecoder.CoCreateInstance(CLSID_CCryptoRar29Decoder));
        }
        rar29CryptoDecoderSpec->SetRar350Mode(item.UnPackVersion < 36);
        CMyComPtr<ICompressSetDecoderProperties2> cryptoProperties;
        RINOK(rar29CryptoDecoder.QueryInterface(IID_ICompressSetDecoderProperties2,
            &cryptoProperties));
        RINOK(cryptoProperties->SetDecoderProperties2(item.Salt, item.HasSalt() ? sizeof(item.Salt) : 0));
        filterStreamSpec->Filter = rar29CryptoDecoder;
      }
      else if (item.UnPackVersion >= 20)
      {
        if (!rar20CryptoDecoder)
        {
          rar20CryptoDecoderSpec = new NCrypto::NRar20::CDecoder;
          rar20CryptoDecoder = rar20CryptoDecoderSpec;
          // RINOK(rar20CryptoDecoder.CoCreateInstance(CLSID_CCryptoRar20Decoder));
        }
        filterStreamSpec->Filter = rar20CryptoDecoder;
      }
      else
      {
        outStream.Release();
        RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kUnSupportedMethod));
        continue;
      }
      RINOK(filterStreamSpec->Filter.QueryInterface(IID_ICryptoSetPassword,
          &cryptoSetPassword));

      if (!getTextPassword)
        extractCallback->QueryInterface(IID_ICryptoGetTextPassword, (void **)&getTextPassword);
      if (getTextPassword)
      {
        CMyComBSTR password;
        RINOK(getTextPassword->CryptoGetTextPassword(&password));
        if (item.UnPackVersion >= 29)
        {
          CByteBuffer buffer;
          UString unicodePassword(password);
          const UInt32 sizeInBytes = unicodePassword.Length() * 2;
          buffer.SetCapacity(sizeInBytes);
          for (int i = 0; i < unicodePassword.Length(); i++)
          {
            wchar_t c = unicodePassword[i];
            ((Byte *)buffer)[i * 2] = (Byte)c;
            ((Byte *)buffer)[i * 2 + 1] = (Byte)(c >> 8);
          }
          RINOK(cryptoSetPassword->CryptoSetPassword(
            (const Byte *)buffer, sizeInBytes));
        }
        else
        {
          AString oemPassword = UnicodeStringToMultiByte(
            (const wchar_t *)password, CP_OEMCP);
          RINOK(cryptoSetPassword->CryptoSetPassword(
            (const Byte *)(const char *)oemPassword, oemPassword.Length()));
        }
      }
      else
      {
        RINOK(cryptoSetPassword->CryptoSetPassword(0, 0));
      }
      filterStreamSpec->SetInStream(folderInStream);
      inStream = filterStream;
    }
    else
    {
      inStream = folderInStream;
    }
    CMyComPtr<ICompressCoder> commonCoder;
    switch(item.Method)
    {
      case '0':
      {
        commonCoder = copyCoder;
        break;
      }
      case '1':
      case '2':
      case '3':
      case '4':
      case '5':
      {
        /*
        if (item.UnPackVersion >= 29)
        {
          outStream.Release();
          RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kUnSupportedMethod));
          continue;
        }
        */
        int m;
        for (m = 0; m < methodItems.Size(); m++)
          if (methodItems[m].RarUnPackVersion == item.UnPackVersion)
            break;
        if (m == methodItems.Size())
        {
          CMethodItem mi;
          mi.RarUnPackVersion = item.UnPackVersion;

          mi.Coder.Release();
          if (item.UnPackVersion <= 30)
          {
            UInt32 methodID = 0x040300;
            if (item.UnPackVersion < 20)
              methodID += 1;
            else if (item.UnPackVersion < 29)
              methodID += 2;
            else
              methodID += 3;
            RINOK(CreateCoder(EXTERNAL_CODECS_VARS methodID, mi.Coder, false));
          }
         
          if (mi.Coder == 0)
          {
            outStream.Release();
            RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kUnSupportedMethod));
            continue;
          }

          m = methodItems.Add(mi);
        }
        CMyComPtr<ICompressCoder> decoder = methodItems[m].Coder;

        CMyComPtr<ICompressSetDecoderProperties2> compressSetDecoderProperties;
        RINOK(decoder.QueryInterface(IID_ICompressSetDecoderProperties2,
            &compressSetDecoderProperties));
        
        Byte isSolid = (Byte)((IsSolid(index) || item.IsSplitBefore()) ? 1: 0);
        if (solidStart)
        {
          isSolid = false;
          solidStart = false;
        }


        RINOK(compressSetDecoderProperties->SetDecoderProperties2(&isSolid, 1));
          
        commonCoder = decoder;
        break;
      }
      default:
        outStream.Release();
        RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kUnSupportedMethod));
        continue;
    }
    HRESULT result = commonCoder->Code(inStream, outStream, &packSize, &item.Size, progress);
    if (item.IsEncrypted())
      filterStreamSpec->ReleaseInStream();
    if (result == S_FALSE)
    {
      outStream.Release();
      RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kDataError));
      continue;
    }
    if (result != S_OK)
      return result;

    /*
    if (refItem.NumItems == 1 &&
        !item.IsSplitBefore() && !item.IsSplitAfter())
    */
    {
      const CItemEx &lastItem = _items[refItem.ItemIndex + refItem.NumItems - 1];
      bool crcOK = outStreamSpec->GetCRC() == lastItem.FileCRC;
      outStream.Release();
      RINOK(extractCallback->SetOperationResult(crcOK ?
          NExtract::NOperationResult::kOK:
          NExtract::NOperationResult::kCRCError));
    }
    /*
    else
    {
      bool crcOK = true;
      for (int partIndex = 0; partIndex < refItem.NumItems; partIndex++)
      {
        const CItemEx &item = _items[refItem.ItemIndex + partIndex];
        if (item.FileCRC != folderInStreamSpec->CRCs[partIndex])
        {
          crcOK = false;
          break;
        }
      }
      RINOK(extractCallback->SetOperationResult(crcOK ?
          NExtract::NOperationResult::kOK:
          NExtract::NOperationResult::kCRCError));
    }
    */
  }
  return S_OK;
  COM_TRY_END
}

IMPL_ISetCompressCodecsInfo

}}
<file_sep>/SQLCEHelper/TestApp/SqlCeHelperTestCases.h
#pragma once


#include "../Include/SqlCeHelper.h"

#define DB_FILE_NAME L"SqlCeHelperTest.sdf"
int max = 100;

TEST(SqlCeHelper, SelectDataAfterDelete)
{
	printf("\n====After Delete.====\n");
	SqlCeHelper db;
	HRESULT hr = db.Open(DB_FILE_NAME);
	if(hr < 0)
	{
		CString cstr = db.GetErrorsMessage();
		char* str = new char[cstr.GetLength()+1];
		sprintf(str, "%S", cstr);
		FAIL(str);
		delete str;
	}
	
	CString sqlStr;
	sqlStr.Format(L"SELECT * FROM T1");
	hr = db.ExecuteReader(sqlStr);
	if(hr < 0)
	{
		CString cstr = db.GetErrorsMessage();
		char* str = new char[cstr.GetLength()+1];
		sprintf(str, "%S", cstr);
		FAIL(str);
		delete str;
	}
	
	while(!db.IsEndOfRecordSet())
	{
		wprintf(L"F1=[%d], F2=[%s], F3=[%s]\n", db.GetRowInt(1), db.GetRowStr(2), db.GetRowStr(3));
		db.MoveNext();
	}

	db.CloseReader();
	db.Close();
}

TEST(SqlCeHelper, DeleteData)
{
	SqlCeHelper db;
	HRESULT hr = db.Open(DB_FILE_NAME);
	if(hr < 0)
	{
		CString cstr = db.GetErrorsMessage();
		char* str = new char[cstr.GetLength()+1];
		sprintf(str, "%S", cstr);
		FAIL(str);
		delete str;
	}

	CString sqlStr;
	for(int i=0; i<max; ++i)
	{
		sqlStr.Format(L"DELETE FROM T1 WHERE F1=%d", i);
		hr = db.ExecuteNonQuery(sqlStr);
		if(hr < 0)
		{
			CString cstr = db.GetErrorsMessage();
			char* str = new char[cstr.GetLength()+1];
			sprintf(str, "%S", cstr);
			FAIL(str);
			delete str;
		}
	}

	db.Close();
}

TEST(SqlCeHelper, SelectDataBeforeDelete)
{
	printf("\n====Before Delete.====\n");
	SqlCeHelper db;
	HRESULT hr = db.Open(DB_FILE_NAME);
	if(hr < 0)
	{
		CString cstr = db.GetErrorsMessage();
		char* str = new char[cstr.GetLength()+1];
		sprintf(str, "%S", cstr);
		FAIL(str);
		delete str;
	}
	
	CString sqlStr;
	sqlStr.Format(L"SELECT * FROM T1");
	hr = db.ExecuteReader(sqlStr);
	if(hr < 0)
	{
		CString cstr = db.GetErrorsMessage();
		char* str = new char[cstr.GetLength()+1];
		sprintf(str, "%S", cstr);
		FAIL(str);
		delete str;
	}
	
	while(!db.IsEndOfRecordSet())
	{
		wprintf(L"F1=[%d], F2=[%s], F3=[%s]\n", db.GetRowInt(1), db.GetRowStr(2), db.GetRowStr(3));
		db.MoveNext();
	}

	db.CloseReader();
	db.Close();
}


TEST(SqlCeHelper, UpdateData)
{
	SqlCeHelper db;
	HRESULT hr = db.Open(DB_FILE_NAME);
	if(hr < 0)
	{
		CString cstr = db.GetErrorsMessage();
		char* str = new char[cstr.GetLength()+1];
		sprintf(str, "%S", cstr);
		FAIL(str);
		delete str;
	}

	CString sqlStr;
	for(int i=0; i<max; ++i)
	{
		SYSTEMTIME currentTime;	
		GetLocalTime(&currentTime);
		sqlStr.Format(L"UPDATE T1 SET F2='STR%d', F3='%d-%d-%d %d:%d:%d' WHERE F1=%d", 
			max-i, currentTime.wYear, currentTime.wMonth, currentTime.wDay, currentTime.wHour, currentTime.wMinute, currentTime.wSecond, i);
		hr = db.ExecuteNonQuery(sqlStr);
		if(hr < 0)
		{
			CString cstr = db.GetErrorsMessage();
			char* str = new char[cstr.GetLength()+1];
			sprintf(str, "%S", cstr);
			FAIL(str);
			delete str;
		}
	}

	db.Close();
}

TEST(SqlCeHelper, SelectDataBeforeUpdate)
{
	printf("\n====Before Update.====\n");
	SqlCeHelper db;
	HRESULT hr = db.Open(DB_FILE_NAME);
	if(hr < 0)
	{
		CString cstr = db.GetErrorsMessage();
		char* str = new char[cstr.GetLength()+1];
		sprintf(str, "%S", cstr);
		FAIL(str);
		delete str;
	}
	
	CString sqlStr;
	sqlStr.Format(L"SELECT * FROM T1");
	hr = db.ExecuteReader(sqlStr);
	if(hr < 0)
	{
		CString cstr = db.GetErrorsMessage();
		char* str = new char[cstr.GetLength()+1];
		sprintf(str, "%S", cstr);
		FAIL(str);
		delete str;
	}
	
	while(!db.IsEndOfRecordSet())
	{
		wprintf(L"F1=[%d], F2=[%s], F3=[%s]\n", db.GetRowInt(1), db.GetRowStr(2), db.GetRowStr(3));
		db.MoveNext();
	}
	db.CloseReader();
	db.Close();
}

TEST(SqlCeHelper, InsertData)
{
	SqlCeHelper db;
	HRESULT hr = db.Open(DB_FILE_NAME);
	if(hr < 0)
	{
		CString cstr = db.GetErrorsMessage();
		char* str = new char[cstr.GetLength()+1];
		sprintf(str, "%S", cstr);
		FAIL(str);
		delete str;
	}

	CString sqlStr;
	for(int i=0; i<max; ++i)
	{
		SYSTEMTIME currentTime;	
		GetLocalTime(&currentTime);
		sqlStr.Format(L"INSERT INTO T1 (F1, F2, F3) VALUES(%d, 'STR%d', '%d-%d-%d %d:%d:%d')", 
			i, i, currentTime.wYear, currentTime.wMonth, currentTime.wDay, currentTime.wHour, currentTime.wMinute, currentTime.wSecond);
		hr = db.ExecuteNonQuery(sqlStr);
		if(hr < 0)
		{
			CString cstr = db.GetErrorsMessage();
			char* str = new char[cstr.GetLength()+1];
			sprintf(str, "%S", cstr);
			FAIL(str);
			delete str;
		}
	}

	db.Close();
}

TEST(SqlCeHelper, SelectDataBeforeInsert)
{
	printf("\n====Before Insert.====\n");
	SqlCeHelper db;
	HRESULT hr = db.Open(DB_FILE_NAME);
	if(hr < 0)
	{
		CString cstr = db.GetErrorsMessage();
		char* str = new char[cstr.GetLength()+1];
		sprintf(str, "%S", cstr);
		FAIL(str);
		delete str;
	}
	
	CString sqlStr;
	sqlStr.Format(L"SELECT * FROM T1");
	hr = db.ExecuteReader(sqlStr);
	if(hr < 0)
	{
		CString cstr = db.GetErrorsMessage();
		char* str = new char[cstr.GetLength()+1];
		sprintf(str, "%S", cstr);
		FAIL(str);
		delete str;
	}
	
	while(!db.IsEndOfRecordSet())
	{
		wprintf(L"F1=[%d], F2=[%s], F3=[%s]\n", db.GetRowInt(1), db.GetRowStr(2), db.GetRowStr(3));
		db.MoveNext();
	}
	db.CloseReader();
	db.Close();
}

TEST(SqlCeHelper, OpenDatabase)
{
	SqlCeHelper db;
	bool b = db.Open(DB_FILE_NAME);
	if(!b)
	{
		CString cstr = db.GetErrorsMessage();
		char* str = new char[cstr.GetLength()+1];
		sprintf(str, "%S", cstr);
		FAIL(str);
		delete str;
	}
	
	//if(hr == -1)
	//{
	//	FAIL("The database file doesn't exist.");
	//}
	//else if(hr == REGDB_E_CLASSNOTREG)
	//{
	//	FAIL("SqlCe 3.5 is not installed or the sqlceoledb35.dll is not registered.");
	//}
	//else if(hr < 0)
	//{
	//	FAIL(db.GetErrorsMessage().c_str());
	//	//FAIL("Cannot open the database.");
	//}

	db.Close();
}<file_sep>/7-Zip/CPP/7zip/Archive/Tar/TarHandler.cpp
// TarHandler.cpp

#include "StdAfx.h"

#include "Common/ComTry.h"
#include "Common/Defs.h"
#include "Common/NewHandler.h"
#include "Common/StringConvert.h"

#include "Windows/PropVariant.h"
#include "Windows/Time.h"

#include "../../Common/LimitedStreams.h"
#include "../../Common/ProgressUtils.h"

#include "../Common/ItemNameUtils.h"

#include "TarHandler.h"
#include "TarIn.h"

using namespace NWindows;

namespace NArchive {
namespace NTar {

STATPROPSTG kProps[] =
{
  { NULL, kpidPath, VT_BSTR},
  { NULL, kpidIsDir, VT_BOOL},
  { NULL, kpidSize, VT_UI8},
  { NULL, kpidPackSize, VT_UI8},
  { NULL, kpidMTime, VT_FILETIME},
  { NULL, kpidPosixAttrib, VT_UI4},
  { NULL, kpidUser, VT_BSTR},
  { NULL, kpidGroup, VT_BSTR},
  { NULL, kpidLink, VT_BSTR}
};

IMP_IInArchive_Props
IMP_IInArchive_ArcProps_NO_Table

STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
{
  NCOM::CPropVariant prop;
  switch(propID)
  {
    case kpidPhySize: if (_phySizeDefined) prop = _phySize; break;
  }
  prop.Detach(value);
  return S_OK;
}

HRESULT CHandler::Open2(IInStream *stream, IArchiveOpenCallback *callback)
{
  UInt64 endPos = 0;
  {
    RINOK(stream->Seek(0, STREAM_SEEK_END, &endPos));
    RINOK(stream->Seek(0, STREAM_SEEK_SET, NULL));
  }
  
  _isGood = true;
  UInt64 pos = 0;
  for (;;)
  {
    CItemEx item;
    bool filled;
    item.HeaderPosition = pos;
    RINOK(ReadItem(stream, filled, item));
    if (!filled)
      break;
    _items.Add(item);
    
    RINOK(stream->Seek(item.GetPackSize(), STREAM_SEEK_CUR, &pos));
    if (pos > endPos)
      return S_FALSE;
    if (pos == endPos)
    {
      _isGood = false;
      break;
    }
    if (callback != NULL)
    {
      if (_items.Size() == 1)
      {
        RINOK(callback->SetTotal(NULL, &endPos));
      }
      if (_items.Size() % 100 == 0)
      {
        UInt64 numFiles = _items.Size();
        RINOK(callback->SetCompleted(&numFiles, &pos));
      }
    }
  }

  if (_items.Size() == 0)
  {
    CMyComPtr<IArchiveOpenVolumeCallback> openVolumeCallback;
    if (!callback)
      return S_FALSE;
    callback->QueryInterface(IID_IArchiveOpenVolumeCallback, (void **)&openVolumeCallback);
    if (!openVolumeCallback)
      return S_FALSE;
    NCOM::CPropVariant prop;
    if (openVolumeCallback->GetProperty(kpidName, &prop) != S_OK)
      return S_FALSE;
    if (prop.vt != VT_BSTR)
      return S_FALSE;
    UString baseName = prop.bstrVal;
    baseName = baseName.Right(4);
    if (baseName.CompareNoCase(L".tar") != 0)
      return S_FALSE;
  }
  return S_OK;
}

STDMETHODIMP CHandler::Open(IInStream *stream, const UInt64 *, IArchiveOpenCallback *openArchiveCallback)
{
  COM_TRY_BEGIN
  {
    Close();
    RINOK(Open2(stream, openArchiveCallback));
    _stream = stream;
  }
  return S_OK;
  COM_TRY_END
}

STDMETHODIMP CHandler::OpenSeq(ISequentialInStream *stream)
{
  Close();
  _seqStream = stream;
  return S_OK;
}

STDMETHODIMP CHandler::Close()
{
  _phySizeDefined = false;
  _curIndex = 0;
  _latestIsRead = false;
  _items.Clear();
  _seqStream.Release();
  _stream.Release();
  return S_OK;
}

STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
{
  *numItems = (_stream ? _items.Size() : (UInt32)(Int32)-1);
  return S_OK;
}

CHandler::CHandler()
{
  copyCoderSpec = new NCompress::CCopyCoder();
  copyCoder = copyCoderSpec;
}

HRESULT CHandler::SkipTo(UInt32 index)
{
  while (_curIndex < index || !_latestIsRead)
  {
    if (_latestIsRead)
    {
      UInt64 packSize = _latestItem.GetPackSize();
      RINOK(copyCoderSpec->Code(_seqStream, NULL, &packSize, &packSize, NULL));
      _latestIsRead = false;
      _curIndex++;
    }
    else
    {
      bool filled;
      // item.HeaderPosition = pos;
      RINOK(ReadItem(_seqStream, filled, _latestItem));
      if (!filled)
        return E_INVALIDARG;
      _latestIsRead = true;
    }
  }
  return S_OK;
}

static UString TarStringToUnicode(const AString &s)
{
  return MultiByteToUnicodeString(s, CP_OEMCP);
}

STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
{
  COM_TRY_BEGIN
  NWindows::NCOM::CPropVariant prop;

  const CItemEx *item;
  if (_stream)
    item = &_items[index];
  else
  {
    if (index < _curIndex)
      return E_INVALIDARG;
    else
    {
      RINOK(SkipTo(index));
      item = &_latestItem;
    }
  }

  switch(propID)
  {
    case kpidPath:  prop = NItemName::GetOSName2(TarStringToUnicode(item->Name)); break;
    case kpidIsDir:  prop = item->IsDir(); break;
    case kpidSize:  prop = item->Size; break;
    case kpidPackSize:  prop = item->GetPackSize(); break;
    case kpidMTime:
      if (item->MTime != 0)
      {
        FILETIME ft;
        NTime::UnixTimeToFileTime(item->MTime, ft);
        prop = ft;
      }
      break;
    case kpidPosixAttrib: prop = item->Mode; break;
    case kpidUser:  prop = TarStringToUnicode(item->User); break;
    case kpidGroup:  prop = TarStringToUnicode(item->Group); break;
    case kpidLink:  prop = TarStringToUnicode(item->LinkName); break;
  }
  prop.Detach(value);
  return S_OK;
  COM_TRY_END
}

HRESULT CHandler::Extract(const UInt32 *indices, UInt32 numItems,
    Int32 testMode, IArchiveExtractCallback *extractCallback)
{
  COM_TRY_BEGIN
  ISequentialInStream *stream = _seqStream;
  bool seqMode = (_stream == NULL);
  if (!seqMode)
    stream = _stream;

  bool allFilesMode = (numItems == (UInt32)-1);
  if (allFilesMode)
    numItems = _items.Size();
  if (_stream && numItems == 0)
    return S_OK;
  UInt64 totalSize = 0;
  UInt32 i;
  for (i = 0; i < numItems; i++)
    totalSize += _items[allFilesMode ? i : indices[i]].Size;
  extractCallback->SetTotal(totalSize);

  UInt64 totalPackSize;
  totalSize = totalPackSize = 0;
  
  CLocalProgress *lps = new CLocalProgress;
  CMyComPtr<ICompressProgressInfo> progress = lps;
  lps->Init(extractCallback, false);

  CLimitedSequentialInStream *streamSpec = new CLimitedSequentialInStream;
  CMyComPtr<ISequentialInStream> inStream(streamSpec);
  streamSpec->SetStream(stream);

  CLimitedSequentialOutStream *outStreamSpec = new CLimitedSequentialOutStream;
  CMyComPtr<ISequentialOutStream> outStream(outStreamSpec);

  for (i = 0; i < numItems || seqMode; i++)
  {
    lps->InSize = totalPackSize;
    lps->OutSize = totalSize;
    RINOK(lps->SetCur());
    CMyComPtr<ISequentialOutStream> realOutStream;
    Int32 askMode = testMode ?
        NExtract::NAskMode::kTest :
        NExtract::NAskMode::kExtract;
    Int32 index = allFilesMode ? i : indices[i];
    const CItemEx *item;
    if (seqMode)
    {
      HRESULT res = SkipTo(index);
      if (res == E_INVALIDARG)
        break;
      RINOK(res);
      item = &_latestItem;
    }
    else
      item = &_items[index];

    RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
    totalSize += item->Size;
    totalPackSize += item->GetPackSize();
    if (item->IsDir())
    {
      RINOK(extractCallback->PrepareOperation(askMode));
      RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kOK));
      continue;
    }
    bool skipMode = false;
    if (!testMode && !realOutStream)
    {
      if (!seqMode)
        continue;
      skipMode = true;
      askMode = NExtract::NAskMode::kSkip;
    }
    RINOK(extractCallback->PrepareOperation(askMode));

    outStreamSpec->SetStream(realOutStream);
    realOutStream.Release();
    outStreamSpec->Init(skipMode ? 0 : item->Size, true);

    if (!seqMode)
    {
      RINOK(_stream->Seek(item->GetDataPosition(), STREAM_SEEK_SET, NULL));
    }
    streamSpec->Init(item->GetPackSize());
    RINOK(copyCoder->Code(inStream, outStream, NULL, NULL, progress));
    if (seqMode)
    {
      _latestIsRead = false;
      _curIndex++;
    }
    outStreamSpec->ReleaseStream();
    RINOK(extractCallback->SetOperationResult(outStreamSpec->GetRem() == 0 ?
        NExtract::NOperationResult::kOK:
        NExtract::NOperationResult::kDataError));
  }
  return S_OK;
  COM_TRY_END
}

STDMETHODIMP CHandler::GetStream(UInt32 index, ISequentialInStream **stream)
{
  COM_TRY_BEGIN
  const CItemEx &item = _items[index];
  return CreateLimitedInStream(_stream, item.GetDataPosition(), item.Size, stream);
  COM_TRY_END
}

}}
<file_sep>/7-Zip/CPP/7zip/Archive/Iso/IsoRegister.cpp
// IsoRegister.cpp

#include "StdAfx.h"

#include "../../Common/RegisterArc.h"

#include "IsoHandler.h"
static IInArchive *CreateArc() { return new NArchive::NIso::CHandler; }

static CArcInfo g_ArcInfo =
  { L"Iso", L"iso", 0, 0xE7, { 'C', 'D', '0', '0', '1', 0x1 }, 7, false, CreateArc, 0 };

REGISTER_ARC(Iso)
<file_sep>/7-Zip/CPP/7zip/Compress/PpmdContext.h
// PpmdContext.h
// 2009-05-30 : <NAME> : Public domain
// This code is based on <NAME>'s PPMdH code (public domain)

#ifndef __COMPRESS_PPMD_CONTEXT_H
#define __COMPRESS_PPMD_CONTEXT_H

#include "../../Common/Types.h"

#include "PpmdSubAlloc.h"
#include "RangeCoder.h"

namespace NCompress {
namespace NPpmd {

const int INT_BITS=7, PERIOD_BITS=7, TOT_BITS=INT_BITS+PERIOD_BITS,
        INTERVAL=1 << INT_BITS, BIN_SCALE=1 << TOT_BITS, MAX_FREQ=124;

struct SEE2_CONTEXT
{
  // SEE-contexts for PPM-contexts with masked symbols
  UInt16 Summ;
  Byte Shift, Count;
  void init(int InitVal) { Summ = (UInt16)(InitVal << (Shift=PERIOD_BITS-4)); Count=4; }
  unsigned int getMean()
  {
    unsigned int RetVal=(Summ >> Shift);
    Summ = (UInt16)(Summ - RetVal);
    return RetVal+(RetVal == 0);
  }
  void update()
  {
    if (Shift < PERIOD_BITS && --Count == 0)
    {
      Summ <<= 1;
      Count = (Byte)(3 << Shift++);
    }
  }
};

struct PPM_CONTEXT
{
  UInt16 NumStats; // sizeof(UInt16) > sizeof(Byte)
  UInt16 SummFreq;
  
  struct STATE
  {
    Byte Symbol, Freq;
    UInt16 SuccessorLow;
    UInt16 SuccessorHigh;

    UInt32 GetSuccessor() const { return SuccessorLow | ((UInt32)SuccessorHigh << 16); }
    void SetSuccessor(UInt32 v)
    {
      SuccessorLow = (UInt16)(v & 0xFFFF);
      SuccessorHigh = (UInt16)((v >> 16) & 0xFFFF);
    }
  };
  
  UInt32 Stats;
  UInt32 Suffix;
  
  PPM_CONTEXT* createChild(CSubAllocator &subAllocator, STATE* pStats, STATE& FirstState)
  {
    PPM_CONTEXT* pc = (PPM_CONTEXT*) subAllocator.AllocContext();
    if (pc)
    {
      pc->NumStats = 1;
      pc->oneState() = FirstState;
      pc->Suffix = subAllocator.GetOffset(this);
      pStats->SetSuccessor(subAllocator.GetOffsetNoCheck(pc));
    }
    return pc;
  }

  STATE& oneState() const { return (STATE&) SummFreq; }
};

/////////////////////////////////

const UInt16 InitBinEsc[] =
  {0x3CDD, 0x1F3F, 0x59BF, 0x48F3, 0x64A1, 0x5ABC, 0x6632, 0x6051};

struct CInfo
{
  CSubAllocator SubAllocator;
  SEE2_CONTEXT SEE2Cont[25][16], DummySEE2Cont;
  PPM_CONTEXT * MinContext, * MaxContext;

  PPM_CONTEXT::STATE* FoundState;      // found next state transition
  int NumMasked, InitEsc, OrderFall, RunLength, InitRL, MaxOrder;
  Byte CharMask[256], NS2Indx[256], NS2BSIndx[256], HB2Flag[256];
  Byte EscCount, PrintCount, PrevSuccess, HiBitsFlag;
  UInt16 BinSumm[128][64];               // binary SEE-contexts

  UInt16 &GetBinSumm(const PPM_CONTEXT::STATE &rs, int numStates)
  {
    HiBitsFlag = HB2Flag[FoundState->Symbol];
    return BinSumm[rs.Freq - 1][
         PrevSuccess + NS2BSIndx[numStates - 1] +
         HiBitsFlag + 2 * HB2Flag[rs.Symbol] +
         ((RunLength >> 26) & 0x20)];
  }

  PPM_CONTEXT *GetContext(UInt32 offset) const { return (PPM_CONTEXT *)SubAllocator.GetPtr(offset); }
  PPM_CONTEXT *GetContextNoCheck(UInt32 offset) const { return (PPM_CONTEXT *)SubAllocator.GetPtrNoCheck(offset); }
  PPM_CONTEXT::STATE *GetState(UInt32 offset) const { return (PPM_CONTEXT::STATE *)SubAllocator.GetPtr(offset); }
  PPM_CONTEXT::STATE *GetStateNoCheck(UInt32 offset) const { return (PPM_CONTEXT::STATE *)SubAllocator.GetPtr(offset); }

  void RestartModelRare()
  {
    int i, k, m;
    memset(CharMask,0,sizeof(CharMask));
    SubAllocator.InitSubAllocator();
    InitRL = -((MaxOrder < 12) ? MaxOrder : 12) - 1;
    MinContext = MaxContext = (PPM_CONTEXT*) SubAllocator.AllocContext();
    MinContext->Suffix = 0;
    OrderFall = MaxOrder;
    MinContext->SummFreq = (UInt16)((MinContext->NumStats = 256) + 1);
    FoundState = (PPM_CONTEXT::STATE*)SubAllocator.AllocUnits(256 / 2);
    MinContext->Stats = SubAllocator.GetOffsetNoCheck(FoundState);
    PrevSuccess = 0;
    for (RunLength = InitRL, i = 0; i < 256; i++)
    {
      PPM_CONTEXT::STATE &state = FoundState[i];
      state.Symbol = (Byte)i;
      state.Freq = 1;
      state.SetSuccessor(0);
    }
    for (i = 0; i < 128; i++)
        for (k = 0; k < 8; k++)
            for ( m=0; m < 64; m += 8)
                BinSumm[i][k + m] = (UInt16)(BIN_SCALE - InitBinEsc[k] / (i + 2));
    for (i = 0; i < 25; i++)
        for (k = 0; k < 16; k++)
            SEE2Cont[i][k].init(5*i+10);
  }

  void StartModelRare(int maxOrder)
  {
    int i, k, m ,Step;
    EscCount=PrintCount=1;
    if (maxOrder < 2)
    {
        memset(CharMask,0,sizeof(CharMask));
        OrderFall = MaxOrder;
        MinContext = MaxContext;
        while (MinContext->Suffix != 0)
        {
          MinContext = GetContextNoCheck(MinContext->Suffix);
          OrderFall--;
        }
        FoundState = GetState(MinContext->Stats);
        MinContext = MaxContext;
    }
    else
    {
        MaxOrder = maxOrder;
        RestartModelRare();
        NS2BSIndx[0] = 2 * 0;
        NS2BSIndx[1] = 2 * 1;
        memset(NS2BSIndx + 2, 2 * 2, 9);
        memset(NS2BSIndx + 11, 2 * 3, 256 - 11);
        for (i = 0; i < 3; i++)
          NS2Indx[i] = (Byte)i;
        for (m = i, k = Step = 1; i < 256; i++)
        {
            NS2Indx[i] = (Byte)m;
            if ( !--k )
            {
              k = ++Step;
              m++;
            }
        }
        memset(HB2Flag, 0, 0x40);
        memset(HB2Flag + 0x40, 0x08, 0x100 - 0x40);
        DummySEE2Cont.Shift = PERIOD_BITS;
    }
  }

  PPM_CONTEXT* CreateSuccessors(bool skip, PPM_CONTEXT::STATE* p1)
  {
    // static UpState declaration bypasses IntelC bug
    // static PPM_CONTEXT::STATE UpState;
    PPM_CONTEXT::STATE UpState;

    PPM_CONTEXT *pc = MinContext;
    PPM_CONTEXT *UpBranch = GetContext(FoundState->GetSuccessor());
    PPM_CONTEXT::STATE * p, * ps[MAX_O], ** pps = ps;
    if ( !skip )
    {
        *pps++ = FoundState;
        if ( !pc->Suffix )
          goto NO_LOOP;
    }
    if ( p1 )
    {
        p = p1;
        pc = GetContext(pc->Suffix);
        goto LOOP_ENTRY;
    }
    do
    {
        pc = GetContext(pc->Suffix);
        if (pc->NumStats != 1)
        {
            if ((p = GetStateNoCheck(pc->Stats))->Symbol != FoundState->Symbol)
                do { p++; } while (p->Symbol != FoundState->Symbol);
        }
        else
          p = &(pc->oneState());
LOOP_ENTRY:
        if (GetContext(p->GetSuccessor()) != UpBranch)
        {
            pc = GetContext(p->GetSuccessor());
            break;
        }
        *pps++ = p;
    }
    while ( pc->Suffix );
NO_LOOP:
    if (pps == ps)
      return pc;
    UpState.Symbol = *(Byte*) UpBranch;
    UpState.SetSuccessor(SubAllocator.GetOffset(UpBranch) + 1);
    if (pc->NumStats != 1)
    {
        if ((p = GetStateNoCheck(pc->Stats))->Symbol != UpState.Symbol)
                do { p++; } while (p->Symbol != UpState.Symbol);
        unsigned int cf = p->Freq-1;
        unsigned int s0 = pc->SummFreq - pc->NumStats - cf;
        UpState.Freq = (Byte)(1 + ((2 * cf <= s0) ? (5 * cf > s0) :
            ((2 * cf + 3 * s0 - 1) / (2 * s0))));
    }
    else
      UpState.Freq = pc->oneState().Freq;
    do
    {
        pc = pc->createChild(SubAllocator, *--pps, UpState);
        if ( !pc )
          return NULL;
    }
    while (pps != ps);
    return pc;
  }

  void UpdateModel()
  {
    PPM_CONTEXT::STATE fs = *FoundState, * p = NULL;
    PPM_CONTEXT* pc, * Successor;
    unsigned int ns1, ns, cf, sf, s0;
    if (fs.Freq < MAX_FREQ / 4 && MinContext->Suffix != 0)
    {
        pc = GetContextNoCheck(MinContext->Suffix);
      
        if (pc->NumStats != 1)
        {
            if ((p = GetStateNoCheck(pc->Stats))->Symbol != fs.Symbol)
            {
                do { p++; } while (p->Symbol != fs.Symbol);
                if (p[0].Freq >= p[-1].Freq)
                {
                    _PPMD_SWAP(p[0],p[-1]);
                    p--;
                }
            }
            if (p->Freq < MAX_FREQ-9)
            {
                p->Freq += 2;
                pc->SummFreq += 2;
            }
        }
        else
        {
            p = &(pc->oneState());
            p->Freq = (Byte)(p->Freq + ((p->Freq < 32) ? 1 : 0));
        }
    }
    if ( !OrderFall )
    {
        MinContext = MaxContext = CreateSuccessors(true, p);
        FoundState->SetSuccessor(SubAllocator.GetOffset(MinContext));
        if (MinContext == 0)
          goto RESTART_MODEL;
        return;
    }
    *SubAllocator.pText++ = fs.Symbol;
    Successor = (PPM_CONTEXT*) SubAllocator.pText;
    if (SubAllocator.pText >= SubAllocator.UnitsStart)
      goto RESTART_MODEL;
    if (fs.GetSuccessor() != 0)
    {
        if ((Byte *)GetContext(fs.GetSuccessor()) <= SubAllocator.pText)
        {
          PPM_CONTEXT* cs = CreateSuccessors(false, p);
          fs.SetSuccessor(SubAllocator.GetOffset(cs));
          if (cs == NULL)
            goto RESTART_MODEL;
        }
        if ( !--OrderFall )
        {
            Successor = GetContext(fs.GetSuccessor());
            SubAllocator.pText -= (MaxContext != MinContext);
        }
    }
    else
    {
        FoundState->SetSuccessor(SubAllocator.GetOffsetNoCheck(Successor));
        fs.SetSuccessor(SubAllocator.GetOffsetNoCheck(MinContext));
    }
    s0 = MinContext->SummFreq - (ns = MinContext->NumStats) - (fs.Freq - 1);
    for (pc = MaxContext; pc != MinContext; pc = GetContext(pc->Suffix))
    {
        if ((ns1 = pc->NumStats) != 1)
        {
            if ((ns1 & 1) == 0)
            {
                void *ppp = SubAllocator.ExpandUnits(GetState(pc->Stats), ns1 >> 1);
                pc->Stats = SubAllocator.GetOffset(ppp);
                if (!ppp)
                  goto RESTART_MODEL;
            }
            pc->SummFreq = (UInt16)(pc->SummFreq + (2 * ns1 < ns) + 2 * ((4 * ns1 <= ns) &
                    (pc->SummFreq <= 8 * ns1)));
        }
        else
        {
            p = (PPM_CONTEXT::STATE*) SubAllocator.AllocUnits(1);
            if ( !p )
              goto RESTART_MODEL;
            *p = pc->oneState();
            pc->Stats = SubAllocator.GetOffsetNoCheck(p);
            if (p->Freq < MAX_FREQ / 4 - 1)
              p->Freq <<= 1;
            else
              p->Freq  = MAX_FREQ - 4;
            pc->SummFreq = (UInt16)(p->Freq + InitEsc + (ns > 3));
        }
        cf = 2 * fs.Freq * (pc->SummFreq+6);
        sf = s0 + pc->SummFreq;
        if (cf < 6 * sf)
        {
            cf = 1 + (cf > sf)+(cf >= 4 * sf);
            pc->SummFreq += 3;
        }
        else
        {
            cf = 4 + (cf >= 9 * sf) + (cf >= 12 * sf) + (cf >= 15 * sf);
            pc->SummFreq = (UInt16)(pc->SummFreq + cf);
        }
        p = GetState(pc->Stats) + ns1;
        p->SetSuccessor(SubAllocator.GetOffset(Successor));
        p->Symbol = fs.Symbol;
        p->Freq = (Byte)cf;
        pc->NumStats = (UInt16)++ns1;
    }
    MaxContext = MinContext = GetContext(fs.GetSuccessor());
    return;
RESTART_MODEL:
    RestartModelRare();
    EscCount = 0;
    PrintCount = 0xFF;
  }

  void ClearMask()
  {
    EscCount = 1;
    memset(CharMask, 0, sizeof(CharMask));
    // if (++PrintCount == 0)
    //   PrintInfo(DecodedFile,EncodedFile);
  }

  void update1(PPM_CONTEXT::STATE* p)
  {
    (FoundState = p)->Freq += 4;
    MinContext->SummFreq += 4;
    if (p[0].Freq > p[-1].Freq)
    {
        _PPMD_SWAP(p[0],p[-1]);
        FoundState = --p;
        if (p->Freq > MAX_FREQ)
          rescale();
    }
  }


  void update2(PPM_CONTEXT::STATE* p)
  {
    (FoundState = p)->Freq += 4;
    MinContext->SummFreq += 4;
    if (p->Freq > MAX_FREQ)
      rescale();
    EscCount++;
    RunLength = InitRL;
  }
  
  SEE2_CONTEXT* makeEscFreq2(int Diff, UInt32 &scale)
  {
    SEE2_CONTEXT* psee2c;
    if (MinContext->NumStats != 256)
    {
      psee2c = SEE2Cont[NS2Indx[Diff-1]] +
        (Diff < (GetContext(MinContext->Suffix))->NumStats - MinContext->NumStats) +
        2 * (MinContext->SummFreq < 11 * MinContext->NumStats) +
        4 * (NumMasked > Diff) +
        HiBitsFlag;
      scale = psee2c->getMean();
    }
    else
    {
      psee2c = &DummySEE2Cont;
      scale = 1;
    }
    return psee2c;
  }



  void rescale()
  {
    int OldNS = MinContext->NumStats, i = MinContext->NumStats - 1, Adder, EscFreq;
    PPM_CONTEXT::STATE* p1, * p;
    PPM_CONTEXT::STATE *stats = GetStateNoCheck(MinContext->Stats);
    for (p = FoundState; p != stats; p--)
      _PPMD_SWAP(p[0], p[-1]);
    stats->Freq += 4;
    MinContext->SummFreq += 4;
    EscFreq = MinContext->SummFreq - p->Freq;
    Adder = (OrderFall != 0);
    p->Freq = (Byte)((p->Freq + Adder) >> 1);
    MinContext->SummFreq = p->Freq;
    do
    {
        EscFreq -= (++p)->Freq;
        p->Freq = (Byte)((p->Freq + Adder) >> 1);
        MinContext->SummFreq = (UInt16)(MinContext->SummFreq + p->Freq);
        if (p[0].Freq > p[-1].Freq)
        {
            PPM_CONTEXT::STATE tmp = *(p1 = p);
            do
            {
              p1[0] = p1[-1];
            }
            while (--p1 != stats && tmp.Freq > p1[-1].Freq);
            *p1 = tmp;
        }
    }
    while ( --i );
    if (p->Freq == 0)
    {
        do { i++; } while ((--p)->Freq == 0);
        EscFreq += i;
        MinContext->NumStats = (UInt16)(MinContext->NumStats - i);
        if (MinContext->NumStats == 1)
        {
            PPM_CONTEXT::STATE tmp = *stats;
            do { tmp.Freq = (Byte)(tmp.Freq - (tmp.Freq >> 1)); EscFreq >>= 1; } while (EscFreq > 1);
            SubAllocator.FreeUnits(stats, (OldNS+1) >> 1);
            *(FoundState = &MinContext->oneState()) = tmp;  return;
        }
    }
    EscFreq -= (EscFreq >> 1);
    MinContext->SummFreq = (UInt16)(MinContext->SummFreq + EscFreq);
    int n0 = (OldNS+1) >> 1, n1 = (MinContext->NumStats + 1) >> 1;
    if (n0 != n1)
      MinContext->Stats = SubAllocator.GetOffset(SubAllocator.ShrinkUnits(stats, n0, n1));
    FoundState = GetState(MinContext->Stats);
  }

  void NextContext()
  {
    PPM_CONTEXT *c = GetContext(FoundState->GetSuccessor());
    if (!OrderFall && (Byte *)c > SubAllocator.pText)
      MinContext = MaxContext = c;
    else
    {
      UpdateModel();
      if (EscCount == 0)
        ClearMask();
    }
  }
};

// Tabulated escapes for exponential symbol distribution
const Byte ExpEscape[16]={ 25,14, 9, 7, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 2 };
#define GET_MEAN(SUMM,SHIFT,ROUND) ((SUMM+(1 << (SHIFT-ROUND))) >> (SHIFT))

}}

#endif
<file_sep>/7-Zip/CPP/7zip/UI/FileManager/PanelOperations.cpp
// PanelOperations.cpp

#include "StdAfx.h"

#include "Common/DynamicBuffer.h"
#include "Common/StringConvert.h"

#include "Windows/COM.h"
#include "Windows/FileDir.h"
#include "Windows/PropVariant.h"
#include "Windows/ResourceString.h"
#include "Windows/Thread.h"

#include "ComboDialog.h"

#include "FSFolder.h"
#include "FormatUtils.h"
#include "LangUtils.h"
#include "Panel.h"
#include "UpdateCallback100.h"

#include "resource.h"

using namespace NWindows;
using namespace NFile;

#ifndef _UNICODE
extern bool g_IsNT;
#endif

enum EFolderOpType
{
  FOLDER_TYPE_CREATE_FOLDER = 0,
  FOLDER_TYPE_DELETE = 1,
  FOLDER_TYPE_RENAME = 2
};

class CThreadFolderOperations: public CProgressThreadVirt
{
  HRESULT ProcessVirt();
public:
  EFolderOpType OpType;
  UString Name;
  UInt32 Index;
  CRecordVector<UInt32> Indices;

  CMyComPtr<IFolderOperations> FolderOperations;
  CMyComPtr<IProgress> UpdateCallback;
  CUpdateCallback100Imp *UpdateCallbackSpec;
  
  HRESULT Result;

  CThreadFolderOperations(EFolderOpType opType): OpType(opType), Result(E_FAIL) {};
  HRESULT DoOperation(CPanel &panel, const UString &progressTitle, const UString &titleError);
};
  
HRESULT CThreadFolderOperations::ProcessVirt()
{
  NCOM::CComInitializer comInitializer;
  switch(OpType)
  {
    case FOLDER_TYPE_CREATE_FOLDER:
      Result = FolderOperations->CreateFolder(Name, UpdateCallback);
      break;
    case FOLDER_TYPE_DELETE:
      Result = FolderOperations->Delete(&Indices.Front(), Indices.Size(), UpdateCallback);
      break;
    case FOLDER_TYPE_RENAME:
      Result = FolderOperations->Rename(Index, Name, UpdateCallback);
      break;
    default:
      Result = E_FAIL;
  }
  return Result;
};


HRESULT CThreadFolderOperations::DoOperation(CPanel &panel, const UString &progressTitle, const UString &titleError)
{
  UpdateCallbackSpec = new CUpdateCallback100Imp;
  UpdateCallback = UpdateCallbackSpec;
  UpdateCallbackSpec->ProgressDialog = &ProgressDialog;

  ProgressDialog.WaitMode = true;
  ProgressDialog.Sync.SetErrorMessageTitle(titleError);
  Result = S_OK;

  bool usePassword = false;
  UString password;
  if (panel._parentFolders.Size() > 0)
  {
    const CFolderLink &fl = panel._parentFolders.Back();
    usePassword = <PASSWORD>;
    password = <PASSWORD>;
  }

  UpdateCallbackSpec->Init(usePassword, password);

  ProgressDialog.MainWindow = panel._mainWindow; // panel.GetParent()
  ProgressDialog.MainTitle = LangString(IDS_APP_TITLE, 0x03000000);
  ProgressDialog.MainAddTitle = progressTitle + UString(L" ");

  RINOK(Create(progressTitle, ProgressDialog.MainWindow));
  return Result;
}

#ifndef _UNICODE
typedef int (WINAPI * SHFileOperationWP)(LPSHFILEOPSTRUCTW lpFileOp);
#endif

void CPanel::DeleteItems(bool toRecycleBin)
{
  CPanel::CDisableTimerProcessing disableTimerProcessing2(*this);
  CRecordVector<UInt32> indices;
  GetOperatedItemIndices(indices);
  if (indices.IsEmpty())
    return;
  CSelectedState state;
  SaveSelectedState(state);

  #ifndef UNDER_CE
  // WM6 / SHFileOperationW doesn't ask user! So we use internal delete
  bool useInternalDelete = false;
  if (IsFSFolder() && toRecycleBin)
  {
    #ifndef _UNICODE
    if (!g_IsNT)
    {
      CDynamicBuffer<CHAR> buffer;
      size_t size = 0;
      for (int i = 0; i < indices.Size(); i++)
      {
        const AString path = GetSystemString(GetFsPath() + GetItemRelPath(indices[i]));
        buffer.EnsureCapacity(size + path.Length() + 1);
        memmove(((CHAR *)buffer) + size, (const CHAR *)path, (path.Length() + 1) * sizeof(CHAR));
        size += path.Length() + 1;
      }
      buffer.EnsureCapacity(size + 1);
      ((CHAR *)buffer)[size]  = 0;
      SHFILEOPSTRUCTA fo;
      fo.hwnd = GetParent();
      fo.wFunc = FO_DELETE;
      fo.pFrom = (const CHAR *)buffer;
      fo.pTo = 0;
      fo.fFlags = 0;
      if (toRecycleBin)
        fo.fFlags |= FOF_ALLOWUNDO;
      // fo.fFlags |= FOF_NOCONFIRMATION;
      // fo.fFlags |= FOF_NOERRORUI;
      // fo.fFlags |= FOF_SILENT;
      // fo.fFlags |= FOF_WANTNUKEWARNING;
      fo.fAnyOperationsAborted = FALSE;
      fo.hNameMappings = 0;
      fo.lpszProgressTitle = 0;
      /* int res = */ ::SHFileOperationA(&fo);
    }
    else
    #endif
    {
      CDynamicBuffer<WCHAR> buffer;
      size_t size = 0;
      int maxLen = 0;
      for (int i = 0; i < indices.Size(); i++)
      {
        // L"\\\\?\\") doesn't work here.
        const UString path = GetFsPath() + GetItemRelPath(indices[i]);
        if (path.Length() > maxLen)
          maxLen = path.Length();
        buffer.EnsureCapacity(size + path.Length() + 1);
        memmove(((WCHAR *)buffer) + size, (const WCHAR *)path, (path.Length() + 1) * sizeof(WCHAR));
        size += path.Length() + 1;
      }
      buffer.EnsureCapacity(size + 1);
      ((WCHAR *)buffer)[size] = 0;
      if (maxLen >= MAX_PATH)
      {
        if (toRecycleBin)
        {
          MessageBoxErrorLang(IDS_ERROR_LONG_PATH_TO_RECYCLE, 0x03020218);
          return;
        }
        useInternalDelete = true;
      }
      else
      {
        SHFILEOPSTRUCTW fo;
        fo.hwnd = GetParent();
        fo.wFunc = FO_DELETE;
        fo.pFrom = (const WCHAR *)buffer;
        fo.pTo = 0;
        fo.fFlags = 0;
        if (toRecycleBin)
          fo.fFlags |= FOF_ALLOWUNDO;
        fo.fAnyOperationsAborted = FALSE;
        fo.hNameMappings = 0;
        fo.lpszProgressTitle = 0;
        int res;
        #ifdef _UNICODE
        res = ::SHFileOperationW(&fo);
        #else
        SHFileOperationWP shFileOperationW = (SHFileOperationWP)
          ::GetProcAddress(::GetModuleHandleW(L"shell32.dll"), "SHFileOperationW");
        if (shFileOperationW == 0)
          return;
        res = shFileOperationW(&fo);
        #endif
      }
    }
    /*
    if (fo.fAnyOperationsAborted)
      MessageBoxError(result, LangString(IDS_ERROR_DELETING, 0x03020217));
    */
  }
  else
    useInternalDelete = true;
  if (useInternalDelete)
  #endif
    DeleteItemsInternal(indices);
  RefreshListCtrl(state);
}

void CPanel::MessageBoxErrorForUpdate(HRESULT errorCode, UINT resourceID, UInt32 langID)
{
  if (errorCode == E_NOINTERFACE)
    MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
  else
    MessageBoxError(errorCode, LangString(resourceID, langID));
}

void CPanel::DeleteItemsInternal(CRecordVector<UInt32> &indices)
{
  CMyComPtr<IFolderOperations> folderOperations;
  if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
  {
    MessageBoxErrorForUpdate(E_NOINTERFACE, IDS_ERROR_DELETING, 0x03020217);
    return;
  }

  UString title;
  UString message;
  if (indices.Size() == 1)
  {
    int index = indices[0];
    const UString itemName = GetItemRelPath(index);
    if (IsItemFolder(index))
    {
      title = LangString(IDS_CONFIRM_FOLDER_DELETE, 0x03020211);
      message = MyFormatNew(IDS_WANT_TO_DELETE_FOLDER, 0x03020214, itemName);
    }
    else
    {
      title = LangString(IDS_CONFIRM_FILE_DELETE, 0x03020210);
      message = MyFormatNew(IDS_WANT_TO_DELETE_FILE, 0x03020213, itemName);
    }
  }
  else
  {
    title = LangString(IDS_CONFIRM_ITEMS_DELETE, 0x03020212);
    message = MyFormatNew(IDS_WANT_TO_DELETE_ITEMS, 0x03020215,
        NumberToString(indices.Size()));
  }
  if (::MessageBoxW(GetParent(), message, title, MB_OKCANCEL | MB_ICONQUESTION) != IDOK)
    return;

  {
    CThreadFolderOperations op(FOLDER_TYPE_DELETE);
    op.FolderOperations = folderOperations;
    op.Indices = indices;
    op.DoOperation(*this,
        LangString(IDS_DELETING, 0x03020216),
        LangString(IDS_ERROR_DELETING, 0x03020217));
  }
  RefreshTitleAlways();
}

BOOL CPanel::OnBeginLabelEdit(LV_DISPINFOW * lpnmh)
{
  int realIndex = GetRealIndex(lpnmh->item);
  if (realIndex == kParentIndex)
    return TRUE;
  CMyComPtr<IFolderOperations> folderOperations;
  if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
    return TRUE;
  return FALSE;
}

BOOL CPanel::OnEndLabelEdit(LV_DISPINFOW * lpnmh)
{
  if (lpnmh->item.pszText == NULL)
    return FALSE;
  CMyComPtr<IFolderOperations> folderOperations;
  if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
  {
    MessageBoxErrorForUpdate(E_NOINTERFACE, IDS_ERROR_RENAMING, 0x03020221);
    return FALSE;
  }
  const UString newName = lpnmh->item.pszText;
  CPanel::CDisableTimerProcessing disableTimerProcessing2(*this);

  SaveSelectedState(_selectedState);

  int realIndex = GetRealIndex(lpnmh->item);
  if (realIndex == kParentIndex)
    return FALSE;
  const UString prefix = GetItemPrefix(realIndex);


  {
    CThreadFolderOperations op(FOLDER_TYPE_RENAME);
    op.FolderOperations = folderOperations;
    op.Index = realIndex;
    op.Name = newName;
    HRESULT res = op.DoOperation(*this,
        LangString(IDS_RENAMING, 0x03020220),
        LangString(IDS_ERROR_RENAMING, 0x03020221));
    if (res != S_OK)
      return FALSE;
  }

  // Can't use RefreshListCtrl here.
  // RefreshListCtrlSaveFocused();
  _selectedState.FocusedName = prefix + newName;
  _selectedState.SelectFocused = true;

  // We need clear all items to disable GetText before Reload:
  // number of items can change.
  // _listView.DeleteAllItems();
  // But seems it can still call GetText (maybe for current item)
  // so we can't delete items.

  _dontShowMode = true;

  PostMessage(kReLoadMessage);
  return TRUE;
}

void CPanel::CreateFolder()
{
  CMyComPtr<IFolderOperations> folderOperations;
  if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
  {
    MessageBoxErrorForUpdate(E_NOINTERFACE, IDS_CREATE_FOLDER_ERROR, 0x03020233);
    return;
  }
  CPanel::CDisableTimerProcessing disableTimerProcessing2(*this);
  CSelectedState state;
  SaveSelectedState(state);
  CComboDialog comboDialog;
  comboDialog.Title = LangString(IDS_CREATE_FOLDER, 0x03020230);
  comboDialog.Static = LangString(IDS_CREATE_FOLDER_NAME, 0x03020231);
  comboDialog.Value = LangString(IDS_CREATE_FOLDER_DEFAULT_NAME, /*0x03020232*/ (UInt32)-1);
  if (comboDialog.Create(GetParent()) == IDCANCEL)
    return;
  
  UString newName = comboDialog.Value;
  
  {
    CThreadFolderOperations op(FOLDER_TYPE_CREATE_FOLDER);
    op.FolderOperations = folderOperations;
    op.Name = newName;
    HRESULT res = op.DoOperation(*this,
        LangString(IDS_CREATE_FOLDER, 0x03020230),
        LangString(IDS_CREATE_FOLDER_ERROR, 0x03020233));
    if (res != S_OK)
      return;
  }
  int pos = newName.Find(WCHAR_PATH_SEPARATOR);
  if (pos >= 0)
    newName = newName.Left(pos);
  if (!_mySelectMode)
    state.SelectedNames.Clear();
  state.FocusedName = newName;
  state.SelectFocused = true;
  RefreshTitleAlways();
  RefreshListCtrl(state);
}

void CPanel::CreateFile()
{
  CMyComPtr<IFolderOperations> folderOperations;
  if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
  {
    MessageBoxErrorForUpdate(E_NOINTERFACE, IDS_CREATE_FILE_ERROR, 0x03020243);
    return;
  }
  CPanel::CDisableTimerProcessing disableTimerProcessing2(*this);
  CSelectedState state;
  SaveSelectedState(state);
  CComboDialog comboDialog;
  comboDialog.Title = LangString(IDS_CREATE_FILE, 0x03020240);
  comboDialog.Static = LangString(IDS_CREATE_FILE_NAME, 0x03020241);
  comboDialog.Value = LangString(IDS_CREATE_FILE_DEFAULT_NAME, /*0x03020242*/ (UInt32)-1);
  if (comboDialog.Create(GetParent()) == IDCANCEL)
    return;
  UString newName = comboDialog.Value;
  HRESULT result = folderOperations->CreateFile(newName, 0);
  if (result != S_OK)
  {
    MessageBoxErrorForUpdate(result, IDS_CREATE_FILE_ERROR, 0x03020243);
    return;
  }
  int pos = newName.Find(WCHAR_PATH_SEPARATOR);
  if (pos >= 0)
    newName = newName.Left(pos);
  if (!_mySelectMode)
    state.SelectedNames.Clear();
  state.FocusedName = newName;
  state.SelectFocused = true;
  RefreshListCtrl(state);
}

void CPanel::RenameFile()
{
  int index = _listView.GetFocusedItem();
  if (index >= 0)
    _listView.EditLabel(index);
}

void CPanel::ChangeComment()
{
  CPanel::CDisableTimerProcessing disableTimerProcessing2(*this);
  int index = _listView.GetFocusedItem();
  if (index < 0)
    return;
  int realIndex = GetRealItemIndex(index);
  if (realIndex == kParentIndex)
    return;
  CSelectedState state;
  SaveSelectedState(state);
  CMyComPtr<IFolderOperations> folderOperations;
  if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
  {
    MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
    return;
  }

  UString comment;
  {
    NCOM::CPropVariant propVariant;
    if (_folder->GetProperty(realIndex, kpidComment, &propVariant) != S_OK)
      return;
    if (propVariant.vt == VT_BSTR)
      comment = propVariant.bstrVal;
    else if (propVariant.vt != VT_EMPTY)
      return;
  }
  UString name = GetItemRelPath(realIndex);
  CComboDialog comboDialog;
  comboDialog.Title = name + L" " + LangString(IDS_COMMENT, 0x03020290);
  comboDialog.Value = comment;
  comboDialog.Static = LangString(IDS_COMMENT2, 0x03020291);
  if (comboDialog.Create(GetParent()) == IDCANCEL)
    return;
  NCOM::CPropVariant propVariant = comboDialog.Value;

  HRESULT result = folderOperations->SetProperty(realIndex, kpidComment, &propVariant, NULL);
  if (result != S_OK)
  {
    if (result == E_NOINTERFACE)
      MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
    else
      MessageBoxError(result, L"Set Comment Error");
  }
  RefreshListCtrl(state);
}
<file_sep>/FingerSuite/FingerSuiteCPL/resource.h
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by FingerSuiteCPL.rc
//
#define IDI_ICON1                       101
#define IDI_ICON                        101
#define IDI_FingerSuiteApplet           101
#define IDS_NAME                        102
#define IDS_FingerSuiteApplet           102
#define IDS_DESC                        103
#define IDS_Description_FingerSuiteApplet 103
#define IDI_ICON3                       104
#define IDS_Task_FingerSuiteApplet      104
#define IDS_Keywords_FingerSuiteApplet  105
#define IDD_FINGERMENUCONFIG_FORM       129
#define IDD_PAGE1                       129
#define IDD_PAGE2                       130
#define IDD_PAGE3                       131
#define IDD_PAGE4                       132
#define IDD_PAGEABOUT                   133
#define IDD_PAGE5                       134
#define IDD_PAGE7                       135
#define IDR_CONTROLPANEL                200
#define IDC_BTN_CLOSE_FINGERMENU        1000
#define IDC_BTN_START_FINGERMENU        1001
#define IDC_CB_SKIN_FINGERMENU          1001
#define IDC_CB_SKIN_FINGERMSGBOX        1002
#define IDC_AUTOSTART_MENU              1002
#define IDC_AUTOSTART_MSGBOX            1003
#define IDC_LBL_AUTOSTART_MENU          1004
#define IDC_LBL_TRANSLEVEL              1005
#define IDC_LBL_CB_SKIN_FINGERMENU      1005
#define IDC_TRANSLEVEL                  1006
#define IDC_LBL_MAXCOUNT                1007
#define IDC_SPIN_TRANSLEVEL             1008
#define IDC_MAXCOUNT                    1009
#define IDC_ENABLE_SIP                  1010
#define IDC_CL_BKGCOLOR                 1011
#define IDC_CL_TEXTCOLOR                1012
#define IDC_CL_SELTEXTCOLOR             1013
#define IDC_BTN_BKGCOLOR                1014
#define IDC_BTN_TEXTCOLOR               1015
#define IDC_BTN_SELTEXTCOLOR            1016
#define IDC_CL_DISTEXTCOLOR             1017
#define IDC_BTN_DISTEXTCOLOR            1018
#define IDC_CL_LINECOLOR                1019
#define IDC_BTN_LINECOLOR               1020
#define IDC_CB_PROCESSES                1021
#define IDC_BTN_ADDPROGRAM              1022
#define IDC_LB_PROCESSES                1023
#define IDC_BTN_REMOVEPROGRAMS          1024
#define IDC_BTN_REFRESH                 1025
#define IDC_SPIN_MAXCOUNT               1026
#define IDC_LBL_MAXVELOCITY             1027
#define IDC_MAXVELOCITY                 1028
#define IDC_SPIN_MAXVELOCITY            1029
#define IDC_ENABLE_TRANSPARENCY         1030
#define IDC_CL_BKGCOLORTRANSP           1031
#define IDC_BTN_BKGCOLORTRANSP          1032
#define IDC_DISABLE_BTNS                1033
#define IDC_DISABLEINTERVAL             1034
#define IDC_ENABLE_ANIMATION            1034

// Next default values for new objects
// 
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE        106
#define _APS_NEXT_COMMAND_VALUE         40001
#define _APS_NEXT_CONTROL_VALUE         1006
#define _APS_NEXT_SYMED_VALUE           101
#endif
#endif
<file_sep>/7-Zip/CPP/7zip/Archive/MachoHandler.cpp
// MachoHandler.cpp

#include "StdAfx.h"

#include "../../../C/CpuArch.h"

#include "Common/Buffer.h"
#include "Common/ComTry.h"

#include "Windows/PropVariantUtils.h"

#include "../Common/LimitedStreams.h"
#include "../Common/ProgressUtils.h"
#include "../Common/RegisterArc.h"
#include "../Common/StreamUtils.h"

#include "../Compress/CopyCoder.h"

static UInt32 Get32(const Byte *p, int be) { if (be) return GetBe32(p); return GetUi32(p); }
static UInt64 Get64(const Byte *p, int be) { if (be) return GetBe64(p); return GetUi64(p); }

using namespace NWindows;

namespace NArchive {
namespace NMacho {

#define MACH_ARCH_ABI64 (1 << 24)
#define MACH_MACHINE_386 7
#define MACH_MACHINE_ARM 12
#define MACH_MACHINE_SPARC 14
#define MACH_MACHINE_PPC 18

#define MACH_MACHINE_PPC64 (MACH_ARCH_ABI64 | MACH_MACHINE_PPC)
#define MACH_MACHINE_AMD64 (MACH_ARCH_ABI64 | MACH_MACHINE_386)

#define MACH_CMD_SEGMENT_32 1
#define MACH_CMD_SEGMENT_64 0x19

#define MACH_SECT_TYPE_MASK 0x000000FF
#define MACH_SECT_ATTR_MASK 0xFFFFFF00

#define MACH_SECT_ATTR_ZEROFILL 1

const char *g_SectTypes[] =
{
  "REGULAR",
  "ZEROFILL",
  "CSTRINGS",
  "4BYTE_LITERALS",
  "8BYTE_LITERALS",
  "LITERAL_POINTERS",
  "NON_LAZY_SYMBOL_POINTERS",
  "LAZY_SYMBOL_POINTERS",
  "SYMBOL_STUBS",
  "MOD_INIT_FUNC_POINTERS",
  "MOD_TERM_FUNC_POINTERS",
  "COALESCED",
  "GB_ZEROFILL",
  "INTERPOSING",
  "16BYTE_LITERALS"
};

const char *g_FileTypes[] =
{
  "0",
  "OBJECT",
  "EXECUTE",
  "FVMLIB",
  "CORE",
  "PRELOAD",
  "DYLIB",
  "DYLINKER",
  "BUNDLE",
  "DYLIB_STUB",
  "DSYM"
};

static const CUInt32PCharPair g_Flags[] =
{
  { (UInt32)1 << 31, "PURE_INSTRUCTIONS" },
  { 1 << 30, "NO_TOC" },
  { 1 << 29, "STRIP_STATIC_SYMS" },
  { 1 << 28, "NO_DEAD_STRIP" },
  { 1 << 27, "LIVE_SUPPORT" },
  { 1 << 26, "SELF_MODIFYING_CODE" },
  { 1 << 25, "DEBUG" },
  { 1 << 10, "SOME_INSTRUCTIONS" },
  { 1 <<  9, "EXT_RELOC" },
  { 1 <<  8, "LOC_RELOC" }
};

static const CUInt32PCharPair g_MachinePairs[] =
{
  { MACH_MACHINE_386, "x86" },
  { MACH_MACHINE_ARM, "ARM" },
  { MACH_MACHINE_SPARC, "SPARC" },
  { MACH_MACHINE_PPC, "PowerPC" },
  { MACH_MACHINE_PPC64, "PowerPC 64-bit" },
  { MACH_MACHINE_AMD64, "x64" }
};

static const int kNameSize = 16;

struct CSegment
{
  char Name[kNameSize];
};

struct CSection
{
  char Name[kNameSize];
  char SegName[kNameSize];
  UInt64 Va;
  UInt64 Size;
  UInt32 Pa;
  UInt32 Flags;
  int SegmentIndex;
  UInt64 GetPackSize() const { return Flags == MACH_SECT_ATTR_ZEROFILL ? 0 : Size; }
};


class CHandler:
  public IInArchive,
  public CMyUnknownImp
{
  CMyComPtr<IInStream> _inStream;
  CObjectVector<CSegment> _segments;
  CObjectVector<CSection> _sections;
  bool _mode64;
  bool _be;
  UInt32 _machine;
  UInt32 _type;
  UInt32 _headersSize;
  UInt64 _totalSize;
  HRESULT Open2(ISequentialInStream *stream);
  bool Parse(const Byte *buf, UInt32 size);
public:
  MY_UNKNOWN_IMP1(IInArchive)
  INTERFACE_IInArchive(;)
};

bool CHandler::Parse(const Byte *buf, UInt32 size)
{
  bool mode64 = _mode64;
  bool be = _be;

  const Byte *bufStart = buf;
  bool reduceCommands = false;
  if (size < 512)
    return false;

  _machine = Get32(buf + 4, be);
  _type = Get32(buf + 0xC, be);

  UInt32 numCommands = Get32(buf + 0x10, be);
  UInt32 commandsSize = Get32(buf + 0x14, be);
  if (commandsSize > size)
    return false;

  if (commandsSize > (1 << 24) || numCommands > (1 << 18))
    return false;

  if (numCommands > 16)
  {
    reduceCommands = true;
    numCommands = 16;
  }

  _headersSize = 0;

  buf += 0x1C;
  size -= 0x1C;

  if (mode64)
  {
    buf += 4;
    size -= 4;
  }

  _totalSize = (UInt32)(buf - bufStart);
  if (commandsSize < size)
    size = commandsSize;

  for (UInt32 cmdIndex = 0; cmdIndex < numCommands; cmdIndex++)
  {
    if (size < 8)
      return false;
    UInt32 cmd = Get32(buf, be);
    UInt32 cmdSize = Get32(buf + 4, be);
    if (size < cmdSize)
      return false;
    if (cmd == MACH_CMD_SEGMENT_32 || cmd == MACH_CMD_SEGMENT_64)
    {
      UInt32 offs = (cmd == MACH_CMD_SEGMENT_64) ? 0x48 : 0x38;
      if (cmdSize < offs)
        break;

      {
        UInt64 vmAddr, vmSize, phAddr, phSize;
        if (cmd == MACH_CMD_SEGMENT_64)
        {
          vmAddr = Get64(buf + 0x18, be);
          vmSize = Get64(buf + 0x20, be);
          phAddr = Get64(buf + 0x28, be);
          phSize = Get64(buf + 0x30, be);
        }
        else
        {
          vmAddr = Get32(buf + 0x18, be);
          vmSize = Get32(buf + 0x1C, be);
          phAddr = Get32(buf + 0x20, be);
          phSize = Get32(buf + 0x24, be);
        }
        {
          UInt64 totalSize = phAddr + phSize;
          if (totalSize > _totalSize)
            _totalSize = totalSize;
        }
      }
      
      CSegment seg;
      memcpy(seg.Name, buf + 8, kNameSize);
      _segments.Add(seg);

      UInt32 numSections = Get32(buf + offs - 8, be);
      if (numSections > (1 << 8))
        return false;

      while (numSections-- != 0)
      {
        CSection section;
        UInt32 headerSize = (cmd == MACH_CMD_SEGMENT_64) ? 0x50 : 0x44;
        const Byte *p = buf + offs;
        if (cmdSize - offs < headerSize)
          break;
        if (cmd == MACH_CMD_SEGMENT_64)
        {
          section.Va = Get64(p + 0x20, be);
          section.Size = Get64(p + 0x28, be);
          section.Pa = Get32(p + 0x30, be);
          section.Flags = Get32(p + 0x40, be);
        }
        else
        {
          section.Va = Get32(p + 0x20, be);
          section.Size = Get32(p + 0x24, be);
          section.Pa = Get32(p + 0x28, be);
          section.Flags = Get32(p + 0x38, be);
        }
        memcpy(section.Name, p, kNameSize);
        memcpy(section.SegName, p + kNameSize, kNameSize);
        section.SegmentIndex = _segments.Size() - 1;
        _sections.Add(section);
        offs += headerSize;
      }
      if (offs != cmdSize)
        return false;
    }
    buf += cmdSize;
    size -= cmdSize;
  }
  _headersSize = (UInt32)(buf - bufStart);
  return reduceCommands || (size == 0);
}

STATPROPSTG kArcProps[] =
{
  { NULL, kpidCpu, VT_BSTR},
  { NULL, kpidBit64, VT_BOOL},
  { NULL, kpidBigEndian, VT_BOOL},
  { NULL, kpidCharacts, VT_BSTR},
  { NULL, kpidPhySize, VT_UI8},
  { NULL, kpidHeadersSize, VT_UI4}
};

STATPROPSTG kProps[] =
{
  { NULL, kpidPath, VT_BSTR},
  { NULL, kpidSize, VT_UI8},
  { NULL, kpidPackSize, VT_UI8},
  { NULL, kpidCharacts, VT_BSTR},
  { NULL, kpidOffset, VT_UI8},
  { NULL, kpidVa, VT_UI8}
};

IMP_IInArchive_Props
IMP_IInArchive_ArcProps

STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
{
  COM_TRY_BEGIN
  NCOM::CPropVariant prop;
  switch(propID)
  {
    case kpidCpu:  PAIR_TO_PROP(g_MachinePairs, _machine, prop); break;
    case kpidCharacts:  TYPE_TO_PROP(g_FileTypes, _type, prop); break;
    case kpidPhySize:  prop = _totalSize; break;
    case kpidHeadersSize:  prop = _headersSize; break;
    case kpidBit64:  if (_mode64) prop = _mode64; break;
    case kpidBigEndian:  if (_be) prop = _be; break;
  }
  prop.Detach(value);
  return S_OK;
  COM_TRY_END
}

static AString GetName(const char *name)
{
  char res[kNameSize + 1];
  memcpy(res, name, kNameSize);
  res[kNameSize] = 0;
  return res;
}

static AString SectFlagsToString(UInt32 flags)
{
  AString res = TypeToString(g_SectTypes, sizeof(g_SectTypes) / sizeof(g_SectTypes[0]),
      flags & MACH_SECT_TYPE_MASK);
  AString s = FlagsToString(g_Flags, sizeof(g_Flags) / sizeof(g_Flags[0]),
      flags & MACH_SECT_ATTR_MASK);
  if (!s.IsEmpty())
  {
    res += ' ';
    res += s;
  }
  return res;
}

STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
{
  COM_TRY_BEGIN
  NCOM::CPropVariant prop;
  const CSection &item = _sections[index];
  switch(propID)
  {
    case kpidPath:  StringToProp(GetName(_segments[item.SegmentIndex].Name) + GetName(item.Name), prop); break;
    case kpidSize:  prop = (UInt64)item.Size; break;
    case kpidPackSize:  prop = (UInt64)item.GetPackSize(); break;
    case kpidCharacts:  StringToProp(SectFlagsToString(item.Flags), prop); break;
    case kpidOffset:  prop = item.Pa; break;
    case kpidVa:  prop = item.Va; break;
  }
  prop.Detach(value);
  return S_OK;
  COM_TRY_END
}

HRESULT CHandler::Open2(ISequentialInStream *stream)
{
  const UInt32 kBufSize = 1 << 18;
  const UInt32 kSigSize = 4;

  CByteBuffer buffer;
  buffer.SetCapacity(kBufSize);
  Byte *buf = buffer;

  size_t processed = kSigSize;
  RINOK(ReadStream_FALSE(stream, buf, processed));
  UInt32 sig = GetUi32(buf);
  bool be, mode64;
  switch(sig)
  {
    case 0xCEFAEDFE:  be = true; mode64 = false; break;
    case 0xCFFAEDFE:  be = true; mode64 = true; break;
    case 0xFEEDFACE:  be = false; mode64 = false; break;
    case 0xFEEDFACF:  be = false; mode64 = true; break;
    default: return S_FALSE;
  }
  processed = kBufSize - kSigSize;
  RINOK(ReadStream(stream, buf + kSigSize, &processed));
  _mode64 = mode64;
  _be = be;
  return Parse(buf, (UInt32)processed + kSigSize) ? S_OK : S_FALSE;
}

STDMETHODIMP CHandler::Open(IInStream *inStream,
    const UInt64 * /* maxCheckStartPosition */,
    IArchiveOpenCallback * /* openArchiveCallback */)
{
  COM_TRY_BEGIN
  Close();
  RINOK(Open2(inStream));
  _inStream = inStream;
  return S_OK;
  COM_TRY_END
}

STDMETHODIMP CHandler::Close()
{
  _inStream.Release();
  _sections.Clear();
  _segments.Clear();
  return S_OK;
}

STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
{
  *numItems = _sections.Size();
  return S_OK;
}

STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
    Int32 testMode, IArchiveExtractCallback *extractCallback)
{
  COM_TRY_BEGIN
  bool allFilesMode = (numItems == (UInt32)-1);
  if (allFilesMode)
    numItems = _sections.Size();
  if (numItems == 0)
    return S_OK;
  UInt64 totalSize = 0;
  UInt32 i;
  for (i = 0; i < numItems; i++)
    totalSize += _sections[allFilesMode ? i : indices[i]].GetPackSize();
  extractCallback->SetTotal(totalSize);

  UInt64 currentTotalSize = 0;
  UInt64 currentItemSize;
  
  NCompress::CCopyCoder *copyCoderSpec = new NCompress::CCopyCoder();
  CMyComPtr<ICompressCoder> copyCoder = copyCoderSpec;

  CLocalProgress *lps = new CLocalProgress;
  CMyComPtr<ICompressProgressInfo> progress = lps;
  lps->Init(extractCallback, false);

  CLimitedSequentialInStream *streamSpec = new CLimitedSequentialInStream;
  CMyComPtr<ISequentialInStream> inStream(streamSpec);
  streamSpec->SetStream(_inStream);

  for (i = 0; i < numItems; i++, currentTotalSize += currentItemSize)
  {
    lps->InSize = lps->OutSize = currentTotalSize;
    RINOK(lps->SetCur());
    Int32 askMode = testMode ?
        NExtract::NAskMode::kTest :
        NExtract::NAskMode::kExtract;
    UInt32 index = allFilesMode ? i : indices[i];
    const CSection &item = _sections[index];
    currentItemSize = item.GetPackSize();

    CMyComPtr<ISequentialOutStream> outStream;
    RINOK(extractCallback->GetStream(index, &outStream, askMode));
    if (!testMode && !outStream)
      continue;
    
    RINOK(extractCallback->PrepareOperation(askMode));
    RINOK(_inStream->Seek(item.Pa, STREAM_SEEK_SET, NULL));
    streamSpec->Init(currentItemSize);
    RINOK(copyCoder->Code(inStream, outStream, NULL, NULL, progress));
    outStream.Release();
    RINOK(extractCallback->SetOperationResult(copyCoderSpec->TotalSize == currentItemSize ?
        NExtract::NOperationResult::kOK:
        NExtract::NOperationResult::kDataError));
  }
  return S_OK;
  COM_TRY_END
}

static IInArchive *CreateArc() { return new CHandler; }

static CArcInfo g_ArcInfo =
  { L"MachO", L"", 0, 0xDF, { 0 }, 0, false, CreateArc, 0 };

REGISTER_ARC(Macho)

}}
<file_sep>/FBReaderJ/jni/LineBreak/TxtParser.h

#ifndef HW_TXTPARSER_H
#define HW_TXTPARSER_H


#include <jni.h>



#ifdef __cplusplus
extern "C"
{
#endif

JNIEXPORT void JNICALL Java_org_parser_txt_TxtParser_Parser(JNIEnv *env, jobject thiz, jobject thisParser,jstring strPath);

#ifdef __cplusplus
}
#endif

#endif
<file_sep>/7-Zip/CPP/7zip/Archive/Wim/WimIn.h
// Archive/WimIn.h

#ifndef __ARCHIVE_WIM_IN_H
#define __ARCHIVE_WIM_IN_H

#include "Common/Buffer.h"
#include "Common/MyString.h"

#include "../../Compress/CopyCoder.h"
#include "../../Compress/LzxDecoder.h"

namespace NArchive {
namespace NWim {

namespace NXpress {

class CBitStream
{
  CInBuffer m_Stream;
  UInt32 m_Value;
  unsigned m_BitPos;
public:
  bool Create(UInt32 bufferSize) { return m_Stream.Create(bufferSize); }
  void SetStream(ISequentialInStream *s) { m_Stream.SetStream(s); }
  void ReleaseStream() { m_Stream.ReleaseStream(); }

  void Init() { m_Stream.Init(); m_BitPos = 0; }
  // UInt64 GetProcessedSize() const { return m_Stream.GetProcessedSize() - m_BitPos / 8; }
  Byte DirectReadByte() { return m_Stream.ReadByte(); }

  void Normalize()
  {
    if (m_BitPos < 16)
    {
      Byte b0 = m_Stream.ReadByte();
      Byte b1 = m_Stream.ReadByte();
      m_Value = (m_Value << 8) | b1;
      m_Value = (m_Value << 8) | b0;
      m_BitPos += 16;
    }
  }

  UInt32 GetValue(unsigned numBits)
  {
    Normalize();
    return (m_Value >> (m_BitPos - numBits)) & ((1 << numBits) - 1);
  }
  
  void MovePos(unsigned numBits) { m_BitPos -= numBits; }
  
  UInt32 ReadBits(unsigned numBits)
  {
    UInt32 res = GetValue(numBits);
    m_BitPos -= numBits;
    return res;
  }
};

const int kNumHuffmanBits = 16;
const UInt32 kMatchMinLen = 3;
const UInt32 kNumLenSlots = 16;
const UInt32 kNumPosSlots = 16;
const UInt32 kNumPosLenSlots = kNumPosSlots * kNumLenSlots;
const UInt32 kMainTableSize = 256 + kNumPosLenSlots;

class CDecoder
{
  CBitStream m_InBitStream;
  CLzOutWindow m_OutWindowStream;
  NCompress::NHuffman::CDecoder<kNumHuffmanBits, kMainTableSize> m_MainDecoder;

  HRESULT CodeSpec(UInt32 size);
  HRESULT CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream, UInt32 outSize);
public:
  void ReleaseStreams()
  {
    m_OutWindowStream.ReleaseStream();
    m_InBitStream.ReleaseStream();
  }
  HRESULT Flush() { return m_OutWindowStream.Flush(); }
  HRESULT Code(ISequentialInStream *inStream, ISequentialOutStream *outStream, UInt32 outSize);
};

}

namespace NResourceFlags
{
  const Byte Compressed = 4;
  const Byte kMetadata = 2;
}

struct CResource
{
  UInt64 PackSize;
  UInt64 Offset;
  UInt64 UnpackSize;
  Byte Flags;

  void Parse(const Byte *p);
  bool IsCompressed() const { return (Flags & NResourceFlags::Compressed) != 0; }
  bool IsMetadata() const { return (Flags & NResourceFlags::kMetadata) != 0; }
  bool IsEmpty() const { return (UnpackSize == 0); }
};

namespace NHeaderFlags
{
  const UInt32 kCompression = 2;
  const UInt32 kSpanned = 8;
  const UInt32 kRpFix = 0x80;
  const UInt32 kXPRESS = 0x20000;
  const UInt32 kLZX = 0x40000;
}

struct CHeader
{
  UInt32 Flags;
  UInt32 Version;
  // UInt32 ChunkSize;
  UInt16 PartNumber;
  UInt16 NumParts;
  UInt32 NumImages;
  Byte Guid[16];
  
  CResource OffsetResource;
  CResource XmlResource;
  CResource MetadataResource;
  /*
  CResource IntegrityResource;
  UInt32 BootIndex;
  */

  HRESULT Parse(const Byte *p);
  bool IsCompressed() const { return (Flags & NHeaderFlags::kCompression) != 0; }
  bool IsSupported() const { return (!IsCompressed() || (Flags & NHeaderFlags::kLZX) != 0 || (Flags & NHeaderFlags::kXPRESS) != 0 ) ; }
  bool IsLzxMode() const { return (Flags & NHeaderFlags::kLZX) != 0; }
  bool IsSpanned() const { return (!IsCompressed() || (Flags & NHeaderFlags::kSpanned) != 0); }

  bool IsNewVersion()const { return (Version > 0x010C00); }

  bool AreFromOnArchive(const CHeader &h)
  {
    return (memcmp(Guid, h.Guid, sizeof(Guid)) == 0) && (h.NumParts == NumParts);
  }
};

const UInt32 kHashSize = 20;
const UInt32 kStreamInfoSize = 24 + 2 + 4 + kHashSize;

struct CStreamInfo
{
  CResource Resource;
  UInt16 PartNumber;
  UInt32 RefCount;
  BYTE Hash[kHashSize];
};

struct CItem
{
  UString Name;
  UInt32 Attrib;
  // UInt32 SecurityId;
  BYTE Hash[kHashSize];
  FILETIME CTime;
  FILETIME ATime;
  FILETIME MTime;
  // UInt32 ReparseTag;
  // UInt64 HardLink;
  // UInt16 NumStreams;
  // UInt16 ShortNameLen;
  int StreamIndex;
  bool HasMetadata;
  CItem(): HasMetadata(true), StreamIndex(-1) {}
  bool isDir() const { return HasMetadata && ((Attrib & 0x10) != 0); }
  bool HasStream() const
  {
    for (int i = 0; i < kHashSize; i++)
      if (Hash[i] != 0)
        return true;
    return false;
  }
};

struct CDatabase
{
  CRecordVector<CStreamInfo> Streams;
  CObjectVector<CItem> Items;

  UInt64 GetUnpackSize() const
  {
    UInt64 res = 0;
    for (int i = 0; i < Streams.Size(); i++)
      res += Streams[i].Resource.UnpackSize;
    return res;
  }

  UInt64 GetPackSize() const
  {
    UInt64 res = 0;
    for (int i = 0; i < Streams.Size(); i++)
      res += Streams[i].Resource.PackSize;
    return res;
  }

  void Clear()
  {
    Streams.Clear();
    Items.Clear();
  }
};

HRESULT ReadHeader(IInStream *inStream, CHeader &header);
HRESULT OpenArchive(IInStream *inStream, const CHeader &header, CByteBuffer &xml, CDatabase &database);
HRESULT SortDatabase(CDatabase &database);

class CUnpacker
{
  NCompress::CCopyCoder *copyCoderSpec;
  CMyComPtr<ICompressCoder> copyCoder;

  NCompress::NLzx::CDecoder *lzxDecoderSpec;
  CMyComPtr<ICompressCoder> lzxDecoder;

  NXpress::CDecoder xpressDecoder;

  CByteBuffer sizesBuf;
  HRESULT Unpack(IInStream *inStream, const CResource &res, bool lzxMode,
      ISequentialOutStream *outStream, ICompressProgressInfo *progress);
public:
  HRESULT Unpack(IInStream *inStream, const CResource &res, bool lzxMode,
      ISequentialOutStream *outStream, ICompressProgressInfo *progress, Byte *digest);
};

}}
  
#endif
<file_sep>/7-Zip/CPP/7zip/Archive/Tar/TarUpdate.cpp
// TarUpdate.cpp

#include "StdAfx.h"

#include "../../Common/LimitedStreams.h"
#include "../../Common/ProgressUtils.h"

#include "../../Compress/CopyCoder.h"

#include "TarOut.h"
#include "TarUpdate.h"

namespace NArchive {
namespace NTar {

HRESULT UpdateArchive(IInStream *inStream, ISequentialOutStream *outStream,
    const CObjectVector<NArchive::NTar::CItemEx> &inputItems,
    const CObjectVector<CUpdateItem> &updateItems,
    IArchiveUpdateCallback *updateCallback)
{
  COutArchive outArchive;
  outArchive.Create(outStream);

  UInt64 complexity = 0;

  int i;
  for(i = 0; i < updateItems.Size(); i++)
  {
    const CUpdateItem &ui = updateItems[i];
    if (ui.NewData)
      complexity += ui.Size;
    else
      complexity += inputItems[ui.IndexInArchive].GetFullSize();
  }

  RINOK(updateCallback->SetTotal(complexity));

  NCompress::CCopyCoder *copyCoderSpec = new NCompress::CCopyCoder;
  CMyComPtr<ICompressCoder> copyCoder = copyCoderSpec;

  CLocalProgress *lps = new CLocalProgress;
  CMyComPtr<ICompressProgressInfo> progress = lps;
  lps->Init(updateCallback, true);

  CLimitedSequentialInStream *streamSpec = new CLimitedSequentialInStream;
  CMyComPtr<CLimitedSequentialInStream> inStreamLimited(streamSpec);
  streamSpec->SetStream(inStream);

  complexity = 0;

  for(i = 0; i < updateItems.Size(); i++)
  {
    lps->InSize = lps->OutSize = complexity;
    RINOK(lps->SetCur());

    const CUpdateItem &ui = updateItems[i];
    CItem item;
    if (ui.NewProps)
    {
      item.Mode = ui.Mode;
      item.Name = ui.Name;
      item.User = ui.User;
      item.Group = ui.Group;
      if (ui.IsDir)
      {
        item.LinkFlag = NFileHeader::NLinkFlag::kDirectory;
        item.Size = 0;
      }
      else
      {
        item.LinkFlag = NFileHeader::NLinkFlag::kNormal;
        item.Size = ui.Size;
      }
      item.MTime = ui.Time;
      item.DeviceMajorDefined = false;
      item.DeviceMinorDefined = false;
      item.UID = 0;
      item.GID = 0;
      memmove(item.Magic, NFileHeader::NMagic::kEmpty, 8);
    }
    else
      item = inputItems[ui.IndexInArchive];

    if (ui.NewData)
    {
      item.Size = ui.Size;
      if (item.Size == (UInt64)(Int64)-1)
        return E_INVALIDARG;
    }
    else
      item.Size = inputItems[ui.IndexInArchive].Size;
  
    if (ui.NewData)
    {
      CMyComPtr<ISequentialInStream> fileInStream;
      HRESULT res = updateCallback->GetStream(ui.IndexInClient, &fileInStream);
      if (res != S_FALSE)
      {
        RINOK(res);
        RINOK(outArchive.WriteHeader(item));
        if (!ui.IsDir)
        {
          RINOK(copyCoder->Code(fileInStream, outStream, NULL, NULL, progress));
          if (copyCoderSpec->TotalSize != item.Size)
            return E_FAIL;
          RINOK(outArchive.FillDataResidual(item.Size));
        }
      }
      complexity += ui.Size;
      RINOK(updateCallback->SetOperationResult(NArchive::NUpdate::NOperationResult::kOK));
    }
    else
    {
      const CItemEx &existItemInfo = inputItems[ui.IndexInArchive];
      UInt64 size;
      if (ui.NewProps)
      {
        RINOK(outArchive.WriteHeader(item));
        RINOK(inStream->Seek(existItemInfo.GetDataPosition(), STREAM_SEEK_SET, NULL));
        size = existItemInfo.Size;
      }
      else
      {
        RINOK(inStream->Seek(existItemInfo.HeaderPosition, STREAM_SEEK_SET, NULL));
        size = existItemInfo.GetFullSize();
      }
      streamSpec->Init(size);

      RINOK(copyCoder->Code(inStreamLimited, outStream, NULL, NULL, progress));
      if (copyCoderSpec->TotalSize != size)
        return E_FAIL;
      RINOK(outArchive.FillDataResidual(existItemInfo.Size));
      complexity += size;
    }
  }
  return outArchive.WriteFinishHeader();
}

}}
<file_sep>/FingerSuite/FingerNotificationRES/resource.h
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by FingerNotificationRES.rc
//
#define IDS_NO_NEW_NOTIFICATIONS        102
#define IDS_VOLUME                      103
#define IDS_BATTERY                     104
#define IDR_MAINFRAME                   128
#define ID_MENU_SHOWORIGINAL            40003
#define ID_MENU_ABOUT                   40004
#define ID_MENU_EXIT                    40006

// Next default values for new objects
// 
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE        102
#define _APS_NEXT_COMMAND_VALUE         40009
#define _APS_NEXT_CONTROL_VALUE         1001
#define _APS_NEXT_SYMED_VALUE           101
#endif
#endif
<file_sep>/SQLCEHelper/Source/Currency.h

#pragma once

class CCurrency
{
private:
	CY	m_cy;

public:
	CCurrency(const CY& cy) : m_cy(cy) {}
	CCurrency(const CCurrency& cy) : m_cy(cy) {}

	CCurrency& operator=(const CY& cy);
	CCurrency& operator=(const CCurrency& cy);

	bool operator==(const CCurrency& cy) const	{ return m_cy.int64 == cy.m_cy.int64;	}
	bool operator!=(const CCurrency& cy) const	{ return m_cy.int64 != cy.m_cy.int64;	}
	bool operator< (const CCurrency& cy) const	{ return m_cy.int64 > cy.m_cy.int64;	}
	bool operator> (const CCurrency& cy) const	{ return m_cy.int64 < cy.m_cy.int64;	}
	bool operator<=(const CCurrency& cy) const	{ return m_cy.int64 <= cy.m_cy.int64;	}
	bool operator>=(const CCurrency& cy) const	{ return m_cy.int64 >= cy.m_cy.int64;	}
	
	bool operator! () const { return !m_cy.int64; }

	CCurrency	operator+(const CCurrency& cy) const;
	CCurrency	operator-(const CCurrency& cy) const;
	CCurrency	operator-() const;
	CCurrency	operator*(int nMultiplier) const;
	CCurrency	operator/(int nDivider) const;

	const CCurrency&	operator+=(const CCurrency& cy)	{ m_cy.int64 += cy.m_cy.int64; return *this;	}
	const CCurrency&	operator-=(const CCurrency& cy)	{ m_cy.int64 -= cy.m_cy.int64; return *this;	}
	const CCurrency&	operator*=(int nMultiplier)		{ m_cy.int64 *= nMultiplier; return *this;		}
	const CCurrency&	operator/=(int nDivider)		{ m_cy.int64 /= nDivider; return *this;			}

	operator CY() const			{ return m_cy; }
	operator double() const		{ return ((double)m_cy.int64) / 10000;	}
	operator float() const		{ return ((float)m_cy.int64) / 10000;	}

	enum NumberFormat
	{
		None,
		Number,
		Currency
	};

	CString Format(NumberFormat fmt = None, LCID lcid = LOCALE_SYSTEM_DEFAULT);
};


inline CCurrency& CCurrency::operator=(const CY &cy)
{
	m_cy = cy;
	return *this;
}


inline CCurrency& CCurrency::operator=(const CCurrency &cy)
{
	if(this != &cy)
		m_cy = cy.m_cy;
	return *this;
}


inline CCurrency CCurrency::operator +(const CCurrency& cy) const
{
	CY	val;

	val.int64 = m_cy.int64 + cy.m_cy.int64;

	return val;
}


inline CCurrency CCurrency::operator -(const CCurrency& cy) const
{
	CY	val;

	val.int64 = m_cy.int64 - cy.m_cy.int64;

	return val;
}


inline CCurrency CCurrency::operator *(int nMultiplier) const
{
	CY	val;

	val.int64 = m_cy.int64 * nMultiplier;

	return val;
}


inline CCurrency CCurrency::operator /(int nDivider) const
{
	CY	val;

	val.int64 = m_cy.int64 / nDivider;

	return val;
}


// CCurrency::operator-
//
//		Unary opertor -
//
inline CCurrency CCurrency::operator-() const
{
	CY	val;

	val.int64 = -m_cy.int64;

	return val;
}<file_sep>/SQLCEHelper/Source/Currency.cpp

#include "stdafx.h"
#include "Currency.h"


CString CCurrency::Format(NumberFormat fmt, LCID lcid)
{
	TCHAR		szNum[32];					// Must hold between 922337203685477.5807 and -922337203685477.5808
	TCHAR*		psz		= szNum + 31;		// Set psz to last char
	__int64		ii		= m_cy.int64 < 0 ? -m_cy.int64 : m_cy.int64;
	int			nDec	= 4;				// Four decimals max

	*psz = 0;								// Set terminating null
	do
	{
		--psz;								// Move back
		if(nDec-- == 0)
			*psz = _T('.');					// Decimal point
		else
		{
			unsigned lsd = (unsigned)(ii % 10);		// Get least significant
													// digit
			ii /= 10;								// Prepare for next most
													// significant digit
			*psz = _T('0') + lsd;					// Place the digit
		}
	} while(ii != 0);

	// Check if we need to add trailing zeroes
	if(nDec >= 0)
	{
		while(nDec-- > 0)
			*--psz = _T('0');
		*--psz = _T('.');
	}

	if(m_cy.int64 < 0)
		*--psz = _T('-');

	if(fmt == Number)
	{
		TCHAR	szFmt[32];

		GetNumberFormat(LOCALE_USER_DEFAULT, NULL, psz, NULL, szFmt, 32);
		return CString(szFmt);
	}
	
	if(fmt == Currency)
	{
		TCHAR	szFmt[32];

		GetCurrencyFormat(LOCALE_USER_DEFAULT, NULL, psz, NULL, szFmt, 32);
		return CString(szFmt);
	}

	return CString(psz);
}
<file_sep>/FingerSuite/FingerMsgboxRES/resource.h
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by FingerMsgboxRES.rc
//
#define IDR_MAINFRAME                   128
#define IDS_OK                          129
#define IDS_CANCEL                      130
#define IDS_YES                         131
#define IDS_MENU_ABOUT                  132
#define IDS_MENU_EXIT                   133
#define IDS_SOFTKEY_CLOSE               134
#define IDS_NO                          136
#define IDS_ABORT                       137
#define IDS_RETRY                       138
#define IDS_IGNORE                      139
#define ID_MENU_SHOWORIGINAL            32774
#define ID_MENU_EXIT                    32776
#define ID_MENU_ABOUT                   32779
#define ID_MENU_ADDTOEXCLUSIONLIST      40001
#define ID_MENU_ADDTOWNDEXCLUSIONLIST   40002

// Next default values for new objects
// 
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE        102
#define _APS_NEXT_COMMAND_VALUE         40002
#define _APS_NEXT_CONTROL_VALUE         1001
#define _APS_NEXT_SYMED_VALUE           101
#endif
#endif
<file_sep>/FingerSuite/FingerMsgBox/resource.h
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by FingerMsgBox.rc
//
#define IDS_LVK_EXIT                    98
#define IDS_RVK_MENU                    99
#define IDR_MAINFRAME                   128
#define IDS_OK                          129
#define IDS_CANCEL                      130
#define IDS_YES                         131
#define IDS_MENU_ABOUT                  132
#define IDS_MENU_EXIT                   133
#define IDS_SOFTKEY_CLOSE               134
#define IDS_UNKNOWN_ERROR               135
#define IDS_NO                          136
#define IDS_ABORT                       137
#define IDS_RETRY                       138
#define IDS_IGNORE                      139
#define IDR_MENU1                       202
#define FM_IDW_MENU_BAR                 0xE803
#define ID_MENU_SHOWORIGINAL            32774
#define ID_MENU_EXIT                    32776
#define ID_MENU_ABOUT                   32779
#define ID_MENU_ADDTOEXCLUSIONLIST      40001
#define ID_MENU_ADDTOWNDEXCLUSIONLIST   40002



// Next default values for new objects
// 
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE        203
#define _APS_NEXT_COMMAND_VALUE         32775
#define _APS_NEXT_CONTROL_VALUE         1000
#define _APS_NEXT_SYMED_VALUE           101
#endif
#endif
<file_sep>/7-Zip/CPP/7zip/UI/FileManager/PanelListNotify.cpp
// PanelListNotify.cpp

#include "StdAfx.h"

#include "resource.h"

#include "Common/IntToString.h"
#include "Common/StringConvert.h"

#include "Windows/PropVariant.h"
#include "Windows/PropVariantConversions.h"

#include "../Common/PropIDUtils.h"
#include "../../PropID.h"

#include "Panel.h"
#include "FormatUtils.h"

using namespace NWindows;

/*
static UString ConvertSizeToStringShort(UInt64 value)
{
  wchar_t s[32];
  wchar_t c, c2 = L'B';
  if (value < (UInt64)10000)
  {
    c = L'B';
    c2 = L'\0';
  }
  else if (value < ((UInt64)10000 << 10))
  {
    value >>= 10;
    c = L'K';
  }
  else if (value < ((UInt64)10000 << 20))
  {
    value >>= 20;
    c = L'M';
  }
  else
  {
    value >>= 30;
    c = L'G';
  }
  ConvertUInt64ToString(value, s);
  int p = MyStringLen(s);
  s[p++] = L' ';
  s[p++] = c;
  s[p++] = c2;
  s[p++] = L'\0';
  return s;
}
*/

UString ConvertSizeToString(UInt64 value)
{
  wchar_t s[32];
  ConvertUInt64ToString(value, s);
  int i = MyStringLen(s);
  int pos = sizeof(s) / sizeof(s[0]);
  s[--pos] = L'\0';
  while (i > 3)
  {
    s[--pos] = s[--i];
    s[--pos] = s[--i];
    s[--pos] = s[--i];
    s[--pos] = L' ';
  }
  while (i > 0)
    s[--pos] = s[--i];
  return s + pos;
}

LRESULT CPanel::SetItemText(LVITEMW &item)
{
  if (_dontShowMode)
    return 0;

  UINT32 realIndex = GetRealIndex(item);
  /*
  if ((item.mask & LVIF_IMAGE) != 0)
  {
    bool defined  = false;
    CComPtr<IFolderGetSystemIconIndex> folderGetSystemIconIndex;
    _folder.QueryInterface(&folderGetSystemIconIndex);
    if (folderGetSystemIconIndex)
    {
      folderGetSystemIconIndex->GetSystemIconIndex(index, &item.iImage);
      defined = (item.iImage > 0);
    }
    if (!defined)
    {
      NCOM::CPropVariant prop;
      _folder->GetProperty(index, kpidAttrib, &prop);
      UINT32 attrib = 0;
      if (prop.vt == VT_UI4)
        attrib = prop.ulVal;
      else if (IsItemFolder(index))
        attrib |= FILE_ATTRIBUTE_DIRECTORY;
      if (_currentFolderPrefix.IsEmpty())
        throw 1;
      else
        item.iImage = _extToIconMap.GetIconIndex(attrib, GetSystemString(GetItemName(index)));
    }
    // item.iImage = 1;
  }
  */

  if ((item.mask & LVIF_TEXT) == 0)
    return 0;

  if (realIndex == kParentIndex)
    return 0;
  UString s;
  UINT32 subItemIndex = item.iSubItem;
  PROPID propID = _visibleProperties[subItemIndex].ID;
  /*
  {
    NCOM::CPropVariant property;
    if (propID == kpidType)
      string = GetFileType(index);
    else
    {
      HRESULT result = m_ArchiveFolder->GetProperty(index, propID, &property);
      if (result != S_OK)
      {
        // PrintMessage("GetPropertyValue error");
        return 0;
      }
      string = ConvertPropertyToString(property, propID, false);
    }
  }
  */
  // const NFind::CFileInfo &aFileInfo = m_Files[index];

  NCOM::CPropVariant prop;
  /*
  bool needRead = true;
  if (propID == kpidSize)
  {
    CComPtr<IFolderGetItemFullSize> getItemFullSize;
    if (_folder.QueryInterface(&getItemFullSize) == S_OK)
    {
      if (getItemFullSize->GetItemFullSize(index, &prop) == S_OK)
        needRead = false;
    }
  }
  if (needRead)
  */

  if (_folder->GetProperty(realIndex, propID, &prop) != S_OK)
      throw 2723407;

  if ((prop.vt == VT_UI8 || prop.vt == VT_UI4) && (
      propID == kpidSize ||
      propID == kpidPackSize ||
      propID == kpidNumSubDirs ||
      propID == kpidNumSubFiles ||
      propID == kpidPosition ||
      propID == kpidNumBlocks ||
      propID == kpidClusterSize ||
      propID == kpidTotalSize ||
      propID == kpidFreeSpace
      ))
    s = ConvertSizeToString(ConvertPropVariantToUInt64(prop));
  else
  {
    s = ConvertPropertyToString(prop, propID, false);
    s.Replace(wchar_t(0xA), L' ');
    s.Replace(wchar_t(0xD), L' ');
  }
  int size = item.cchTextMax;
  if (size > 0)
  {
    if (s.Length() + 1 > size)
      s = s.Left(size - 1);
    MyStringCopy(item.pszText, (const wchar_t *)s);
  }
  return 0;
}

#ifndef UNDER_CE
extern DWORD g_ComCtl32Version;
#endif

void CPanel::OnItemChanged(NMLISTVIEW *item)
{
  int index = (int)item->lParam;
  if (index == kParentIndex)
    return;
  bool oldSelected = (item->uOldState & LVIS_SELECTED) != 0;
  bool newSelected = (item->uNewState & LVIS_SELECTED) != 0;
  // Don't change this code. It works only with such check
  if (oldSelected != newSelected)
    _selectedStatusVector[index] = newSelected;
}

extern bool g_LVN_ITEMACTIVATE_Support;

void CPanel::OnNotifyActivateItems()
{
  // bool leftCtrl = (::GetKeyState(VK_LCONTROL) & 0x8000) != 0;
  // bool rightCtrl = (::GetKeyState(VK_RCONTROL) & 0x8000) != 0;
  bool alt = (::GetKeyState(VK_MENU) & 0x8000) != 0;
  bool ctrl = (::GetKeyState(VK_CONTROL) & 0x8000) != 0;
  bool shift = (::GetKeyState(VK_SHIFT) & 0x8000) != 0;
  if (!shift && alt && !ctrl)
    Properties();
  else
    OpenSelectedItems(!shift || alt || ctrl);
}

bool CPanel::OnNotifyList(LPNMHDR header, LRESULT &result)
{
  switch(header->code)
  {
    case LVN_ITEMCHANGED:
    {
      if (_enableItemChangeNotify)
      {
        if (!_mySelectMode)
          OnItemChanged((LPNMLISTVIEW)header);
        RefreshStatusBar();
      }
      return false;
    }
    /*

    case LVN_ODSTATECHANGED:
      {
      break;
      }
    */

    case LVN_GETDISPINFOW:
    {
      LV_DISPINFOW *dispInfo = (LV_DISPINFOW *)header;

      //is the sub-item information being requested?

      if ((dispInfo->item.mask & LVIF_TEXT) != 0 ||
        (dispInfo->item.mask & LVIF_IMAGE) != 0)
        SetItemText(dispInfo->item);
      return false;
    }
    case LVN_KEYDOWN:
    {
      bool boolResult = OnKeyDown(LPNMLVKEYDOWN(header), result);
      RefreshStatusBar();
      return boolResult;
    }

    case LVN_COLUMNCLICK:
      OnColumnClick(LPNMLISTVIEW(header));
      return false;

    case LVN_ITEMACTIVATE:
      if (g_LVN_ITEMACTIVATE_Support)
      {
        OnNotifyActivateItems();
        return false;
      }
      break;
    case NM_DBLCLK:
    case NM_RETURN:
      if (!g_LVN_ITEMACTIVATE_Support)
      {
        OnNotifyActivateItems();
        return false;
      }
      break;

    case NM_RCLICK:
      RefreshStatusBar();
      break;

    /*
      return OnRightClick((LPNMITEMACTIVATE)header, result);
    */
      /*
      case NM_CLICK:
      SendRefreshStatusBarMessage();
      return 0;
      
        // TODO : Handler default action...
        return 0;
        case LVN_ITEMCHANGED:
        {
        NMLISTVIEW *pNMLV = (NMLISTVIEW *) lpnmh;
        SelChange(pNMLV);
        return TRUE;
        }
        case NM_SETFOCUS:
        return onSetFocus(NULL);
        case NM_KILLFOCUS:
        return onKillFocus(NULL);
      */
    case NM_CLICK:
    {
      // we need SetFocusToList, if we drag-select items from other panel.
      SetFocusToList();
      RefreshStatusBar();
      if (_mySelectMode)
        #ifndef UNDER_CE
        if (g_ComCtl32Version >= MAKELONG(71, 4))
        #endif
          OnLeftClick((MY_NMLISTVIEW_NMITEMACTIVATE *)header);
      return false;
    }
    case LVN_BEGINLABELEDITW:
      result = OnBeginLabelEdit((LV_DISPINFOW *)header);
      return true;
    case LVN_ENDLABELEDITW:
      result = OnEndLabelEdit((LV_DISPINFOW *)header);
      return true;

    case NM_CUSTOMDRAW:
    {
      if (_mySelectMode)
        return OnCustomDraw((LPNMLVCUSTOMDRAW)header, result);
      break;
    }
    case LVN_BEGINDRAG:
    {
      OnDrag((LPNMLISTVIEW)header);
      RefreshStatusBar();
      break;
    }
    // case LVN_BEGINRDRAG:
  }
  return false;
}

bool CPanel::OnCustomDraw(LPNMLVCUSTOMDRAW lplvcd, LRESULT &result)
{
  switch(lplvcd->nmcd.dwDrawStage)
  {
  case CDDS_PREPAINT :
    result = CDRF_NOTIFYITEMDRAW;
    return true;
    
  case CDDS_ITEMPREPAINT:
    /*
    SelectObject(lplvcd->nmcd.hdc,
    GetFontForItem(lplvcd->nmcd.dwItemSpec,
    lplvcd->nmcd.lItemlParam) );
    lplvcd->clrText = GetColorForItem(lplvcd->nmcd.dwItemSpec,
    lplvcd->nmcd.lItemlParam);
    lplvcd->clrTextBk = GetBkColorForItem(lplvcd->nmcd.dwItemSpec,
    lplvcd->nmcd.lItemlParam);
    */
    int realIndex = (int)lplvcd->nmcd.lItemlParam;
    bool selected = false;
    if (realIndex != kParentIndex)
      selected = _selectedStatusVector[realIndex];
    if (selected)
      lplvcd->clrTextBk = RGB(255, 192, 192);
    // lplvcd->clrText = RGB(255, 0, 128);
    else
      lplvcd->clrTextBk = _listView.GetBkColor();
    // lplvcd->clrText = RGB(0, 0, 0);
    // result = CDRF_NEWFONT;
    result = CDRF_NOTIFYITEMDRAW;
    return true;
    
    // return false;
    // return true;
    /*
    case CDDS_SUBITEM | CDDS_ITEMPREPAINT:
    if (lplvcd->iSubItem == 0)
    {
    // lplvcd->clrText = RGB(255, 0, 0);
    lplvcd->clrTextBk = RGB(192, 192, 192);
    }
    else
    {
    lplvcd->clrText = RGB(0, 0, 0);
    lplvcd->clrTextBk = RGB(255, 255, 255);
    }
    return true;
    */

        /* At this point, you can change the background colors for the item
        and any subitems and return CDRF_NEWFONT. If the list-view control
        is in report mode, you can simply return CDRF_NOTIFYSUBITEMREDRAW
        to customize the item's subitems individually */
  }
  return false;
}

void CPanel::OnRefreshStatusBar()
{
  CRecordVector<UINT32> indices;
  GetOperatedItemIndices(indices);

  _statusBar.SetText(0, MyFormatNew(IDS_N_SELECTED_ITEMS, 0x02000301, NumberToString(indices.Size())));

  UString selectSizeString;

  if (indices.Size() > 0)
  {
    UInt64 totalSize = 0;
    for (int i = 0; i < indices.Size(); i++)
      totalSize += GetItemSize(indices[i]);
    selectSizeString = ConvertSizeToString(totalSize);
  }
  _statusBar.SetText(1, selectSizeString);

  int focusedItem = _listView.GetFocusedItem();
  UString sizeString;
  UString dateString;
  if (focusedItem >= 0 && _listView.GetSelectedCount() > 0)
  {
    int realIndex = GetRealItemIndex(focusedItem);
    if (realIndex != kParentIndex)
    {
      sizeString = ConvertSizeToString(GetItemSize(realIndex));
      NCOM::CPropVariant prop;
      if (_folder->GetProperty(realIndex, kpidMTime, &prop) == S_OK)
        dateString = ConvertPropertyToString(prop, kpidMTime, false);
    }
  }
  _statusBar.SetText(2, sizeString);
  _statusBar.SetText(3, dateString);
  // _statusBar.SetText(4, nameString);
  // _statusBar2.SetText(1, MyFormatNew(L"{0} bytes", NumberToStringW(totalSize)));
}
<file_sep>/7-Zip/CPP/7zip/UI/FileManager/PropertyName.cpp
// PropertyName.cpp

#include "StdAfx.h"

#include "Common/IntToString.h"

#include "Windows/ResourceString.h"

#include "../../PropID.h"

#include "LangUtils.h"
#include "PropertyName.h"

#include "resource.h"
#include "PropertyNameRes.h"

struct CPropertyIDNamePair
{
  PROPID PropID;
  UINT ResourceID;
  UInt32 LangID;
};

static CPropertyIDNamePair kPropertyIDNamePairs[] =
{
  { kpidPath, IDS_PROP_PATH, 0x02000203 },
  { kpidName, IDS_PROP_NAME, 0x02000204 },
  { kpidExtension, IDS_PROP_EXTENSION, 0x02000205 },
  { kpidIsDir, IDS_PROP_IS_FOLDER, 0x02000206},
  { kpidSize, IDS_PROP_SIZE, 0x02000207},
  { kpidPackSize, IDS_PROP_PACKED_SIZE, 0x02000208 },
  { kpidAttrib, IDS_PROP_ATTRIBUTES, 0x02000209 },
  { kpidCTime, IDS_PROP_CTIME, 0x0200020A },
  { kpidATime, IDS_PROP_ATIME, 0x0200020B },
  { kpidMTime, IDS_PROP_MTIME, 0x0200020C },
  { kpidSolid, IDS_PROP_SOLID, 0x0200020D },
  { kpidCommented, IDS_PROP_C0MMENTED, 0x0200020E },
  { kpidEncrypted, IDS_PROP_ENCRYPTED, 0x0200020F },
  { kpidSplitBefore, IDS_PROP_SPLIT_BEFORE, 0x02000210 },
  { kpidSplitAfter, IDS_PROP_SPLIT_AFTER, 0x02000211 },
  { kpidDictionarySize, IDS_PROP_DICTIONARY_SIZE, 0x02000212 },
  { kpidCRC, IDS_PROP_CRC, 0x02000213 },
  { kpidType, IDS_PROP_FILE_TYPE, 0x02000214},
  { kpidIsAnti, IDS_PROP_ANTI, 0x02000215 },
  { kpidMethod, IDS_PROP_METHOD, 0x02000216 },
  { kpidHostOS, IDS_PROP_HOST_OS, 0x02000217 },
  { kpidFileSystem, IDS_PROP_FILE_SYSTEM, 0x02000218},
  { kpidUser, IDS_PROP_USER, 0x02000219},
  { kpidGroup, IDS_PROP_GROUP, 0x0200021A},
  { kpidBlock, IDS_PROP_BLOCK, 0x0200021B },
  { kpidComment, IDS_PROP_COMMENT, 0x0200021C },
  { kpidPosition, IDS_PROP_POSITION, 0x0200021D },
  { kpidPrefix, IDS_PROP_PREFIX, 0x0200021E },
  { kpidNumSubDirs, IDS_PROP_FOLDERS, 0x0200021F },
  { kpidNumSubFiles, IDS_PROP_FILES, 0x02000220 },
  { kpidUnpackVer, IDS_PROP_VERSION, 0x02000221},
  { kpidVolume, IDS_PROP_VOLUME, 0x02000222},
  { kpidIsVolume, IDS_PROP_IS_VOLUME, 0x02000223},
  { kpidOffset, IDS_PROP_OFFSET, 0x02000224},
  { kpidLinks, IDS_PROP_LINKS, 0x02000225},
  { kpidNumBlocks, IDS_PROP_NUM_BLOCKS, 0x02000226},
  { kpidNumVolumes, IDS_PROP_NUM_VOLUMES, 0x02000227},

  { kpidBit64, IDS_PROP_BIT64, 0x02000229},
  { kpidBigEndian, IDS_PROP_BIG_ENDIAN, 0x0200022A},
  { kpidCpu, IDS_PROP_CPU, 0x0200022B},
  { kpidPhySize, IDS_PROP_PHY_SIZE, 0x0200022C},
  { kpidHeadersSize, IDS_PROP_HEADERS_SIZE, 0x0200022D},
  { kpidChecksum, IDS_PROP_CHECKSUM, 0x0200022E},
  { kpidCharacts, IDS_PROP_CHARACTS, 0x0200022F},
  { kpidVa, IDS_PROP_VA, 0x02000230},
  { kpidId, IDS_PROP_ID, 0x02000231 },
  { kpidShortName, IDS_PROP_SHORT_NAME, 0x02000232 },
  { kpidCreatorApp, IDS_PROP_CREATOR_APP, 0x02000233 },
  { kpidSectorSize, IDS_PROP_SECTOR_SIZE, 0x02000234 },
  { kpidPosixAttrib, IDS_PROP_POSIX_ATTRIB, 0x02000235 },
  { kpidLink, IDS_PROP_LINK, 0x02000236 },
 
  { kpidTotalSize, IDS_PROP_TOTAL_SIZE, 0x03031100 },
  { kpidFreeSpace, IDS_PROP_FREE_SPACE, 0x03031101 },
  { kpidClusterSize, IDS_PROP_CLUSTER_SIZE, 0x03031102},
  { kpidVolumeName, IDS_PROP_VOLUME_NAME, 0x03031103 },

  { kpidLocalName, IDS_PROP_LOCAL_NAME, 0x03031200 },
  { kpidProvider, IDS_PROP_PROVIDER, 0x03031201 }
};

int FindProperty(PROPID propID)
{
  for (int i = 0; i < sizeof(kPropertyIDNamePairs) / sizeof(kPropertyIDNamePairs[0]); i++)
    if (kPropertyIDNamePairs[i].PropID == propID)
      return i;
  return -1;
}

UString GetNameOfProperty(PROPID propID, const wchar_t *name)
{
  int index = FindProperty(propID);
  if (index < 0)
  {
    if (name)
      return name;
    wchar_t s[16];
    ConvertUInt32ToString(propID, s);
    return s;
  }
  const CPropertyIDNamePair &pair = kPropertyIDNamePairs[index];
  return LangString(pair.ResourceID, pair.LangID);
}
<file_sep>/7-Zip/CPP/7zip/UI/FileManager/ClassDefs.cpp
// ClassDefs.cpp

#include "StdAfx.h"

#include "Common/MyInitGuid.h"

#include "PluginInterface.h"
#include "../Agent/Agent.h"

DEFINE_GUID(CLSID_CZipContextMenu,
0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00);
<file_sep>/7-Zip/CPP/7zip/Archive/Zip/ZipOut.cpp
// ZipOut.cpp

#include "StdAfx.h"

#include "../../Common/OffsetStream.h"

#include "ZipOut.h"

namespace NArchive {
namespace NZip {

void COutArchive::Create(IOutStream *outStream)
{
  if (!m_OutBuffer.Create(1 << 16))
    throw CSystemException(E_OUTOFMEMORY);
  m_Stream = outStream;
  m_OutBuffer.SetStream(outStream);
  m_OutBuffer.Init();
  m_BasePosition = 0;
}

void COutArchive::MoveBasePosition(UInt64 distanceToMove)
{
  m_BasePosition += distanceToMove; // test overflow
}

void COutArchive::PrepareWriteCompressedDataZip64(UInt16 fileNameLength, bool isZip64, bool aesEncryption)
{
  m_IsZip64 = isZip64;
  m_ExtraSize = isZip64 ? (4 + 8 + 8) : 0;
  if (aesEncryption)
    m_ExtraSize += 4 + 7;
  m_LocalFileHeaderSize = 4 + NFileHeader::kLocalBlockSize + fileNameLength + m_ExtraSize;
}

void COutArchive::PrepareWriteCompressedData(UInt16 fileNameLength, UInt64 unPackSize, bool aesEncryption)
{
  // We test it to 0xF8000000 to support case when compressed size
  // can be larger than uncompressed size.
  PrepareWriteCompressedDataZip64(fileNameLength, unPackSize >= 0xF8000000, aesEncryption);
}

void COutArchive::PrepareWriteCompressedData2(UInt16 fileNameLength, UInt64 unPackSize, UInt64 packSize, bool aesEncryption)
{
  bool isUnPack64 = unPackSize >= 0xFFFFFFFF;
  bool isPack64 = packSize >= 0xFFFFFFFF;
  bool isZip64 = isPack64 || isUnPack64;
  PrepareWriteCompressedDataZip64(fileNameLength, isZip64, aesEncryption);
}

void COutArchive::WriteBytes(const void *buffer, UInt32 size)
{
  m_OutBuffer.WriteBytes(buffer, size);
  m_BasePosition += size;
}

void COutArchive::WriteByte(Byte b)
{
  WriteBytes(&b, 1);
}

void COutArchive::WriteUInt16(UInt16 value)
{
  for (int i = 0; i < 2; i++)
  {
    WriteByte((Byte)value);
    value >>= 8;
  }
}

void COutArchive::WriteUInt32(UInt32 value)
{
  for (int i = 0; i < 4; i++)
  {
    WriteByte((Byte)value);
    value >>= 8;
  }
}

void COutArchive::WriteUInt64(UInt64 value)
{
  for (int i = 0; i < 8; i++)
  {
    WriteByte((Byte)value);
    value >>= 8;
  }
}

void COutArchive::WriteExtra(const CExtraBlock &extra)
{
  if (extra.SubBlocks.Size() != 0)
  {
    for (int i = 0; i < extra.SubBlocks.Size(); i++)
    {
      const CExtraSubBlock &subBlock = extra.SubBlocks[i];
      WriteUInt16(subBlock.ID);
      WriteUInt16((UInt16)subBlock.Data.GetCapacity());
      WriteBytes(subBlock.Data, (UInt32)subBlock.Data.GetCapacity());
    }
  }
}

void COutArchive::SeekTo(UInt64 offset)
{
  HRESULT res = m_Stream->Seek(offset, STREAM_SEEK_SET, NULL);
  if (res != S_OK)
    throw CSystemException(res);
}

void COutArchive::WriteLocalHeader(const CLocalItem &item)
{
  SeekTo(m_BasePosition);
  
  bool isZip64 = m_IsZip64 || item.PackSize >= 0xFFFFFFFF || item.UnPackSize >= 0xFFFFFFFF;
  
  WriteUInt32(NSignature::kLocalFileHeader);
  {
    Byte ver = item.ExtractVersion.Version;
    if (isZip64 && ver < NFileHeader::NCompressionMethod::kExtractVersion_Zip64)
      ver = NFileHeader::NCompressionMethod::kExtractVersion_Zip64;
    WriteByte(ver);
  }
  WriteByte(item.ExtractVersion.HostOS);
  WriteUInt16(item.Flags);
  WriteUInt16(item.CompressionMethod);
  WriteUInt32(item.Time);
  WriteUInt32(item.FileCRC);
  WriteUInt32(isZip64 ? 0xFFFFFFFF: (UInt32)item.PackSize);
  WriteUInt32(isZip64 ? 0xFFFFFFFF: (UInt32)item.UnPackSize);
  WriteUInt16((UInt16)item.Name.Length());
  {
    UInt16 localExtraSize = (UInt16)((isZip64 ? (4 + 16): 0) + item.LocalExtra.GetSize());
    if (localExtraSize > m_ExtraSize)
      throw CSystemException(E_FAIL);
  }
  WriteUInt16((UInt16)m_ExtraSize); // test it;
  WriteBytes((const char *)item.Name, item.Name.Length());

  UInt32 extraPos = 0;
  if (isZip64)
  {
    extraPos += 4 + 16;
    WriteUInt16(NFileHeader::NExtraID::kZip64);
    WriteUInt16(16);
    WriteUInt64(item.UnPackSize);
    WriteUInt64(item.PackSize);
  }

  WriteExtra(item.LocalExtra);
  extraPos += (UInt32)item.LocalExtra.GetSize();
  for (; extraPos < m_ExtraSize; extraPos++)
    WriteByte(0);

  m_OutBuffer.FlushWithCheck();
  MoveBasePosition(item.PackSize);
  SeekTo(m_BasePosition);
}

void COutArchive::WriteCentralHeader(const CItem &item)
{
  bool isUnPack64 = item.UnPackSize >= 0xFFFFFFFF;
  bool isPack64 = item.PackSize >= 0xFFFFFFFF;
  bool isPosition64 = item.LocalHeaderPosition >= 0xFFFFFFFF;
  bool isZip64  = isPack64 || isUnPack64 || isPosition64;
  
  WriteUInt32(NSignature::kCentralFileHeader);
  WriteByte(item.MadeByVersion.Version);
  WriteByte(item.MadeByVersion.HostOS);
  {
    Byte ver = item.ExtractVersion.Version;
    if (isZip64 && ver < NFileHeader::NCompressionMethod::kExtractVersion_Zip64)
      ver = NFileHeader::NCompressionMethod::kExtractVersion_Zip64;
    WriteByte(ver);
  }
  WriteByte(item.ExtractVersion.HostOS);
  WriteUInt16(item.Flags);
  WriteUInt16(item.CompressionMethod);
  WriteUInt32(item.Time);
  WriteUInt32(item.FileCRC);
  WriteUInt32(isPack64 ? 0xFFFFFFFF: (UInt32)item.PackSize);
  WriteUInt32(isUnPack64 ? 0xFFFFFFFF: (UInt32)item.UnPackSize);
  WriteUInt16((UInt16)item.Name.Length());
  UInt16 zip64ExtraSize = (UInt16)((isUnPack64 ? 8: 0) +  (isPack64 ? 8: 0) + (isPosition64 ? 8: 0));
  const UInt16 kNtfsExtraSize = 4 + 2 + 2 + (3 * 8);
  UInt16 centralExtraSize = (UInt16)(isZip64 ? (4 + zip64ExtraSize) : 0) + (item.NtfsTimeIsDefined ? (4 + kNtfsExtraSize) : 0);
  centralExtraSize = (UInt16)(centralExtraSize + item.CentralExtra.GetSize());
  WriteUInt16(centralExtraSize); // test it;
  WriteUInt16((UInt16)item.Comment.GetCapacity());
  WriteUInt16(0); // DiskNumberStart;
  WriteUInt16(item.InternalAttributes);
  WriteUInt32(item.ExternalAttributes);
  WriteUInt32(isPosition64 ? 0xFFFFFFFF: (UInt32)item.LocalHeaderPosition);
  WriteBytes((const char *)item.Name, item.Name.Length());
  if (isZip64)
  {
    WriteUInt16(NFileHeader::NExtraID::kZip64);
    WriteUInt16(zip64ExtraSize);
    if(isUnPack64)
      WriteUInt64(item.UnPackSize);
    if(isPack64)
      WriteUInt64(item.PackSize);
    if(isPosition64)
      WriteUInt64(item.LocalHeaderPosition);
  }
  if (item.NtfsTimeIsDefined)
  {
    WriteUInt16(NFileHeader::NExtraID::kNTFS);
    WriteUInt16(kNtfsExtraSize);
    WriteUInt32(0); // reserved
    WriteUInt16(NFileHeader::NNtfsExtra::kTagTime);
    WriteUInt16(8 * 3);
    WriteUInt32(item.NtfsMTime.dwLowDateTime);
    WriteUInt32(item.NtfsMTime.dwHighDateTime);
    WriteUInt32(item.NtfsATime.dwLowDateTime);
    WriteUInt32(item.NtfsATime.dwHighDateTime);
    WriteUInt32(item.NtfsCTime.dwLowDateTime);
    WriteUInt32(item.NtfsCTime.dwHighDateTime);
  }
  WriteExtra(item.CentralExtra);
  if (item.Comment.GetCapacity() > 0)
    WriteBytes(item.Comment, (UInt32)item.Comment.GetCapacity());
}

void COutArchive::WriteCentralDir(const CObjectVector<CItem> &items, const CByteBuffer &comment)
{
  SeekTo(m_BasePosition);
  
  UInt64 cdOffset = GetCurrentPosition();
  for(int i = 0; i < items.Size(); i++)
    WriteCentralHeader(items[i]);
  UInt64 cd64EndOffset = GetCurrentPosition();
  UInt64 cdSize = cd64EndOffset - cdOffset;
  bool cdOffset64 = cdOffset >= 0xFFFFFFFF;
  bool cdSize64 = cdSize >= 0xFFFFFFFF;
  bool items64 = items.Size() >= 0xFFFF;
  bool isZip64 = (cdOffset64 || cdSize64 || items64);

  if (isZip64)
  {
    WriteUInt32(NSignature::kZip64EndOfCentralDir);
    WriteUInt64(kZip64EcdSize); // ThisDiskNumber = 0;
    WriteUInt16(45); // version
    WriteUInt16(45); // version
    WriteUInt32(0); // ThisDiskNumber = 0;
    WriteUInt32(0); // StartCentralDirectoryDiskNumber;;
    WriteUInt64((UInt64)items.Size());
    WriteUInt64((UInt64)items.Size());
    WriteUInt64((UInt64)cdSize);
    WriteUInt64((UInt64)cdOffset);

    WriteUInt32(NSignature::kZip64EndOfCentralDirLocator);
    WriteUInt32(0); // number of the disk with the start of the zip64 end of central directory
    WriteUInt64(cd64EndOffset);
    WriteUInt32(1); // total number of disks
  }
  WriteUInt32(NSignature::kEndOfCentralDir);
  WriteUInt16(0); // ThisDiskNumber = 0;
  WriteUInt16(0); // StartCentralDirectoryDiskNumber;
  WriteUInt16((UInt16)(items64 ? 0xFFFF: items.Size()));
  WriteUInt16((UInt16)(items64 ? 0xFFFF: items.Size()));
  WriteUInt32(cdSize64 ? 0xFFFFFFFF: (UInt32)cdSize);
  WriteUInt32(cdOffset64 ? 0xFFFFFFFF: (UInt32)cdOffset);
  UInt16 commentSize = (UInt16)comment.GetCapacity();
  WriteUInt16(commentSize);
  if (commentSize > 0)
    WriteBytes((const Byte *)comment, commentSize);
  m_OutBuffer.FlushWithCheck();
}

void COutArchive::CreateStreamForCompressing(IOutStream **outStream)
{
  COffsetOutStream *streamSpec = new COffsetOutStream;
  CMyComPtr<IOutStream> tempStream(streamSpec);
  streamSpec->Init(m_Stream, m_BasePosition + m_LocalFileHeaderSize);
  *outStream = tempStream.Detach();
}

void COutArchive::SeekToPackedDataPosition()
{
  SeekTo(m_BasePosition + m_LocalFileHeaderSize);
}

void COutArchive::CreateStreamForCopying(ISequentialOutStream **outStream)
{
  CMyComPtr<ISequentialOutStream> tempStream(m_Stream);
  *outStream = tempStream.Detach();
}

}}
<file_sep>/SQLCEHelper/Source/Table.cpp

#include "stdafx.h"

using namespace OLEDBCLI;


CTable::CTable(CSession& session, LPCTSTR pszTableName)
:	m_session		(session),
	m_strName		(pszTableName)
{
}


// CTable::~CTable
//
//		Destructor
//
CTable::~CTable()
{
}


// CTable::Open
//
//		Open a table cursor using the optional index name
//
HRESULT CTable::Open(ULONG cPropSets, DBPROPSET rgPropSets[], LPCTSTR pszIndexName, CRowset &rowset)
{
	HRESULT					hr;
	DBID					dbidTable,
							dbidIndex;
	DBID*					pIndexID	= NULL;
	CComPtr<IRowset>		spRowset;
	CComPtr<IUnknown>		spUnknown(m_session);
	CComPtr<IOpenRowset>	spOpenRowset;

	hr = spUnknown->QueryInterface(IID_IOpenRowset, (void**)&spOpenRowset);
	if(FAILED(hr))
		return hr;

	dbidTable.eKind				= DBKIND_NAME;
	dbidTable.uName.pwszName	= (LPOLESTR)GetName();

	if(pszIndexName != NULL)
	{
		dbidIndex.eKind				= DBKIND_NAME;
		dbidIndex.uName.pwszName	= (LPOLESTR)pszIndexName;
		pIndexID = &dbidIndex;
	}

	// Get the IRowset interface
	hr = spOpenRowset->OpenRowset(NULL, &dbidTable, pIndexID, IID_IRowset, cPropSets, rgPropSets, (IUnknown**)&spRowset);
	if(FAILED(hr))
		return hr;

	hr = rowset.Open(spRowset);
	return hr;
}


//-------------------------------------------------------------------------
//
//	CTableDefinition class
//
//-------------------------------------------------------------------------


CTableDefinition::CTableDefinition()
:	m_nColumns		(0),
	m_nPropSets		(0),
	m_nConstraints	(0),
	m_pColumns		(NULL),
	m_pConstraints	(NULL),
	m_pStrings		(NULL),
	m_pPropSets		(NULL)
{
}


CTableDefinition::~CTableDefinition()
{
	Clear();
}


// CTableDefinition::Clear
//
//		Clears the stored table definition data
//
void CTableDefinition::Clear()
{
	DBCOLUMNDESC*		pColCur;
	DBCONSTRAINTDESC*	pConCur;
	DBPROPSET*			pSetCur;
	ULONG				i, j;

	// Free the column items
	for(pColCur = m_pColumns, i = 0; i < m_nColumns; ++i, ++pColCur)
	{
		if(pColCur->pTypeInfo != NULL)
			CoTaskMemFree(pColCur->pTypeInfo);

		if(pColCur->pclsid != NULL)
			CoTaskMemFree(pColCur->pclsid);

		CDbMemory::Free(pColCur->dbcid);

		for(j = 0; j < pColCur->cPropertySets; ++j)
			CDbMemory::Free(&pColCur->rgPropertySets[j]);

		if(pColCur->rgPropertySets != NULL)
			CoTaskMemFree(pColCur->rgPropertySets);
	}

	// Free the constraint items
	for(pConCur = m_pConstraints, i = 0; i < m_nConstraints; ++i, ++pConCur)
	{
		for(j = 0; j < pConCur->cColumns; ++j)
			CDbMemory::Free(pConCur->rgColumnList[j]);
		if(pConCur->cColumns)
			CoTaskMemFree(pConCur->rgColumnList);

		for(j = 0; j < pConCur->cForeignKeyColumns; ++j)
			CDbMemory::Free(pConCur->rgForeignKeyColumnList[j]);
		if(pConCur->cForeignKeyColumns)
			CoTaskMemFree(pConCur->rgForeignKeyColumnList);

		CDbMemory::Free(*pConCur->pConstraintID);
		if(pConCur->pReferencedTableID)
			CDbMemory::Free(*pConCur->pReferencedTableID);
	}

	// Free the property sets
	for(pSetCur = m_pPropSets, i = 0; i < m_nPropSets; ++i, ++pSetCur)
		CDbMemory::Free(pSetCur);

	// Free the column array
	if(m_pColumns != NULL)
		CoTaskMemFree(m_pColumns);
	m_pColumns = NULL;

	// Free the constraints array
	if(m_pConstraints != NULL)
		CoTaskMemFree(m_pConstraints);
	m_pConstraints = NULL;

	// Free the property sets array
	if(m_pPropSets != NULL)
		CoTaskMemFree(m_pPropSets);
	m_pPropSets = NULL;

	// Free the strings memory
	if(m_pStrings != NULL)
		CoTaskMemFree(m_pStrings);
	m_pStrings = NULL;
}


// CTableDefinition::GetDefinition
//
//		Retrieves the table definition for a given table name
//
HRESULT CTableDefinition::GetDefinition(CSession& session, LPCTSTR pszTableName)
{
	CComPtr<ITableCreation>	spTableCreation;
	CComPtr<IUnknown>		spUnknown(session);
	HRESULT					hr;
	DBID					dbidTable;

	hr = spUnknown->QueryInterface(IID_ITableCreation, (void**)&spTableCreation);
	if(FAILED(hr))
		return hr;

	Clear();

	// Set the table name as the DBID
	dbidTable.eKind				= DBKIND_NAME;
	dbidTable.uName.pwszName	= (LPOLESTR)pszTableName;

	// Get the table definition
	hr = spTableCreation->GetTableDefinition(&dbidTable, 
											 &m_nColumns, &m_pColumns, 
											 &m_nPropSets, &m_pPropSets, 
											 &m_nConstraints, &m_pConstraints, 
											 &m_pStrings);
	return hr;
}


// CTableDefinition::FillColumnArray
//
//		Populates a column list from the table definition
//
bool CTableDefinition::FillColumnArray(CColumnArray& columns)
{
	ULONG	i;
	size_t	c, nColumns = columns.GetCount();

	// Clear the column array
	for(c = 0; c < nColumns; ++c)
		delete columns[c];
	columns.RemoveAll();

	if(m_nColumns == 0)
		return true;

	for(i = 0; i < m_nColumns; ++i)
	{
		CColumn* pColumn = new CColumn(m_pColumns + i, i + 1);

		if(pColumn == NULL)
			return false;

		columns.Add(pColumn);
	}
	return true;
}


// CTableDefinition::FillForeignKeyArray
//
//		Populates a foreign key array from the table definition
//
bool CTableDefinition::FillForeignKeyArray(CForeignKeyArray& foreignKeys)
{
	ULONG	i;
	size_t	c, n = foreignKeys.GetCount();

	// Clear the foreign key array
	for(c = 0; c < n; ++c)
		delete foreignKeys[c];
	foreignKeys.RemoveAll();

	for(i = 0; i < m_nConstraints; ++i)
	{
		if(m_pConstraints[i].ConstraintType == DBCONSTRAINTTYPE_FOREIGNKEY)
		{
			CForeignKey* pForeignKey = new CForeignKey(m_pConstraints + i);

			if(pForeignKey == NULL)
				return false;
			foreignKeys.Add(pForeignKey);
		}
	}
	return true;
}


// CTableDefinition::FillUniqueArray
//
//		Fills an index array with the UNIQUE constraints
//
bool CTableDefinition::FillUniqueArray(CIndexArray& uniques)
{
	ULONG	i;
	size_t	c, n = uniques.GetCount();

	// Clear the unique constraint array
	for(c = 0; c < n; ++c)
		delete uniques[c];
	uniques.RemoveAll();

	for(i = 0; i < m_nConstraints; ++i)
	{
		if(m_pConstraints[i].ConstraintType == DBCONSTRAINTTYPE_UNIQUE)
		{
			CIndex* pIndex = new CIndex(m_pConstraints + i);

			if(pIndex == NULL)
				return false;
			uniques.Add(pIndex);
		}
	}
	return true;
}


CIndex* CTableDefinition::GetPrimaryKey()
{
	ULONG i;
	for(i = 0; i < m_nConstraints; ++i)
	{
		if(m_pConstraints[i].ConstraintType == DBCONSTRAINTTYPE_PRIMARYKEY)
		{
			CIndex*	pKey = new CIndex(m_pConstraints + i);

			return pKey;
		}
	}
	return NULL;
}
<file_sep>/FingerSuite/FingerMenuDLL/hook/sysdecls.h
/********************************************************************
Module : SpyEngine.h - part of CeApiSpyDll implementation 

    Copyright (c) 2003-2005 ForwardLab,Inc.

    See readme.txt for terms and conditions.

Purpose: Contains redefinitions for some CE internal 
    structures and undocumented APIs

  This file was compiled using eMbedded Visual C++ 4.0
  with Pocket PC 2003 and Smartphone 2003 SDKs,
Visual Studio 2005 Beta 2 with Pocket PC 2005, Smartphone 2005 SDKs
********************************************************************/

#ifndef _SYS_DECLS_H_
#define _SYS_DECLS_H_

/********   Beginning of undocumented functions declarations *******/
extern "C"
{
//The following functions exported from coredll.dll are documented in
//Platform Builder help and declared in 
//PUBLIC\COMMON\OAK\INC\pkfuncs.h,
//but not in SDK, so declare them here:
DWORD __stdcall SetProcPermissions(DWORD);
LPVOID __stdcall MapCallerPtr(LPVOID ptr, DWORD dwLen);
LPVOID __stdcall MapPtrToProcess (LPVOID lpv, HANDLE hProc);
LPVOID __stdcall UnMapPtr(LPVOID lpv);
HANDLE __stdcall GetOwnerProcess (void); 
HANDLE __stdcall GetCallerProcess (void); 
BOOL __stdcall SetKMode(BOOL fMode);
BOOL __stdcall IsAPIReady(DWORD hAPI);

//The following are undocumented structures declared in
//PUBLIC\COMMON\OAK\INC\pkfuncs.h, which we have to redeclare here.
//WARNING: undocumented structures and functions may change in the 
//future.
struct CALLBACKINFO 
{
    HANDLE  m_hDestinationProcessHandle;
    FARPROC m_pFunction;
    PVOID   m_pFirstArgument;
};

//The following undocumented functions exported from coredll.dll
//and declared in PUBLIC\COMMON\OAK\INC\pkfuncs.h,
//but not in SDK, so declare them here:
//WARNING: undocumented structures and functions may change in the 
//future.
HANDLE __stdcall CreateAPISet(char acName[4], USHORT cFunctions, 
    const PFNVOID *ppfnMethods, const DWORD *pdwSig);
BOOL  __stdcall RegisterAPISet(HANDLE hASet, DWORD dwSetID);
int  __stdcall QueryAPISetID(char *pName);
FARPROC  __stdcall GetAPIAddress(int setId, int iMethod);
HLOCAL __stdcall LocalAllocInProcess(UINT uFlags, UINT uBytes, 
                                     HPROCESS hProc);
HANDLE __stdcall GetProcFromPtr(LPVOID p);
DWORD  __stdcall PerformCallBack4(CALLBACKINFO *pcbi, 
                                  DWORD dw1, DWORD dw2, DWORD dw3);
BOOL __stdcall GetRomFileInfo(DWORD type, 
                              LPWIN32_FIND_DATA lpfd, DWORD count);
DWORD __stdcall GetProcessIndexFromID(HANDLE hProc);
LPBYTE __stdcall THCreateSnapshot(DWORD dwFlags, DWORD dwProcID);

//The following are API handles from PUBLIC\COMMON\OAK\INC\psyscall.h
//(in addition to SH_* handles defined in SDK kfuncs.h file).
#define HT_EVENT				4	
#define HT_MUTEX				5	
#define HT_APISET				6	
#define HT_FILE					7	
#define HT_FIND					8	
#define HT_DBFILE				9	
#define HT_DBFIND				10	
#define HT_SOCKET				11	
#define HT_INTERFACE			12
#define HT_SEMAPHORE			13	
#define HT_FSMAP				14	
#define HT_WNETENUM             15  

//The following are some methods in the SH_WIN32 table.
//The full list is in psyscall.h.
#define W32_LoadLibraryW		 8 //Disappeared in CE 5.0. Use W32_LoadLibraryExW
#define W32_GetRomFileInfo		32
#define W32_CreateProc          53
#define W32_CeGetCurrentTrust   85
#define W32_PerformCallBack 	113
#define W32_DebugNotify			118
#define W32_LoadLibraryExW		148

//The following are some methods in the SH_FILESYS_APIS table.
#define FILESYS_CreateFile      9

//The following are some methods in the SH_WMGR table.
#define WMGR_TrackPopupMenuEx  63
#define WMGR_DrawIconEx        79
#define WMGR_MessageBoxW       50

//The following are some methods in the SH_SHELL table. (defined in kfuncs.h and C:\WINCE600\PRIVATE\SHELL\SHELLPSL\HAVEAYGSHELL\api.cpp)
#define SHELL_SHNotificationAddII       55
#define SHELL_SHNotificationUpdateII    56 
#define SHELL_SHNotificationRemoveII    57
#define SHELL_SHNotificationGetDataII   58



}//extern "C"
/********   End of undocumented functions declarations *************/

/********   Beginning of kernel data structure declarations ********/
//The key for accessing CE kernel data structure (KDataStruct) is 
//PUserKData. PUserKData is defined in kfuncs.h in SDK as 0xFFFFC800 
//on ARM and 0x00005800 on other CPUs. It is used in the same header 
//to define macros GetCurrentThreadId and GetCurrentProcessId, which 
//directly access the kernel data structures.
//Several kernel data structures are accessed using predefined 
//offsets from PUserKData. For example, SYSHANDLE_OFFSET (defined in
//kfuncs.h), gives access to an array of system handles, KINFO_OFFSET
//(defined in PUBLIC\COMMON\OAK\INC\pkfuncs.h) gives access to 
//UserKInfo array. About 30 indexes in this array are defined in 
//pkfuncs.h (KINX_*) to provide access to such kernel data structures
//as process array, module list, kernel heap, etc.
//Here we are only interested in KINX_APISETS and KINX_API_MASK.
//KINX_APISETS slot holds a pointer to an array of system API sets
//(SystemAPISets). 
//KINX_API_MASK slot is a bit mask of installed APIs.

#define KINFO_OFFSET     0x300

#define KINX_API_MASK 18
#define KINX_APISETS 24

#define UserKInfo  ((long *)(PUserKData+KINFO_OFFSET))


//I will not bother redeclaring this large structure.
//I will only define offsets to 2 fields used in DumpApis():
#define PROCESS_NUM_OFFSET  0    //process number (index of the slot)
#define PROCESS_NAME_OFFSET 0x20 //pointer to the process name

//pointer to struct Process declared in Kernel.h.
typedef struct Process PROCESS;
typedef PROCESS *PPROCESS;

//Also declare structure CINFO, which holds an information 
//about an API (originally declared in  
//PRIVATE\WINCEOS\COREOS\NK\INC\Kernel.h). 
struct CINFO 
{
    char     m_szApiName[4];//used in CreateAPISet and QueryAPISetID
    BYTE     m_byDispatchType;//kernel vs user mode, 
                             //handle-based vs direct.
    BYTE     m_byApiHandle;//ID of the API, such as 
                           //SH_WIN32, SH_SHELL, etc.
    WORD     m_wNumMethods;//number of methods listed in array 
                           //m_ppMethods
    PFNVOID* m_ppMethods;  //array of pointers to methods
    DWORD  * m_pdwMethodSignatures;//DWORD-encoded methods arguments
    PPROCESS m_pProcessServer;//pointer to a process, 
                              //which serves this API.
};

//pkfuncs.h defines a lot of signature generation macros for methods
//with different number of arguments. The purpose of signatures is to
//figure out which arguments are pointers, so the dispatcher may 
//properly map them. We only need to redefine a single macro 
//FNSIG0(), which means that no arguments will be mapped.
#define FNSIG0()    0

//psyscall.h defined macros for calling API methods, 
//such as IMPLICIT_CALL
#if defined(x86)
#define FIRST_METHOD 	0xFFFFFE00
#define APICALL_SCALE	2
#elif defined(ARM)
#define FIRST_METHOD 	0xF0010000
#define APICALL_SCALE	4
#elif defined(SHx)
#define FIRST_METHOD 	0xFFFFFE01
#define APICALL_SCALE	2
#else
#error "Unknown CPU type"
#endif
#define HANDLE_SHIFT 	8
#define IMPLICIT_CALL(ApiID, MethodIdx) \
 (FIRST_METHOD - ((ApiID)<<HANDLE_SHIFT | (MethodIdx))*APICALL_SCALE)

/********   End of kernel data structure declarations **************/

#endif //SYS_DECLS<file_sep>/FingerSuite/FingerMenuCTRL/MenuWindow.h
// WTLApp1View.h : interface of the CWTLApp1View class
//
/////////////////////////////////////////////////////////////////////////////

#pragma once




#ifndef __FNGRSCRL_H__
	#error menu.h requires fngrscrl.h to be included first
#endif

#define IDT_TIMER_MENU_ANIMATION  10110
#define TMR_MENU_ANIMATION        10

#define BORDER_WIDTH           10
#define UM_MINIMIZE               WM_USER + 2
#define UM_SETNEWMENU             WM_USER + 4
#define UM_GETDESTWND             WM_USER + 5



class CMenuWindow : public CWindowImpl<CMenuWindow>, public CFingerScrollImpl<CMenuWindow, true, true>
{
public:
	DECLARE_WND_CLASS(NULL)

	BOOL PreTranslateMessage(MSG* pMsg)
	{
		pMsg;
		return FALSE;
	}

	CMenuWindow ()
	{
		m_idxDPadSelected = -1;
	}

	void DoPaint(CDCHandle dc)
	{
		// must be implemented in a derived class
		RECT rc; GetClientRect(&rc);
		SIZE imgSize;
		imgSize.cx = m_imgSubmenuImage.GetWidth();
		imgSize.cy = m_imgSubmenuImage.GetHeight();

		// font
		CFont oldFont = dc.SelectFont(m_fText);

		for (int i = 0; i < m_menuItems.GetSize(); i++)	
		{
			MENUINFO mi = (MENUINFO)m_menuItems[i];

			COLORREF clText;
			COLORREF clBkg = m_clBkg;
			if ((i == m_idxSelected) || (i == m_idxDPadSelected))
			{
				clText = m_clSelText;
			}
			else
			{
				clText = m_clText;
			}

			if (mi.mii.fState & MF_GRAYED)
			{
				clText = m_clDisabledText;
			}

			
			RECT rcItem = {0, i * m_itemHeight, rc.right, (i + 1) * m_itemHeight };

			// draw rectangle without borders
			CBrush br; br.CreateSolidBrush(clBkg);
			CBrush brOld = dc.SelectBrush(br);
			CPen pen; pen.CreatePen(PS_NULL, 1, RGB(255,255,255));
			CPen penOld = dc.SelectPen(pen);
			dc.Rectangle(&rcItem);
			dc.SelectPen(penOld);
			dc.SelectBrush(brOld);


			if ((i == m_idxSelected) && !(mi.mii.fState & MF_GRAYED))
			{
				m_imgSelectionImage.Draw(dc, rcItem);
			}

			// draw dpad selection
			if ( i == m_idxDPadSelected)
			{
				m_imgDPadCursorImage.Draw(dc, rcItem);
			}


			// draw bottom line
			if (m_menuItems[i].bFollowSeparator)
			{
				// solid line 1px
				CPen pen2; pen2.CreatePen(PS_SOLID, 1, m_clLine);
				CPen penOld2 = dc.SelectPen(pen2);
				dc.MoveTo(rcItem.left, rcItem.bottom - 1);
				dc.LineTo(rcItem.right, rcItem.bottom - 1);
				dc.SelectPen(penOld2);
			}
			else
			{
				// dotted line 1px
				CPen pen2; pen2.CreatePen(PS_DASH, 1, m_clLine);
				CPen penOld2 = dc.SelectPen(pen2);
				dc.MoveTo(rcItem.left, rcItem.bottom - 1);
				dc.LineTo(rcItem.right, rcItem.bottom - 1);
				dc.SelectPen(penOld2);				
			}

			// draw text
			dc.SetBkMode(TRANSPARENT);
			dc.SetTextColor(clText);
			dc.DrawText(m_menuItems[i].text, -1, &rcItem, DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS); 

			if (mi.mii.fType & MFT_RADIOCHECK)
			{
				if (mi.mii.fState & MFS_CHECKED)
				{
					RECT rcImg = {rcItem.right - imgSize.cx, rcItem.top, rcItem.right, rcItem.top + imgSize.cy};
					m_imgRadioCheckedImage.Draw(dc, rcImg);
				}
				else
				{
					RECT rcImg = {rcItem.right - imgSize.cx, rcItem.top, rcItem.right, rcItem.top + imgSize.cy};
					m_imgRadioUncheckedImage.Draw(dc, rcImg);
				}
			}
			else
			{
				// draw check mark
				if (mi.mii.fState & MFS_CHECKED)
				{
					RECT rcImg = {rcItem.right - imgSize.cx, rcItem.top, rcItem.right, rcItem.top + imgSize.cy};
					m_imgCheckedImage.Draw(dc, rcImg);
				}
			}

			// draw sub menu icon
			if (mi.mii.hSubMenu != NULL)
			{
				RECT rcImg = {rcItem.right - imgSize.cx, rcItem.top, rcItem.right, rcItem.top + imgSize.cy};
				m_imgSubmenuImage.Draw(dc, rcImg);
			}

			if (mi.mii.fType & MFT_OWNERDRAW)
			{
				CDC dcTemp; dcTemp.CreateCompatibleDC(dc);

				DRAWITEMSTRUCT dis;
				ZeroMemory(&dis, sizeof(DRAWITEMSTRUCT));

				dis.CtlType = ODT_MENU;
				dis.itemID = mi.mii.wID;
				dis.itemAction = ODA_DRAWENTIRE;
				//dis.itemState = ODS_SELECTED; // TODO
				dis.hwndItem = (HWND)mi.hOwnerMenu;
				dis.hDC = dc;
				CopyRect(&dis.rcItem, &rcItem);
				InflateRect(&dis.rcItem, 0, -8 * m_scaleFactor);
				dis.itemData = mi.mii.dwItemData;

				//LOG(L"Avvio draw....");

				LRESULT lResult = SendMessageRemote(mi.hDestWnd, WM_DRAWITEM, 0, (LPARAM)&dis, sizeof(DRAWITEMSTRUCT), 50);

				if (lResult == 0)
				{
					GetParent().GetParent().PostMessage(WM_COMMAND, ID_MENU_SHOWORIGINAL, 0);
					return;
				}

				//LOG(L"......completato\n");
			}

		}
		dc.SelectFont(oldFont);


		// draw scroll bar
		if (!m_bAnimating)
		{
			int totalHeight = m_menuItems.GetSize() * m_itemHeight;
			if (rc.bottom < totalHeight)
			{
				int height = (int)(((float)rc.bottom / (float)totalHeight) * rc.bottom);
				int top = (int)(((float)GetOffset() / (float)totalHeight) * rc.bottom);

				RECT rcScrollbar;
				rcScrollbar.right = rc.right;
				rcScrollbar.left = rcScrollbar.right - 3 * m_scaleFactor;
				rcScrollbar.top = top + GetOffset();
				rcScrollbar.bottom = rcScrollbar.top + height;
				dc.FillSolidRect(&rcScrollbar, m_clScrollbar);
			}
		}
	}

	typedef CWindowImpl<CMenuWindow>  winbaseClass;
	typedef CFingerScrollImpl<CMenuWindow, true, true> scrollbaseClass;

	BEGIN_MSG_MAP(CMenuWindow)
		MESSAGE_HANDLER(WM_CREATE, OnCreate)
		MESSAGE_HANDLER(WM_SIZE, OnSize)
		MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBackground)
		MESSAGE_HANDLER(WM_TIMER, OnTimer)
		MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown)
		MESSAGE_HANDLER(WM_MOUSEMOVE, OnMouseMove)
		MESSAGE_HANDLER(WM_LBUTTONUP, OnLButtonUp)
		CHAIN_MSG_MAP(scrollbaseClass)
	END_MSG_MAP()

	LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		return 0;
	}

	LRESULT OnSize(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled)
	{
		if(wParam != SIZE_MINIMIZED)
		{
			RECT rc; GetClientRect(&rc);
			SetFingerScrollRegion(m_menuItems.GetSize() * m_itemHeight, rc.bottom);
		}

		bHandled = FALSE;
		return 0;
	}

	LRESULT OnEraseBackground(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		return 1;
	}

	LRESULT OnLButtonDown(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled)
	{
		m_xPos = LOWORD(lParam);
		m_yPos = HIWORD(lParam);
		m_bMouseIsDown = TRUE;

		m_idxSelected = (GetOffset() + m_yPos) / m_itemHeight;
		m_idxDPadSelected = -1;

		if ((m_idxSelected >= 0) && (m_idxSelected < m_menuItems.GetSize()))
		{
			InvalidateRect(NULL, FALSE);
			UpdateWindow();
		}
		else
			m_idxSelected = -1;

		bHandled = FALSE; // very important
		return 0;
	}

	LRESULT OnMouseMove(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled)
	{
		int y = HIWORD(lParam);
		if  (abs(y - m_yPos) >  GetThreshold())
		{
			if (m_idxSelected != -1)
			{
				m_idxSelected = -1;
				InvalidateRect(NULL, FALSE);
				UpdateWindow();
			}
		}

		m_yPos = HIWORD(lParam);

 		bHandled = FALSE; // very important
		return 0;
	}

	LRESULT OnLButtonUp(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled)
	{
		/*
		if (m_bMouseIsDown)
		{
			// back gesture recognition
			int xPosNew =  LOWORD(lParam);
			
			if ((m_xPos - xPosNew) > 100 * m_scaleFactor)
			{
				// back gesture recognized 
				if (Back())
				{
					bHandled = FALSE; // very important
					return 0;
				}
			}
		}
		*/
		
		m_bMouseIsDown = FALSE;


		// normal mode
		if (m_idxSelected != -1)
		{
			MENUINFO mi = (MENUINFO)m_menuItems[m_idxSelected];
			if (!(mi.mii.fState & MF_GRAYED))
			{
				if (mi.mii.hSubMenu != NULL)
				{
					// manage submenu
					LPMENU pMu = NULL;
					for (int i = 0; i < m_menus.GetSize(); i++)
					{
						if (m_menus[i].hMenu == mi.mii.hSubMenu)
						{
							pMu = &m_menus[i];
							break;
						}
					}

					if (pMu == NULL)
					{
						MENU m;
						m.hMenu = mi.mii.hSubMenu;
						m.bInitMenuSent = FALSE;
						m.hPrevMenu = mi.hOwnerMenu;
						m_menus.Add(m);
					}

					GetParent().GetParent().SendMessage(UM_SETNEWMENU, (WPARAM)mi.mii.hSubMenu);
				}
				else 
				{
					GetParent().GetParent().SendMessage(UM_MINIMIZE, (WPARAM)mi.mii.wID, 0);
				}
			}
		}

		bHandled = FALSE; // very important
		return 0;
	}



public:
	COLORREF m_clBkg;
	COLORREF m_clText;
	COLORREF m_clSelText;
	COLORREF m_clDisabledText;
	COLORREF m_clLine;
	COLORREF m_clScrollbar;

	CFontHandle m_fText;
	
	int m_itemHeight;
	int m_scaleFactor;
	BOOL m_bAnimating;

	CxImage m_imgSubmenuImage;
	CxImage m_imgCheckedImage;
	CxImage m_imgRadioCheckedImage;
	CxImage m_imgRadioUncheckedImage;
	CxImage m_imgSelectionImage;
	CxImage m_imgDPadCursorImage;

	int m_idxDPadSelected;
	int m_xPos;
	int m_yPos;
	int m_idxSelected;


protected:


	HRGN m_hRgn;
	BOOL m_bMouseIsDown;
};


class CWrapMenuWindow : public CWindowImpl<CWrapMenuWindow>
{
public:

	CMenuWindow m_menu;

	DECLARE_WND_CLASS(NULL)

	CWrapMenuWindow ()
	{
		m_nMaxMenuItemCount = 1000;
		m_bMouseIsDown = FALSE;
	}

	BOOL PreTranslateMessage(MSG* pMsg)
	{
		pMsg;
		return FALSE;
	}

	void SetMaxMenuItemCount(int value)
	{
		m_nMaxMenuItemCount = value;
	}

	void SetScaleFactor(int value)
	{
		m_scaleFactor = value;
		m_menu.m_scaleFactor = value;

		m_menu.SetThreshold(5 * m_scaleFactor);
	}

	int GetScaleFactor()
	{
		return m_scaleFactor;
	}

	void SetItemHeight(int value)
	{
		m_itemHeight = value; //* m_scaleFactor;
		m_menu.m_itemHeight = value; // * m_scaleFactor;
	}

	void SetButtonHeight(int value)
	{
		m_buttonHeight = value;
	}

    int GetItemHeight()
	{
		return m_itemHeight;
	}
	
	/*
	void SetUsedRect(int value)
	{
		m_nUsedRects = value * m_scaleFactor;
	}
	*/

	BOOL Show()
	{
		ModifyShape();
		StartAnimation();

		return TRUE;
	}



	BEGIN_MSG_MAP(CWrapMenuWindow)
		MESSAGE_HANDLER(WM_CREATE, OnCreate)
		MESSAGE_HANDLER(WM_SIZE, OnSize)
		MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBackground)
		MESSAGE_HANDLER(WM_TIMER, OnTimer)
		MESSAGE_HANDLER(WM_PAINT, OnPaint)
		//MESSAGE_HANDLER(UM_STARTANIM, OnStartAnim)
		MESSAGE_HANDLER(UM_SCRL_NOTIFY, OnScrlNotify)
		MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown)
		MESSAGE_HANDLER(WM_LBUTTONUP, OnLButtonUp)
		MESSAGE_HANDLER(WM_KEYDOWN, OnKeyDown)
	END_MSG_MAP()

	LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		ModifyTopShape();
		// menu
		m_menu.Create(m_hWnd, rcDefault, NULL, WS_CHILD | WS_VISIBLE |WS_CLIPSIBLINGS | WS_CLIPCHILDREN);  
		return 0;
	}

	LRESULT OnSize(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled)
	{
		RECT rc; GetClientRect(&rc);
		if ((m_menuItems.GetSize() > m_nMaxMenuItemCount) && (!m_bNoButtons))
		{
	    	rc.top += m_buttonHeight;
			rc.bottom -= m_buttonHeight;
			m_bButtonsVisible = TRUE;
		}
		m_menu.MoveWindow(&rc, TRUE);
		return 0;
	}

	LRESULT OnEraseBackground(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		return 1;
	}

	LRESULT OnPaint(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		RECT rc; GetClientRect(&rc);
		CBufferedPaintDC dc(m_hWnd, 0);

		if (m_bButtonsVisible)
		{
			RECT rcItem; CopyRect(&rcItem, &rc);
			rcItem.bottom = m_buttonHeight;
			RECT rcArrow; CopyRect(&rcArrow, &rcItem);
			int w = m_bmpBtnArrowUp.GetWidth();
			int h = m_bmpBtnArrowUp.GetHeight();
			int dx = (w - rcItem.right)/2;
			int dy = (h - rcItem.bottom)/2;
			InflateRect(&rcArrow, dx, dy);
			rcArrow.right = rcArrow.left + w;
			rcArrow.bottom = rcArrow.top + h;

			if (m_bBtnUpDisabled)
			{
				m_bmpBtnUpDisabled.Draw(dc, rcItem);
			}
			else if (m_bBtnUpPressed)
			{
				m_bmpBtnUpPressed.Draw(dc, rcItem);
				// draw arrow
				m_bmpBtnArrowUp.Draw(dc, rcArrow);
			}
			else
			{
				m_bmpBtnUp.Draw(dc, rcItem);
				// draw arrow
				m_bmpBtnArrowUp.Draw(dc, rcArrow);
			}

			CopyRect(&rcItem, &rc);
			rcItem.top = rcItem.bottom - m_buttonHeight;
			CopyRect(&rcArrow, &rcItem);
			w = m_bmpBtnArrowDown.GetWidth();
			h = m_bmpBtnArrowDown.GetHeight();
			dx = (w - rcItem.right)/2;
			dy = (h - (rcItem.bottom - rcItem.top))/2;
			InflateRect(&rcArrow, dx, dy);
			rcArrow.right = rcArrow.left + w;
			rcArrow.bottom = rcArrow.top + h;
			
			if (m_bBtnDownDisabled)
			{
				m_bmpBtnDownDisabled.Draw(dc, rcItem);
			}
			else if (m_bBtnDownPressed)
			{
				m_bmpBtnDownPressed.Draw(dc, rcItem);
				// draw arrow
				m_bmpBtnArrowDown.Draw(dc, rcArrow);
			}
			else
			{
				m_bmpBtnDown.Draw(dc, rcItem);
				// draw arrow
				m_bmpBtnArrowDown.Draw(dc, rcArrow);
			}
		}
		return 0;
	}

	LRESULT OnTimer(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled)
	{
		if (wParam == IDT_TIMER_MENU_ANIMATION)
		{
			m_iStep = m_iStep / 2;
			//int iVisibleItems = min(m_nMaxMenuItemCount, m_menu.GetMenuItemCount());
			//MoveWindow(&m_rect, TRUE);
			RECT animRect; CopyRect(&animRect, &m_animRect);
			animRect.top = animRect.top + m_iStep;
			MoveWindow(&animRect, TRUE);

			if (m_iStep == 0)
			{
				KillTimer(IDT_TIMER_MENU_ANIMATION);
				m_bAnimating = FALSE;
				m_menu.m_bAnimating = FALSE;
				m_iStep = 0;
			}

			bHandled = TRUE;
			return 0;
		}

		bHandled = FALSE;
		return 0;
	}

	
	//LRESULT OnStartAnim(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	//{
	//	ModifyShape();
	//	StartAnimation();
	//	return 0;
	//}
	
	LRESULT OnScrlNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
	{
		if (!m_bAnimating)
		{
			BOOL bUpdate = FALSE;
			int offset = (int)wParam;
			if (offset == 0)
			{
				bUpdate = (m_bBtnUpDisabled != TRUE);
				m_bBtnUpDisabled = TRUE;
			}

			if (offset == m_menu.GetScrollableAreaHeight())
			{
				bUpdate = (m_bBtnDownDisabled != TRUE);
				m_bBtnDownDisabled = TRUE;
			}

			if ((offset > 0) && (offset < m_menu.GetScrollableAreaHeight()))
			{
				bUpdate = (m_bBtnUpDisabled != FALSE) || (m_bBtnDownDisabled != FALSE);
				m_bBtnUpDisabled   = FALSE;
				m_bBtnDownDisabled = FALSE;
			}

			if (bUpdate)
			{
				InvalidateRect(NULL, TRUE);
				UpdateWindow();
			}
		}		
		return 0;
	}


	LRESULT OnLButtonDown(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/)
	{
		RECT rc; GetClientRect(&rc);
		UINT yPos = HIWORD(lParam);

		m_menu.m_idxDPadSelected = -1;

		m_bMouseIsDown = TRUE;

		if ((yPos < m_itemHeight) && (!(m_bBtnUpDisabled)))
		{
			m_bBtnUpPressed = TRUE;
			
			RECT rcBtn; CopyRect(&rcBtn, &rc);
			rcBtn.bottom = m_itemHeight;
			InvalidateRect(&rcBtn, FALSE);
			UpdateWindow();
		}

		if ((yPos > (rc.bottom - m_itemHeight)) && (!(m_bBtnDownDisabled)))
		{
			m_bBtnDownPressed = TRUE;
			
			RECT rcBtn; CopyRect(&rcBtn, &rc);
			rcBtn.top = rc.bottom - m_itemHeight;
			InvalidateRect(&rcBtn, FALSE);
			UpdateWindow();
		}
		
		return 0;
	}


	LRESULT OnLButtonUp(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/)
	{
		RECT rc; GetClientRect(&rc);
		UINT yPos = HIWORD(lParam);

		if (m_bMouseIsDown)
		{
			if ((yPos < m_itemHeight) && (!(m_bBtnUpDisabled)))
			{
				m_bBtnUpPressed = FALSE;
			
				int d = (m_menu.GetOffset() - 3 * m_itemHeight) - ( (m_menu.GetOffset() - 3 * m_itemHeight) % m_itemHeight );
				m_menu.ScrollTo(d);

				RECT rcBtn; CopyRect(&rcBtn, &rc);
				rcBtn.bottom = m_itemHeight;
				InvalidateRect(&rcBtn, FALSE);
				UpdateWindow();
			}

			if ((yPos > (rc.bottom - m_itemHeight)) && (!(m_bBtnDownDisabled)))
			{
				m_bBtnDownPressed = FALSE;

				int d = (m_menu.GetOffset() + 3 * m_itemHeight) - ( (m_menu.GetOffset() + 3 * m_itemHeight) % m_itemHeight );
				m_menu.ScrollTo(d);

				RECT rcBtn; CopyRect(&rcBtn, &rc);
				rcBtn.top = rc.bottom - m_itemHeight;
				InvalidateRect(&rcBtn, FALSE);
				UpdateWindow();
			}
		}

		m_bMouseIsDown = FALSE;
		return 0;
	}

	LRESULT OnKeyDown(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
	{
		static int nKeyRepeatCount = 0;
		int nVirtKey = (int)wParam; 
		BOOL bUpdate = FALSE; 

		BOOL bRepeating = (lParam & (1 << 30)) != 0;

		if (bRepeating)
		{
			nKeyRepeatCount++;
			if (nKeyRepeatCount % 5 != 0)
				return 0;
		}
		else
		{
		  nKeyRepeatCount = 0;
		}

		switch (nVirtKey)
		{
		case VK_LEFT:
			GetParent().SendMessage(WM_COMMAND, (WPARAM)ID_BACK);
			break;

		case VK_RIGHT:
		case VK_RETURN:
			if ((m_menu.m_idxDPadSelected >= 0) && (m_menu.m_idxDPadSelected < m_menuItems.GetSize()))
			{
				m_menu.m_idxSelected = m_menu.m_idxDPadSelected;
				m_menu.SendMessage(WM_LBUTTONUP, 0, MAKELPARAM(m_menu.m_xPos, m_menu.m_yPos) );   //(LPARAM)m_menu.m_xPos);
			}
			else
			{
				// as requested select first item
				m_menu.m_idxDPadSelected = 0;

				m_menu.m_idxSelected = m_menu.m_idxDPadSelected;
				m_menu.SendMessage(WM_LBUTTONUP, 0, MAKELPARAM(0, m_menu.m_yPos) );
			}
			break;

		case VK_UP: 
			if ((m_menu.m_idxDPadSelected >= 0) && (m_menu.m_idxDPadSelected < m_menuItems.GetSize()))
			{
				bUpdate = TRUE;
				m_menu.m_idxDPadSelected --;
				if (m_menu.m_idxDPadSelected < (m_menuItems.GetSize() - 3))
				{
					int d = (m_menu.GetOffset() - m_itemHeight) - ( (m_menu.GetOffset() - m_itemHeight) % m_itemHeight );
					m_menu.ScrollTo(d);
				}
			}
			else
			{
				// mi metto sull'ultimo visibile
				bUpdate = TRUE;
				m_menu.ScrollTo((m_menuItems.GetSize() - 1) * m_itemHeight);
				m_menu.m_idxDPadSelected = m_menuItems.GetSize() - 1;
			}
			break;

		case VK_DOWN: 
			if ((m_menu.m_idxDPadSelected >= 0) && (m_menu.m_idxDPadSelected < m_menuItems.GetSize()))
			{
				bUpdate = TRUE;
				m_menu.m_idxDPadSelected ++;
				if (m_menu.m_idxDPadSelected > 2)
				{
					int d = (m_menu.GetOffset() + m_itemHeight) - ( (m_menu.GetOffset() + m_itemHeight) % m_itemHeight );
					m_menu.ScrollTo(d);
				}
			}
			else
			{
				// mi metto sul primo visibile
				bUpdate = TRUE;
				m_menu.ScrollTo(0);
				m_menu.m_idxDPadSelected = 0;
			}
			break;

		}

		if (bUpdate)
		{
			m_menu.m_idxDPadSelected = min(m_menu.m_idxDPadSelected, m_menuItems.GetSize() - 1);
			m_menu.m_idxDPadSelected = max(m_menu.m_idxDPadSelected, 0);

			m_menu.Invalidate(FALSE);
			m_menu.UpdateWindow();
		}

		return 0;
	}

	//HBITMAP m_bmpBtnUp;
	//HBITMAP m_bmpBtnUpPressed;
	//HBITMAP m_bmpBtnUpDisabled;
	//HBITMAP m_bmpBtnDown;
	//HBITMAP m_bmpBtnDownPressed;
	//HBITMAP m_bmpBtnDownDisabled;

	CxImage m_bmpBtnUp;
	CxImage m_bmpBtnUpPressed;
	CxImage m_bmpBtnUpDisabled;
	CxImage m_bmpBtnDown;
	CxImage m_bmpBtnDownPressed;
	CxImage m_bmpBtnDownDisabled;
	CxImage m_bmpBtnArrowUp;
	CxImage m_bmpBtnArrowDown;

	DWORD m_iMaxVisibleItemCount;
	BOOL m_bNoButtons;
	BOOL m_bEnableAnimation;


	void ModifyTopShape()
	{
		int nUsedRects = 3 * m_scaleFactor;
		m_heightHrgnTop = nUsedRects;

		if (m_hrgnTop != NULL)
		{
			DeleteObject(m_hrgnTop);
			m_hrgnTop = NULL;
		}

		RECT rcParent; GetParent().GetClientRect(&rcParent);
		int iWidth = rcParent.right - 2 * BORDER_WIDTH * m_scaleFactor;

		RGNDATA *pRgnData;
		RECT *pRect;		
		DWORD dwTemp = sizeof(RGNDATAHEADER) + nUsedRects * sizeof(RECT);
		pRgnData = (RGNDATA*)malloc(dwTemp);	
		pRgnData->rdh.dwSize = sizeof(RGNDATAHEADER);
		pRgnData->rdh.iType = RDH_RECTANGLES;
		pRgnData->rdh.nCount = nUsedRects;
		pRgnData->rdh.nRgnSize = 0;
		pRgnData->rdh.rcBound.left = pRgnData->rdh.rcBound.top=0;
		pRgnData->rdh.rcBound.right = iWidth;
		pRgnData->rdh.rcBound.bottom = nUsedRects;		

		/*
		for (int i = 0; i < nUsedRects; i++)
		{
			pRect=&(((RECT *)&pRgnData->Buffer)[i]);
			pRect->top = i;
			pRect->bottom = i + 1;
			pRect->left = nUsedRects - i;
			pRect->right = iWidth - (nUsedRects - i);
		}
		*/
		if (nUsedRects == 3)
		{
			// 1st
			pRect = &(((RECT *)&pRgnData->Buffer)[0]);
			pRect->top = 0;
			pRect->bottom = 1;
			pRect->left = 2;
			pRect->right = iWidth - 2;

			// 2nd
			pRect = &(((RECT *)&pRgnData->Buffer)[1]);
			pRect->top = 1;
			pRect->bottom = 2;
			pRect->left = 1;
			pRect->right = iWidth - 1;

			// 3rd
			pRect = &(((RECT *)&pRgnData->Buffer)[2]);
			pRect->top = 2;
			pRect->bottom = 3;
			pRect->left = 0;
			pRect->right = iWidth;
		}
		else if (nUsedRects == 6)
		{
			// 1st
			pRect = &(((RECT *)&pRgnData->Buffer)[0]);
			pRect->top = 0;
			pRect->bottom = 1;
			pRect->left = 5;
			pRect->right = iWidth - 5;

			// 2nd
			pRect = &(((RECT *)&pRgnData->Buffer)[1]);
			pRect->top = 1;
			pRect->bottom = 2;
			pRect->left = 3;
			pRect->right = iWidth - 3;

			// 3rd
			pRect = &(((RECT *)&pRgnData->Buffer)[2]);
			pRect->top = 2;
			pRect->bottom = 3;
			pRect->left = 2;
			pRect->right = iWidth - 2;

			// 4th
			pRect = &(((RECT *)&pRgnData->Buffer)[3]);
			pRect->top = 3;
			pRect->bottom = 4;
			pRect->left = 1;
			pRect->right = iWidth - 1;

			// 5th
			pRect = &(((RECT *)&pRgnData->Buffer)[4]);
			pRect->top = 4;
			pRect->bottom = 5;
			pRect->left = 1;
			pRect->right = iWidth - 1;

			// 6th
			pRect = &(((RECT *)&pRgnData->Buffer)[5]);
			pRect->top = 5;
			pRect->bottom = 6;
			pRect->left = 0;
			pRect->right = iWidth;

		}

		m_hrgnTop = ExtCreateRegion(NULL, dwTemp, pRgnData);
		free(pRgnData);

	}

public:
	//int m_nUsedRects; //6 for VGA
	int m_itemHeight; 
	int m_buttonHeight;
	RECT m_animRect; 
	BOOL m_bAnimating;
	int m_iStep;
	BOOL m_bButtonsVisible;
	int m_nMaxMenuItemCount; 
	BOOL m_bBtnUpDisabled;
	BOOL m_bBtnUpPressed;
	BOOL m_bBtnDownDisabled;
	BOOL m_bBtnDownPressed;
	int m_scaleFactor;
	int m_height;
	BOOL m_bMouseIsDown;
	HRGN m_hrgnTop;
	int  m_heightHrgnTop;


	void ModifyShape()
	{
		m_height = 0;
		BOOL bButtonsVisible = FALSE;
		if ((m_menuItems.GetSize() > m_nMaxMenuItemCount) && (!m_bNoButtons))
		{
			bButtonsVisible = TRUE;
		}

		RECT rcParent; GetParent().GetClientRect(&rcParent);
		int iWidth = rcParent.right - 2 * BORDER_WIDTH * m_scaleFactor;

		int nMaxMenuItemCount = (rcParent.bottom - rcParent.top) / m_itemHeight;
		m_nMaxMenuItemCount = min( m_iMaxVisibleItemCount, nMaxMenuItemCount );

		int nMenuItemCount = m_menuItems.GetSize();
		int nItems = (nMenuItemCount == 0) ? 2 : nMenuItemCount;
		int iVisibleItems = min(m_nMaxMenuItemCount, nItems);
		
		HRGN hrgnBottom = NULL;
		if (bButtonsVisible)
		{
			hrgnBottom = ::CreateRectRgn(0, 0, iWidth, m_buttonHeight - m_heightHrgnTop);
			m_height += m_buttonHeight;
		}
		else
		{
			hrgnBottom = ::CreateRectRgn(0, 0, iWidth, m_itemHeight - m_heightHrgnTop);
			m_height += m_itemHeight;
		}
		::OffsetRgn(hrgnBottom, 0, m_heightHrgnTop);

		CombineRgn(hrgnBottom, m_hrgnTop, hrgnBottom, RGN_OR);

		HRGN hrgnFinal = NULL;
		if (bButtonsVisible)
		{
			hrgnFinal = CreateRectRgn(0, m_buttonHeight, iWidth, (iVisibleItems - 1) * m_itemHeight + m_buttonHeight);
		}
		else
		{
			hrgnFinal = CreateRectRgn(0, m_itemHeight, iWidth, iVisibleItems * m_itemHeight);
		}
		m_height += (iVisibleItems - 1) * m_itemHeight;

		int res = CombineRgn(hrgnFinal, hrgnBottom, hrgnFinal, RGN_OR);
		if (res > 0)
		{
			SetWindowRgn(hrgnFinal, FALSE);
		}
	}

	void StartAnimation()
	{
		// window position
		m_bAnimating = (m_bEnableAnimation) ? TRUE : FALSE;
		m_menu.m_bAnimating = (m_bEnableAnimation) ? TRUE : FALSE;
		m_iStep = (m_bEnableAnimation) ? m_itemHeight / 3 : 0;

		RECT rcParent; GetParent().GetClientRect(&rcParent);

		m_animRect.left = BORDER_WIDTH * m_scaleFactor;
		m_animRect.right = rcParent.right - BORDER_WIDTH * m_scaleFactor;
		m_animRect.top = rcParent.bottom - m_height;
		m_animRect.bottom = rcParent.bottom;


		RECT animRect; CopyRect(&animRect, &m_animRect);
		animRect.top = animRect.top + m_iStep;
		MoveWindow(&animRect, TRUE);

		m_bBtnDownDisabled = FALSE;
		m_bBtnUpDisabled = TRUE;
		m_bBtnDownPressed = FALSE;
		m_bBtnUpPressed = FALSE;

		if (m_bEnableAnimation)
			SetTimer(IDT_TIMER_MENU_ANIMATION, TMR_MENU_ANIMATION);
	}



};

<file_sep>/7-Zip/CPP/7zip/Compress/PpmdType.h
// PpmdType.h
// 2009-05-30 : <NAME> : Public domain
// This code is based on <NAME>'s PPMdH code (public domain)

#ifndef __COMPRESS_PPMD_TYPE_H
#define __COMPRESS_PPMD_TYPE_H

const int kMaxOrderCompress = 32;
const int MAX_O = 255; /* maximum allowed model order */

template <class T>
inline void _PPMD_SWAP(T& t1,T& t2) { T tmp = t1; t1 = t2; t2 = tmp; }

#endif
<file_sep>/FingerSuite/Common/ext/RegionBuilder.cpp
//////////////////////////////////////////////////////////////////////////
// CRegionBuilder - fast HRGN creation for WinCE/PocketPC/Win32
// coded by dzolee - http://dzolee.blogspot.com
//////////////////////////////////////////////////////////////////////////

#include "StdAfx.h"
#include "RegionBuilder.h"

//////////////////////////////////////////////////////////////////////////
CRegionBuilder::CRegionBuilder()
{
}

//////////////////////////////////////////////////////////////////////////
CRegionBuilder::~CRegionBuilder()
{
}

//////////////////////////////////////////////////////////////////////////
RegionBuilderError CRegionBuilder::BuildRegion(HBITMAP hBmp, HRGN *pDest)
{
register LONG x, y, lW;
register DWORD *pCurrentDW, dwCurrent, nCurrentBit;
RegionBuilderError retval;
BITMAP bmp;
BITMAPINFO *pBmpInfo;
void *pBits;
HBITMAP hDIB;
LONG lH, nTotalDWsPerRow, nUsedBits, nUsedRects, nCurrentRect, start_x;
HDC dcDisplay, dcSrc, dcDest;
HGDIOBJ hSrcOldObj, hDestOldObj;
DWORD dwTemp;
bool bNotTransparent;
HRGN hRgn;
RGNDATA *pRgnData;
RECT *pRect;

	//zero result
	*pDest=NULL;

	//get bitmap dimensions
	if(GetObject(hBmp, sizeof(BITMAP), &bmp) == 0)
	{
		return rbeGDIError;
	}

	lW=bmp.bmWidth;
	lH=bmp.bmHeight;

	//alloc buffer for bmp header plus 2 colors (black and white)
	pBmpInfo=(BITMAPINFO *)malloc(sizeof(BITMAPINFOHEADER) + 2 * sizeof(RGBQUAD));

	//if failed to alloc...
	if(pBmpInfo == NULL)
	{
		return rbeNoMem;
	}

	//size of structure included in structure
	pBmpInfo->bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
	//copy dimensions
	pBmpInfo->bmiHeader.biWidth=lW;
	pBmpInfo->bmiHeader.biHeight=lH;
	//always one plane
	pBmpInfo->bmiHeader.biPlanes=1;
	//monochrome
	pBmpInfo->bmiHeader.biBitCount=1;
	//colors stored as RGBQUADs
	pBmpInfo->bmiHeader.biCompression=BI_RGB;
	//number of bytes. each scanline is padded to a multiple of 4 -- courtesy of <NAME>
	pBmpInfo->bmiHeader.biSizeImage = (DWORD)(((lW+7) & 0xfffffff8) * lH/8);
	//dummy values
	pBmpInfo->bmiHeader.biXPelsPerMeter=1000000;
	pBmpInfo->bmiHeader.biYPelsPerMeter=1000000;
	//2 colors used: black and white
	pBmpInfo->bmiHeader.biClrUsed=2;
	pBmpInfo->bmiHeader.biClrImportant=2;
	//now the RGBQUAD table: first entry is "black", second entry is "white".
	pBmpInfo->bmiColors[0].rgbBlue=pBmpInfo->bmiColors[0].rgbGreen=pBmpInfo->bmiColors[0].rgbRed=pBmpInfo->bmiColors[0].rgbReserved=0;
	pBmpInfo->bmiColors[1].rgbBlue=pBmpInfo->bmiColors[1].rgbGreen=pBmpInfo->bmiColors[1].rgbRed=pBmpInfo->bmiColors[1].rgbReserved=255;
	//create bitmap	
	hDIB=CreateDIBSection(NULL, pBmpInfo, DIB_RGB_COLORS, &pBits, NULL, 0);
	//free unused mem
	free(pBmpInfo);

	if(hDIB == NULL)
	{
		//error
		return rbeGDIError;
	}

	//get a DC to the display
	dcDisplay=::GetDC(NULL);
	if(dcDisplay == NULL)
	{
		//failed	
		DeleteObject(hDIB);
		return rbeGDIError;
	}
	
	//create compatible DCs for source (input) and destination (monochrome) bitmap
	dcSrc=CreateCompatibleDC(dcDisplay);
	//failed to create DC?
	if(dcSrc == NULL)
	{
		//clean up
		DeleteObject(hDIB);
		::ReleaseDC(NULL, dcDisplay);
		return rbeGDIError;
	}

	dcDest=CreateCompatibleDC(dcDisplay);
	//release display DC as soon as it is not needed anymore
	::ReleaseDC(NULL, dcDisplay);

	if(dcDest == NULL)
	{
		DeleteDC(dcSrc);
		DeleteObject(hDIB);
		return rbeGDIError;
	}

	//select source and destination bitmaps into DCs
	hSrcOldObj=SelectObject(dcSrc, hBmp);
	hDestOldObj=SelectObject(dcDest, hDIB);

	retval=rbeGDIError;

	//copy source bitmap to destination (monochrome)
	if(TRUE == ::BitBlt(dcDest, 0, 0, lW, lH, dcSrc, 0, 0, SRCCOPY))
	{
		//copy ok - now we have bits at pBits

		//first calculate the number of RECTs required

		//calculate DWORDs per row
		if(lW > 32)
		{
			nTotalDWsPerRow=lW / 32;
			//if number of pixels does not exactly fit into DWORD boundary
			if(lW % 32 != 0)
			{
				//one more DWORD needed to store row			
				nTotalDWsPerRow++;
			}
		}
		else
		{
			//simple case, DWORD count is 1
			nTotalDWsPerRow=1;
		}

		//for every row (backwards scan because image is flipped)
		nUsedBits=nUsedRects=0;
		bNotTransparent=false;
		for(y=lH-1; y>=0; y--)
		{
			//pointer to first DWORD in row
			pCurrentDW=((DWORD *)pBits + y * nTotalDWsPerRow);
			nCurrentBit=0;
			start_x=0;
			for(x=0; x<lW; x++)
			{
				if(nCurrentBit == 0)
				{
					//we can access the buffer by DWORDs but the result needs to be bswapped
					dwCurrent=ByteSwap(*pCurrentDW);
				}

				if(dwCurrent & 0x80000000)
				{
					//bit 1
					nUsedBits++;
					if(bNotTransparent == false)
					{
						//start line
						bNotTransparent=true;
						start_x=x;
					}
				}
				else
				{
					if(bNotTransparent == true)
					{
						//if was in a line, end line
						bNotTransparent=false;
						nUsedRects++;
					}
				}

				dwCurrent<<=1;
				//next bit
				nCurrentBit++;
				if(nCurrentBit == 32)
				{
					nCurrentBit=0;
					pCurrentDW++;
				}

				//end of row reached?
				if(x == lW-1)
				{
					if(bNotTransparent == true)
					{
						//finish line
						bNotTransparent=false;
						nUsedRects++;
					}
				}

			}//for x
		}//for y

		//alloc mem for region data
		dwTemp=sizeof(RGNDATAHEADER) + nUsedRects * sizeof(RECT);
		pRgnData=(RGNDATA *)malloc(dwTemp);		
		if(pRgnData == NULL)
		{
			//clean up and exit
			SelectObject(dcSrc, hSrcOldObj);
			SelectObject(dcDest, hDestOldObj);
			DeleteObject(hDIB);
			DeleteDC(dcSrc);
			DeleteDC(dcDest);
			return rbeGDIError;
		}

		//now build array of RECTs for region

		bNotTransparent=false;
		nCurrentRect=0;

		for(y=lH-1; y>=0; y--)
		{
			//pointer to first DWORD in row
			pCurrentDW=((DWORD *)pBits + y * nTotalDWsPerRow);
			nCurrentBit=0;
			start_x=0;
			for(x=0; x<lW; x++)
			{
				if(nCurrentBit == 0)
				{
					//we can access the buffer by DWORDs but the result needs to be bswapped
					dwCurrent=ByteSwap(*pCurrentDW);
				}

				if(dwCurrent & 0x80000000)
				{
					//bit 1
					nUsedBits++;
					if(bNotTransparent == false)
					{
						bNotTransparent=true;
						start_x=x;
					}
				}
				else
				{
					if(bNotTransparent == true)
					{
						bNotTransparent=false;
						pRect=&(((RECT *)&pRgnData->Buffer)[nCurrentRect]);
						pRect->left=start_x;
						pRect->right=x;
						pRect->top=lH-y-1;
						pRect->bottom=lH-y;
						nCurrentRect++;
					}
				}

				dwCurrent<<=1;
				//next bit
				nCurrentBit++;
				if(nCurrentBit == 32)
				{
					nCurrentBit=0;
					pCurrentDW++;
				}

				//end of row reached?
				if(x == lW-1)
				{
					if(bNotTransparent == true)
					{
						//finish line
						bNotTransparent=false;
						pRect=&(((RECT *)&pRgnData->Buffer)[nCurrentRect]);
						pRect->left=start_x;
						pRect->right=x;
						pRect->top=lH-y-1;
						pRect->bottom=lH-y;
						nCurrentRect++;
					}
				}
			}//for x
		}//for y

		//last step: region creation

		//build region data header
		pRgnData->rdh.dwSize=sizeof(RGNDATAHEADER);
		pRgnData->rdh.iType=RDH_RECTANGLES;
		pRgnData->rdh.nCount=nCurrentRect;
		pRgnData->rdh.nRgnSize=nCurrentRect * sizeof(RECT);
		pRgnData->rdh.rcBound.left=pRgnData->rdh.rcBound.top=0;
		pRgnData->rdh.rcBound.right=lW;
		pRgnData->rdh.rcBound.bottom=lH;

		//create region
		hRgn=ExtCreateRegion(NULL, sizeof(RGNDATAHEADER) + nUsedRects * sizeof(RECT), pRgnData);

		//free RECT data
		free(pRgnData);

		if(hRgn != NULL)
		{
			//clean up and return success
			*pDest=hRgn;
			retval=rbeOK;
		}
	}//if BitBlt succeeded

	//clean up and exit
	SelectObject(dcSrc, hSrcOldObj);
	SelectObject(dcDest, hDestOldObj);
	DeleteObject(hDIB);
	DeleteDC(dcSrc);
	DeleteDC(dcDest);
	return retval;
}

//////////////////////////////////////////////////////////////////////////
//code from stdlib
inline DWORD CRegionBuilder::ByteSwap(DWORD dwIn)
{
DWORD j;

	j =  (dwIn << 24);
	j += (dwIn <<  8) & 0x00ff0000;
	j += (dwIn >>  8) & 0x0000ff00;
	j += (dwIn >> 24);

	return j;
}
<file_sep>/7-Zip/CPP/7zip/Archive/Rar/RarIn.h
// RarIn.h

#ifndef __ARCHIVE_RAR_IN_H
#define __ARCHIVE_RAR_IN_H

#include "Common/DynamicBuffer.h"
#include "Common/MyCom.h"

#include "../../ICoder.h"
#include "../../IStream.h"

#include "../../Common/StreamObjects.h"

#include "../../Crypto/RarAes.h"

#include "RarHeader.h"
#include "RarItem.h"

namespace NArchive {
namespace NRar {

class CInArchiveException
{
public:
  enum CCauseType
  {
    kUnexpectedEndOfArchive = 0,
    kArchiveHeaderCRCError,
    kFileHeaderCRCError,
    kIncorrectArchive
  }
  Cause;
  CInArchiveException(CCauseType cause) :   Cause(cause) {}
};

class CInArchiveInfo
{
public:
  UInt64 StartPosition;
  UInt16 Flags;
  UInt64 CommentPosition;
  UInt16 CommentSize;
  bool IsSolid() const { return (Flags & NHeader::NArchive::kSolid) != 0; }
  bool IsCommented() const {  return (Flags & NHeader::NArchive::kComment) != 0; }
  bool IsVolume() const {  return (Flags & NHeader::NArchive::kVolume) != 0; }
  bool HaveNewVolumeName() const {  return (Flags & NHeader::NArchive::kNewVolName) != 0; }
  bool IsEncrypted() const { return (Flags & NHeader::NArchive::kBlockEncryption) != 0; }
};

class CInArchive
{
  CMyComPtr<IInStream> m_Stream;
  
  UInt64 m_StreamStartPosition;
  UInt64 m_Position;
  UInt64 m_ArchiveStartPosition;
  
  NHeader::NArchive::CHeader360 m_ArchiveHeader;
  CDynamicBuffer<char> m_NameBuffer;
  CDynamicBuffer<wchar_t> _unicodeNameBuffer;
  bool m_SeekOnArchiveComment;
  UInt64 m_ArchiveCommentPosition;
  
  void ReadName(CItemEx &item, int nameSize);
  void ReadHeaderReal(CItemEx &item);
  
  HRESULT ReadBytes(void *data, UInt32 size, UInt32 *aProcessedSize);
  bool ReadBytesAndTestSize(void *data, UInt32 size);
  void ReadBytesAndTestResult(void *data, UInt32 size);
  
  HRESULT FindAndReadMarker(IInStream *stream, const UInt64 *searchHeaderSizeLimit);
  HRESULT Open2(IInStream *stream, const UInt64 *searchHeaderSizeLimit);

  void ThrowExceptionWithCode(CInArchiveException::CCauseType cause);
  void ThrowUnexpectedEndOfArchiveException();
  
  void AddToSeekValue(UInt64 addValue);
  
  CDynamicBuffer<Byte> m_FileHeaderData;
  
  NHeader::NBlock::CBlock m_BlockHeader;

  NCrypto::NRar29::CDecoder *m_RarAESSpec;
  CMyComPtr<ICompressFilter> m_RarAES;
  
  Byte *m_CurData; // it must point to start of Rar::Block
  UInt32 m_CurPos;
  UInt32 m_PosLimit;
  Byte ReadByte();
  UInt16 ReadUInt16();
  UInt32 ReadUInt32();
  void ReadTime(Byte mask, CRarTime &rarTime);

  CBuffer<Byte> m_DecryptedData;
  Byte *m_DecryptedDataAligned;
  UInt32 m_DecryptedDataSize;

  bool m_CryptoMode;
  UInt32 m_CryptoPos;
  void FinishCryptoBlock()
  {
    if (m_CryptoMode)
      while ((m_CryptoPos & 0xF) != 0)
      {
        m_CryptoPos++;
        m_Position++;
      }
  }

public:
  HRESULT Open(IInStream *inStream, const UInt64 *searchHeaderSizeLimit);
  void Close();
  HRESULT GetNextItem(CItemEx &item, ICryptoGetTextPassword *getTextPassword, bool &decryptionError);
  
  void SkipArchiveComment();
  
  void GetArchiveInfo(CInArchiveInfo &archiveInfo) const;
  
  bool SeekInArchive(UInt64 position);
  ISequentialInStream *CreateLimitedStream(UInt64 position, UInt64 size);
};
  
}}
  
#endif
<file_sep>/7-Zip/CPP/7zip/Bundles/Fm/makefile
PROG = 7zFM.exe
CFLAGS = $(CFLAGS) -I ../../../ \
  -DLANG \
  -DNEW_FOLDER_INTERFACE \
  -DEXTERNAL_CODECS \

!IFDEF UNDER_CE
LIBS = $(LIBS) ceshell.lib Commctrl.lib
!ELSE
LIBS = $(LIBS) comctl32.lib htmlhelp.lib comdlg32.lib Mpr.lib Gdi32.lib
CFLAGS = $(CFLAGS) -DWIN_LONG_PATH -DSUPPORT_DEVICE_FILE
!ENDIF

FM_OBJS = \
  $O\App.obj \
  $O\BrowseDialog.obj \
  $O\ClassDefs.obj \
  $O\EnumFormatEtc.obj \
  $O\ExtractCallback.obj \
  $O\FileFolderPluginOpen.obj \
  $O\FilePlugins.obj \
  $O\FM.obj \
  $O\FoldersPage.obj \
  $O\FormatUtils.obj \
  $O\FSFolder.obj \
  $O\FSFolderCopy.obj \
  $O\HelpUtils.obj \
  $O\LangUtils.obj \
  $O\MenuPage.obj \
  $O\MyLoadMenu.obj \
  $O\OpenCallback.obj \
  $O\OptionsDialog.obj \
  $O\Panel.obj \
  $O\PanelCopy.obj \
  $O\PanelCrc.obj \
  $O\PanelDrag.obj \
  $O\PanelFolderChange.obj \
  $O\PanelItemOpen.obj \
  $O\PanelItems.obj \
  $O\PanelKey.obj \
  $O\PanelListNotify.obj \
  $O\PanelMenu.obj \
  $O\PanelOperations.obj \
  $O\PanelSelect.obj \
  $O\PanelSort.obj \
  $O\PanelSplitFile.obj \
  $O\ProgramLocation.obj \
  $O\PropertyName.obj \
  $O\RegistryAssociations.obj \
  $O\RegistryPlugins.obj \
  $O\RegistryUtils.obj \
  $O\RootFolder.obj \
  $O\SplitUtils.obj \
  $O\StringUtils.obj \
  $O\SysIconUtils.obj \
  $O\TextPairs.obj \
  $O\UpdateCallback100.obj \
  $O\ViewSettings.obj \
  $O\AboutDialog.obj \
  $O\ComboDialog.obj \
  $O\CopyDialog.obj \
  $O\EditPage.obj \
  $O\LangPage.obj \
  $O\ListViewDialog.obj \
  $O\MessagesDialog.obj \
  $O\OverwriteDialog.obj \
  $O\PasswordDialog.obj \
  $O\PluginsPage.obj \
  $O\ProgressDialog2.obj \
  $O\SettingsPage.obj \
  $O\SplitDialog.obj \
  $O\SystemPage.obj \

COMMON_OBJS = \
  $O\CommandLineParser.obj \
  $O\CRC.obj \
  $O\IntToString.obj \
  $O\Lang.obj \
  $O\ListFileUtils.obj \
  $O\MyMap.obj \
  $O\MyString.obj \
  $O\MyVector.obj \
  $O\MyXml.obj \
  $O\NewHandler.obj \
  $O\Random.obj \
  $O\StringConvert.obj \
  $O\StringToInt.obj \
  $O\TextConfig.obj \
  $O\UTFConvert.obj \
  $O\Wildcard.obj \

WIN_OBJS = \
  $O\Clipboard.obj \
  $O\DLL.obj \
  $O\Error.obj \
  $O\FileDir.obj \
  $O\FileFind.obj \
  $O\FileIO.obj \
  $O\FileName.obj \
  $O\Memory.obj \
  $O\MemoryLock.obj \
  $O\Menu.obj \
  $O\Process.obj \
  $O\PropVariant.obj \
  $O\PropVariantConversions.obj \
  $O\PropVariantUtils.obj \
  $O\Registry.obj \
  $O\ResourceString.obj \
  $O\Shell.obj \
  $O\Synchronization.obj \
  $O\System.obj \
  $O\Time.obj \
  $O\Window.obj \

!IFNDEF UNDER_CE

FM_OBJS = $(FM_OBJS) \
  $O\FSDrives.obj \
  $O\NetFolder.obj \

WIN_OBJS = $(WIN_OBJS) \
  $O\CommonDialog.obj \
  $O\FileSystem.obj \
  $O\Net.obj \
  $O\Security.obj \

!ENDIF


WIN_CTRL_OBJS = \
  $O\ComboBox.obj \
  $O\Dialog.obj \
  $O\ListView.obj \
  $O\PropertyPage.obj \
  $O\Window2.obj \

7ZIP_COMMON_OBJS = \
  $O\CreateCoder.obj \
  $O\CWrappers.obj \
  $O\FilePathAutoRename.obj \
  $O\FileStreams.obj \
  $O\FilterCoder.obj \
  $O\InBuffer.obj \
  $O\InOutTempBuffer.obj \
  $O\LimitedStreams.obj \
  $O\LockedStream.obj \
  $O\MemBlocks.obj \
  $O\MethodId.obj \
  $O\MethodProps.obj \
  $O\OffsetStream.obj \
  $O\OutBuffer.obj \
  $O\OutMemStream.obj \
  $O\ProgressMt.obj \
  $O\ProgressUtils.obj \
  $O\StreamBinder.obj \
  $O\StreamObjects.obj \
  $O\StreamUtils.obj \
  $O\VirtThread.obj \

AR_OBJS = \
  $O\ArjHandler.obj \
  $O\Bz2Handler.obj \
  $O\CpioHandler.obj \
  $O\DebHandler.obj \
  $O\DeflateProps.obj \
  $O\DmgHandler.obj \
  $O\ElfHandler.obj \
  $O\FatHandler.obj \
  $O\FlvHandler.obj \
  $O\GzHandler.obj \
  $O\LzhHandler.obj \
  $O\LzmaHandler.obj \
  $O\MachoHandler.obj \
  $O\MbrHandler.obj \
  $O\MslzHandler.obj \
  $O\MubHandler.obj \
  $O\NtfsHandler.obj \
  $O\PeHandler.obj \
  $O\RpmHandler.obj \
  $O\SplitHandler.obj \
  $O\SwfHandler.obj \
  $O\VhdHandler.obj \
  $O\XarHandler.obj \
  $O\XzHandler.obj \
  $O\ZHandler.obj \

AR_COMMON_OBJS = \
  $O\CoderMixer2.obj \
  $O\CoderMixer2MT.obj \
  $O\CrossThreadProgress.obj \
  $O\DummyOutStream.obj \
  $O\FindSignature.obj \
  $O\InStreamWithCRC.obj \
  $O\ItemNameUtils.obj \
  $O\MultiStream.obj \
  $O\OutStreamWithCRC.obj \
  $O\OutStreamWithSha1.obj \
  $O\HandlerOut.obj \
  $O\ParseProperties.obj \

UI_COMMON_OBJS = \
  $O\ArchiveCommandLine.obj \
  $O\ArchiveExtractCallback.obj \
  $O\ArchiveName.obj \
  $O\ArchiveOpenCallback.obj \
  $O\Bench.obj \
  $O\CompressCall2.obj \
  $O\DefaultName.obj \
  $O\EnumDirItems.obj \
  $O\Extract.obj \
  $O\ExtractingFilePath.obj \
  $O\LoadCodecs.obj \
  $O\OpenArchive.obj \
  $O\PropIDUtils.obj \
  $O\SetProperties.obj \
  $O\SortUtils.obj \
  $O\TempFiles.obj \
  $O\Update.obj \
  $O\UpdateAction.obj \
  $O\UpdateCallback.obj \
  $O\UpdatePair.obj \
  $O\UpdateProduce.obj \
  $O\WorkDir.obj \
  $O\ZipRegistry.obj \

AGENT_OBJS = \
  $O\Agent.obj \
  $O\AgentOut.obj \
  $O\AgentProxy.obj \
  $O\ArchiveFolder.obj \
  $O\ArchiveFolderOpen.obj \
  $O\ArchiveFolderOut.obj \
  $O\UpdateCallbackAgent.obj \

EXPLORER_OBJS = \
  $O\ContextMenu.obj \
  $O\MyMessages.obj \
  $O\RegistryContextMenu.obj \

GUI_OBJS = \
  $O\BenchmarkDialog.obj \
  $O\CompressDialog.obj \
  $O\ExtractDialog.obj \
  $O\ExtractGUI.obj \
  $O\UpdateCallbackGUI.obj \
  $O\UpdateGUI.obj \


7Z_OBJS = \
  $O\7zCompressionMode.obj \
  $O\7zDecode.obj \
  $O\7zEncode.obj \
  $O\7zExtract.obj \
  $O\7zFolderInStream.obj \
  $O\7zFolderOutStream.obj \
  $O\7zHandler.obj \
  $O\7zHandlerOut.obj \
  $O\7zHeader.obj \
  $O\7zIn.obj \
  $O\7zOut.obj \
  $O\7zProperties.obj \
  $O\7zSpecStream.obj \
  $O\7zUpdate.obj \
  $O\7zRegister.obj \

CAB_OBJS = \
  $O\CabBlockInStream.obj \
  $O\CabHandler.obj \
  $O\CabHeader.obj \
  $O\CabIn.obj \
  $O\CabRegister.obj \

CHM_OBJS = \
  $O\ChmHandler.obj \
  $O\ChmHeader.obj \
  $O\ChmIn.obj \
  $O\ChmRegister.obj \

COM_OBJS = \
  $O\ComHandler.obj \
  $O\ComIn.obj \
  $O\ComRegister.obj \

HFS_OBJS = \
  $O\HfsHandler.obj \
  $O\HfsIn.obj \
  $O\HfsRegister.obj \

ISO_OBJS = \
  $O\IsoHandler.obj \
  $O\IsoHeader.obj \
  $O\IsoIn.obj \
  $O\IsoRegister.obj \

NSIS_OBJS = \
  $O\NsisDecode.obj \
  $O\NsisHandler.obj \
  $O\NsisIn.obj \
  $O\NsisRegister.obj \

RAR_OBJS = \
  $O\RarHandler.obj \
  $O\RarHeader.obj \
  $O\RarIn.obj \
  $O\RarItem.obj \
  $O\RarVolumeInStream.obj \
  $O\RarRegister.obj \

TAR_OBJS = \
  $O\TarHandler.obj \
  $O\TarHandlerOut.obj \
  $O\TarHeader.obj \
  $O\TarIn.obj \
  $O\TarOut.obj \
  $O\TarUpdate.obj \
  $O\TarRegister.obj \

UDF_OBJS = \
  $O\UdfHandler.obj \
  $O\UdfIn.obj \
  $O\UdfRegister.obj \

WIM_OBJS = \
  $O\WimHandler.obj \
  $O\WimIn.obj \
  $O\WimRegister.obj \

ZIP_OBJS = \
  $O\ZipAddCommon.obj \
  $O\ZipHandler.obj \
  $O\ZipHandlerOut.obj \
  $O\ZipHeader.obj \
  $O\ZipIn.obj \
  $O\ZipItem.obj \
  $O\ZipOut.obj \
  $O\ZipUpdate.obj \
  $O\ZipRegister.obj \

COMPRESS_OBJS = \
  $O\ArjDecoder1.obj \
  $O\ArjDecoder2.obj \
  $O\Bcj2Coder.obj \
  $O\Bcj2Register.obj \
  $O\BcjCoder.obj \
  $O\BcjRegister.obj \
  $O\BitlDecoder.obj \
  $O\BranchCoder.obj \
  $O\BranchMisc.obj \
  $O\BranchRegister.obj \
  $O\ByteSwap.obj \
  $O\BZip2Crc.obj \
  $O\BZip2Decoder.obj \
  $O\BZip2Encoder.obj \
  $O\BZip2Register.obj \
  $O\CopyCoder.obj \
  $O\CopyRegister.obj \
  $O\Deflate64Register.obj \
  $O\DeflateDecoder.obj \
  $O\DeflateEncoder.obj \
  $O\DeflateNsisRegister.obj \
  $O\DeflateRegister.obj \
  $O\DeltaFilter.obj \
  $O\ImplodeDecoder.obj \
  $O\ImplodeHuffmanDecoder.obj \
  $O\LzhDecoder.obj \
  $O\Lzma2Decoder.obj \
  $O\Lzma2Encoder.obj \
  $O\Lzma2Register.obj \
  $O\LzmaDecoder.obj \
  $O\LzmaEncoder.obj \
  $O\LzmaRegister.obj \
  $O\LzOutWindow.obj \
  $O\Lzx86Converter.obj \
  $O\LzxDecoder.obj \
  $O\PpmdDecoder.obj \
  $O\PpmdEncoder.obj \
  $O\PpmdRegister.obj \
  $O\QuantumDecoder.obj \
  $O\Rar1Decoder.obj \
  $O\Rar2Decoder.obj \
  $O\Rar3Decoder.obj \
  $O\Rar3Vm.obj \
  $O\RarCodecsRegister.obj \
  $O\ShrinkDecoder.obj \
  $O\ZlibDecoder.obj \
  $O\ZlibEncoder.obj \
  $O\ZDecoder.obj \

CRYPTO_OBJS = \
  $O\7zAes.obj \
  $O\7zAesRegister.obj \
  $O\HmacSha1.obj \
  $O\MyAes.obj \
  $O\Pbkdf2HmacSha1.obj \
  $O\RandGen.obj \
  $O\Rar20Crypto.obj \
  $O\RarAes.obj \
  $O\Sha1.obj \
  $O\WzAes.obj \
  $O\ZipCrypto.obj \
  $O\ZipStrong.obj \


C_OBJS = \
  $O\7zBuf2.obj \
  $O\7zStream.obj \
  $O\Alloc.obj \
  $O\Bra.obj \
  $O\Bra86.obj \
  $O\BraIA64.obj \
  $O\BwtSort.obj \
  $O\CpuArch.obj \
  $O\Delta.obj \
  $O\HuffEnc.obj \
  $O\LzFind.obj \
  $O\LzFindMt.obj \
  $O\Lzma2Dec.obj \
  $O\Lzma2Enc.obj \
  $O\LzmaDec.obj \
  $O\LzmaEnc.obj \
  $O\MtCoder.obj \
  $O\Sha256.obj \
  $O\Sort.obj \
  $O\Threads.obj \
  $O\Xz.obj \
  $O\XzCrc64.obj \
  $O\XzDec.obj \
  $O\XzEnc.obj \
  $O\XzIn.obj \

!include "../../Aes.mak"
!include "../../Crc.mak"

OBJS = \
  $O\StdAfx.obj \
  $(FM_OBJS)\
  $(COMMON_OBJS) \
  $(WIN_OBJS) \
  $(WIN_CTRL_OBJS) \
  $(7ZIP_COMMON_OBJS) \
  $(AR_OBJS) \
  $(AR_COMMON_OBJS) \
  $(UI_COMMON_OBJS) \
  $(AGENT_OBJS) \
  $(EXPLORER_OBJS) \
  $(GUI_OBJS) \
  $(7Z_OBJS) \
  $(CAB_OBJS) \
  $(CHM_OBJS) \
  $(COM_OBJS) \
  $(HFS_OBJS) \
  $(ISO_OBJS) \
  $(NSIS_OBJS) \
  $(RAR_OBJS) \
  $(TAR_OBJS) \
  $(UDF_OBJS) \
  $(WIM_OBJS) \
  $(ZIP_OBJS) \
  $(COMPRESS_OBJS) \
  $(CRYPTO_OBJS) \
  $(C_OBJS) \
  $(ASM_OBJS) \
  $O\resource.res \

!include "../../../Build.mak"

$(FM_OBJS): ../../UI/FileManager/$(*B).cpp
	$(COMPL)
$(COMMON_OBJS): ../../../Common/$(*B).cpp
	$(COMPL)
$(WIN_OBJS): ../../../Windows/$(*B).cpp
	$(COMPL)
$(WIN_CTRL_OBJS): ../../../Windows/Control/$(*B).cpp
	$(COMPL)
$(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp
	$(COMPL)

$(AR_OBJS): ../../Archive/$(*B).cpp
	$(COMPL)
$(AR_COMMON_OBJS): ../../Archive/Common/$(*B).cpp
	$(COMPL)

$(7Z_OBJS): ../../Archive/7z/$(*B).cpp
	$(COMPL)
$(CAB_OBJS): ../../Archive/Cab/$(*B).cpp
	$(COMPL)
$(CHM_OBJS): ../../Archive/Chm/$(*B).cpp
	$(COMPL)
$(COM_OBJS): ../../Archive/Com/$(*B).cpp
	$(COMPL)
$(HFS_OBJS): ../../Archive/Hfs/$(*B).cpp
	$(COMPL)
$(ISO_OBJS): ../../Archive/Iso/$(*B).cpp
	$(COMPL)
$(NSIS_OBJS): ../../Archive/Nsis/$(*B).cpp
	$(COMPL)
$(RAR_OBJS): ../../Archive/Rar/$(*B).cpp
	$(COMPL)
$(TAR_OBJS): ../../Archive/Tar/$(*B).cpp
	$(COMPL)
$(UDF_OBJS): ../../Archive/Udf/$(*B).cpp
	$(COMPL)
$(WIM_OBJS): ../../Archive/Wim/$(*B).cpp
	$(COMPL)
$(ZIP_OBJS): ../../Archive/Zip/$(*B).cpp
	$(COMPL)

$(COMPRESS_OBJS): ../../Compress/$(*B).cpp
	$(COMPL_O2)

$(CRYPTO_OBJS): ../../Crypto/$(*B).cpp
	$(COMPL_O2)

$(UI_COMMON_OBJS): ../../UI/Common/$(*B).cpp
	$(COMPL)
$(AGENT_OBJS): ../../UI/Agent/$(*B).cpp
	$(COMPL)
$(EXPLORER_OBJS): ../../UI/Explorer/$(*B).cpp
	$(COMPL)
$(GUI_OBJS): ../../UI/GUI/$(*B).cpp
	$(COMPL)

$(C_OBJS): ../../../../C/$(*B).c
	$(COMPL_O2)

!include "../../Asm.mak"
<file_sep>/FBReaderJ/jni/LineBreak/TxtParser.cpp
#include "TxtParser.h"
#include <jni.h>
#include "../Ext_Type.h"
#include "../HanvonUtil.h"

#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
enum
{
  ENCODING_UNKNOWN,
  ENCODING_ASCII,
  ENCODING_LATIN1,
  ENCODING_UTF8,
  ENCODING_UTF16BE,
  ENCODING_UTF16LE,
  ENCODING_UTF32BE,
  ENCODING_UTF32LE,
  ENCODING_UCS2, /* Native byte order assumed */
  ENCODING_UCS4,
/* Native byte order assumed */
};

#define UNKNOWN_ASCII	'?'
#define UNKNOWN_UNICODE	0xFFFD

enum
{
  bit7 = 0x80,
  bit6 = 0x40,
  bit5 = 0x20,
  bit4 = 0x10,
  bit3 = 8,
  bit2 = 4,
  bit1 = 2,
  bit0 = 1
};

long
Hanvoniconv(int from, int to, const unsigned char *inbuf, unsigned int inbytesleft,
    unsigned char *outbuf, unsigned int outbytesleft)
{
  const unsigned char *src = NULL;
  const unsigned char *dst = NULL;
  unsigned int srclen, dstlen;
  int ch = 0;
  unsigned int total = 0;

  if (!inbuf)
    {
      /* Reset the context */
      return 0;
    }
  if (!outbuf || !outbytesleft)
    {
      return 0;
    }
  src = inbuf;
  srclen = inbytesleft;
  dst = outbuf;
  dstlen = outbytesleft;

  total = 0;
  while (srclen > 0)
    {
      /* Decode a character */
      switch (from)
        {
      case ENCODING_ASCII:
        {
          unsigned char *p = (unsigned char *) src;
          ch = (unsigned int) (p[0] & 0x7F);
          ++src;
          --srclen;
        }
        break;
      case ENCODING_LATIN1:
        {
          unsigned char *p = (unsigned char *) src;
          ch = (unsigned int) p[0];
          ++src;
          --srclen;
        }
        break;
      case ENCODING_UTF8: /* RFC 3629 */
        {
          unsigned char *p = (unsigned char *) src;
          unsigned char a = 0, b = 0, c = 0;

          a = *p++;
          src++;
          --srclen;
          if ((a & (bit7 | bit6 | bit5)) == (bit7 | bit6))
            { // 0x000080-0x0007ff
                {
                  b = *p++;
                  src++;
                  --srclen;
                  ch = (unsigned short) (((a & (bit4 | bit3 | bit2)) >> 2)
                      * 0x100);
                  ch += (unsigned short) (((a & (bit1 | bit0)) << 6) | (b
                      & (bit5 | bit4 | bit3 | bit2 | bit1 | bit0)));
                }
            }
          else if ((a & (bit7 | bit6 | bit5 | bit4)) == (bit7 | bit6 | bit5)) // 0x000800-0x00ffff
            {
              b = *p++;
              src++;
              --srclen;
              c = *p++;
              src++;
              --srclen;
              ch = (unsigned short) ((((a & (bit3 | bit2 | bit1 | bit0)) << 4)
                  | ((b & (bit5 | bit4 | bit3 | bit2)) >> 2)) * 0x100);
              ch += (unsigned short) (((b & (bit1 | bit0)) << 6) | (c & (bit5
                  | bit4 | bit3 | bit2 | bit1 | bit0)));
            }
          else
            {
              ch = a;
            }
        }
        break;
      case ENCODING_UTF16BE: /* RFC 2781 */
        {
          unsigned char *p = (unsigned char *) src;
          unsigned short W1, W2;
          if (srclen >= 2)
            {
              W1 = ((unsigned short) p[0] << 8) | (unsigned short) p[1];
              src += 2;
              srclen -= 2;
              if (W1 < 0xD800 || W1 > 0xDFFF)
                {
                  ch = (unsigned int) W1;
                }
              else
                {
                  if (W1 <= 0xDBFF)
                    {
                      if (srclen >= 2)
                        {
                          p = (unsigned char *) src;
                          W2 = ((unsigned short) p[0] << 8)
                              | (unsigned short) p[1];
                          src += 2;
                          srclen -= 2;
                          if (!(W2 < 0xDC00 || W2 > 0xDFFF))
                            {
                              ch = (((unsigned int) (W1 & 0x3FF) << 10)
                                  | (unsigned int) (W2 & 0x3FF)) + 0x10000;
                            }
                          else
                            {
                              ch = UNKNOWN_UNICODE;
                            }

                        }
                    }

                }

            }
        }

        break;
      case ENCODING_UTF16LE: /* RFC 2781 */
        {
          unsigned char *p = (unsigned char *) src;
          unsigned short W1 = 0, W2 = 0;
          if (srclen >= 2)
            {
              W1 = ((unsigned short) p[1] << 8) | (unsigned short) p[0];
              src += 2;
              srclen -= 2;
              if (W1 < 0xD800 || W1 > 0xDFFF)
                {
                  ch = (unsigned int) W1;
                }
              else
                {
                  if (W1 <= 0xDBFF)
                    {
                      if (srclen >= 2)
                        {
                          p = (unsigned char *) src;
                          W2 = ((unsigned short) p[1] << 8)
                              | (unsigned short) p[0];
                          src += 2;
                          srclen -= 2;
                          if ((!W2 < 0xDC00 || W2 > 0xDFFF))
                            {
                              ch = (((unsigned int) (W1 & 0x3FF) << 10)
                                  | (unsigned int) (W2 & 0x3FF)) + 0x10000;
                            }
                        }
                      else
                        {
                          src += srclen;
                          srclen -= srclen;
                        }
                    }
                }
            }
          else
            {
              src += srclen;
              srclen -= srclen;
            }
        }

        break;
      case ENCODING_UTF32BE:
        {
          unsigned char *p = (unsigned char *) src;
          if (srclen >= 4)
            {
              ch = ((unsigned int) p[0] << 24) | ((unsigned int) p[1] << 16)
                  | ((unsigned int) p[2] << 8) | (unsigned int) p[3];
              src += 4;
              srclen -= 4;
            }
          else
            {
              src += srclen;
              srclen -= srclen;
            }
        }
        break;
      case ENCODING_UTF32LE:
        {
          unsigned char *p = (unsigned char *) src;
          if (srclen >= 4)
            {
              ch = ((unsigned int) p[3] << 24) | ((unsigned int) p[2] << 16)
                  | ((unsigned int) p[1] << 8) | (unsigned int) p[0];
              src += 4;
              srclen -= 4;
            }
          else
            {
              src += srclen;
              srclen -= srclen;
            }

        }
        break;
      case ENCODING_UCS2:
        {
          unsigned short *p = (unsigned short *) src;
          if (srclen >= 2)
            {
              ch = *p;
              src += 2;
              srclen -= 2;
            }
          else
            {
              src += srclen;
              srclen -= srclen;
            }
        }
        break;
      case ENCODING_UCS4:
        {
          unsigned int *p = (unsigned int *) src;
          if (srclen >= 4)
            {
              ch = *p;
              src += 4;
              srclen -= 4;
            }
          else
            {
              src += srclen;
              srclen -= srclen;
            }
        }
        break;
        }

      /* Encode a character */
      switch (to)
        {
      case ENCODING_ASCII:
        {
          unsigned char *p = (unsigned char *) dst;
          if (dstlen >= 1)
            {
              if (ch <= 0x7F)
                {
                  *p = (unsigned char) ch;
                }
              else
                {

                }
            }
          ++dst;
          --dstlen;
        }
        break;
      case ENCODING_LATIN1:
        {
          unsigned char *p = (unsigned char *) dst;
          if (dstlen >= 1)
            {
              *p = (unsigned char) ch;
            }
          ++dst;
          --dstlen;
        }
        break;
      case ENCODING_UTF8: /* RFC 3629 */
        {
          unsigned char *p = (unsigned char *) dst;
          if (ch > 0x10FFFF)
            {
              ch = UNKNOWN_UNICODE;
            }
          if (ch <= 0x7F)
            {
              if (dstlen >= 1)
                {
                  *p = (unsigned char) ch;
                  ++dst;
                  --dstlen;
                }
            }
          else if (ch <= 0x7FF)
            {
              if (dstlen >= 2)
                {
                  p[0] = 0xC0 | (unsigned char) ((ch >> 6) & 0x1F);
                  p[1] = 0x80 | (unsigned char) (ch & 0x3F);
                  dst += 2;
                  dstlen -= 2;
                }

            }
          else if (ch <= 0xFFFF)
            {
              if (dstlen >= 3)
                {
                  p[0] = 0xE0 | (unsigned char) ((ch >> 12) & 0x0F);
                  p[1] = 0x80 | (unsigned char) ((ch >> 6) & 0x3F);
                  p[2] = 0x80 | (unsigned char) (ch & 0x3F);
                  dst += 3;
                  dstlen -= 3;
                }

            }
          else if (ch <= 0x1FFFFF)
            {
              if (dstlen >= 4)
                {
                  p[0] = 0xF0 | (unsigned char) ((ch >> 18) & 0x07);
                  p[1] = 0x80 | (unsigned char) ((ch >> 12) & 0x3F);
                  p[2] = 0x80 | (unsigned char) ((ch >> 6) & 0x3F);
                  p[3] = 0x80 | (unsigned char) (ch & 0x3F);
                  dst += 4;
                  dstlen -= 4;
                }
            }
          else if (ch <= 0x3FFFFFF)
            {
              if (dstlen >= 5)
                {
                  p[0] = 0xF8 | (unsigned char) ((ch >> 24) & 0x03);
                  p[1] = 0x80 | (unsigned char) ((ch >> 18) & 0x3F);
                  p[2] = 0x80 | (unsigned char) ((ch >> 12) & 0x3F);
                  p[3] = 0x80 | (unsigned char) ((ch >> 6) & 0x3F);
                  p[4] = 0x80 | (unsigned char) (ch & 0x3F);
                  dst += 5;
                  dstlen -= 5;
                }
            }
          else
            {
              if (dstlen >= 6)
                {
                  p[0] = 0xFC | (unsigned char) ((ch >> 30) & 0x01);
                  p[1] = 0x80 | (unsigned char) ((ch >> 24) & 0x3F);
                  p[2] = 0x80 | (unsigned char) ((ch >> 18) & 0x3F);
                  p[3] = 0x80 | (unsigned char) ((ch >> 12) & 0x3F);
                  p[4] = 0x80 | (unsigned char) ((ch >> 6) & 0x3F);
                  p[5] = 0x80 | (unsigned char) (ch & 0x3F);
                  dst += 6;
                  dstlen -= 6;
                }
            }
        }
        break;
      case ENCODING_UTF16BE: /* RFC 2781 */
        {
          unsigned char *p = (unsigned char *) dst;
          if (ch > 0x10FFFF)
            {
              ch = UNKNOWN_UNICODE;
            }
          if (ch < 0x10000)
            {
              if (dstlen >= 2)
                {
                  p[0] = (unsigned char) (ch >> 8);
                  p[1] = (unsigned char) ch;
                  dst += 2;
                  dstlen -= 2;
                }
            }
          else
            {
              unsigned short W1, W2;
              if (dstlen >= 4)
                {
                  ch = ch - 0x10000;
                  W1 = 0xD800 | (unsigned short) ((ch >> 10) & 0x3FF);
                  W2 = 0xDC00 | (unsigned short) (ch & 0x3FF);
                  p[0] = (unsigned char) (W1 >> 8);
                  p[1] = (unsigned char) W1;
                  p[2] = (unsigned char) (W2 >> 8);
                  p[3] = (unsigned char) W2;
                  dst += 4;
                  dstlen -= 4;
                }
            }
        }
        break;
      case ENCODING_UTF16LE: /* RFC 2781 */
        {
          unsigned char *p = (unsigned char *) dst;
          if (ch > 0x10FFFF)
            {
              ch = UNKNOWN_UNICODE;
            }
          if (ch < 0x10000)
            {
              if (dstlen >= 2)
                {
                  p[1] = (unsigned char) (ch >> 8);
                  p[0] = (unsigned char) ch;
                  dst += 2;
                  dstlen -= 2;
                }
            }
          else
            {
              unsigned short W1, W2;
              if (dstlen >= 4)
                {
                  ch = ch - 0x10000;
                  W1 = 0xD800 | (unsigned short) ((ch >> 10) & 0x3FF);
                  W2 = 0xDC00 | (unsigned short) (ch & 0x3FF);
                  p[1] = (unsigned char) (W1 >> 8);
                  p[0] = (unsigned char) W1;
                  p[3] = (unsigned char) (W2 >> 8);
                  p[2] = (unsigned char) W2;
                  dst += 4;
                  dstlen -= 4;
                }
            }
        }
        break;
      case ENCODING_UTF32BE:
        {
          unsigned char *p = (unsigned char *) dst;
          if (ch > 0x10FFFF)
            {
              ch = UNKNOWN_UNICODE;
            }
          if (dstlen >= 4)
            {
              p[0] = (unsigned char) (ch >> 24);
              p[1] = (unsigned char) (ch >> 16);
              p[2] = (unsigned char) (ch >> 8);
              p[3] = (unsigned char) ch;
              dst += 4;
              dstlen -= 4;
            }
        }
        break;
      case ENCODING_UTF32LE:
        {
          unsigned char *p = (unsigned char *) dst;
          if (ch > 0x10FFFF)
            {
              ch = UNKNOWN_UNICODE;
            }
          if (dstlen >= 4)
            {
              p[3] = (unsigned char) (ch >> 24);
              p[2] = (unsigned char) (ch >> 16);
              p[1] = (unsigned char) (ch >> 8);
              p[0] = (unsigned char) ch;
              dst += 4;
              dstlen -= 4;
            }
        }
        break;
      case ENCODING_UCS2:
        {
          unsigned short *p = (unsigned short *) dst;
          if (ch > 0xFFFF)
            {
              ch = UNKNOWN_UNICODE;
            }
          if (dstlen >= 2)
            {
              *p = (unsigned short) ch;
              dst += 2;
              dstlen -= 2;
            }
        }
        break;
      case ENCODING_UCS4:
        {
          unsigned int *p = (unsigned int *) dst;
          if (ch > 0x7FFFFFFF)
            {
              ch = UNKNOWN_UNICODE;
            }
          if (dstlen >= 4)
            {
              *p = ch;
              dst += 4;
              dstlen -= 4;
            }
        }
        break;
        }

      /* Update state */
      ++total;
    }
  return total;
}

void
Java_org_parser_txt_TxtParser_Parser(JNIEnv *env, jobject thiz,
    jobject thisParser, jstring strPath)
{
  LOGD("Enter TxtParser_Parser\n");
  jmethodID startElementID = NULL;
  jmethodID endElementID = NULL;
  jmethodID characterDataID = NULL;
  jclass clsParser = env->GetObjectClass(thisParser);

  if (clsParser)
    {
      startElementID
          = env->GetMethodID(clsParser, "startElementHandler", "()V");
      if (!startElementID)
        {
          LOGD("GetMethodID startElementHandler failed\n");
        }
      endElementID = env->GetMethodID(clsParser, "endElementHandler", "()V");
      if (!endElementID)
        {
          LOGD("GetMethodID endElementID failed\n");
        }
      characterDataID = env->GetMethodID(clsParser, "characterDataHandler",
          "(Ljava/lang/String;)V");
      if (!characterDataID)
        {
          LOGD("GetMethodID characterDataID failed\n");
        }
    }
  else
    {
      LOGD("GetObjectClass failed\n");
    }
  if (!startElementID || !endElementID || !characterDataID)
    {
      return;
    }
  if (startElementID)
    {
      env->CallVoidMethod(thisParser, startElementID);

    }
  long nFrom = ENCODING_ASCII;
  char szFilePath[MAX_PATH * 2] =
    { 0 };
  long nPathLen = env->GetStringUTFLength(strPath);
  LOGD("Enter 1国家\n");
  env->GetStringUTFRegion(strPath, 0, nPathLen, szFilePath);
  LOGD("Enter 2\n"); LOGD(szFilePath);
  FILE* pFile = NULL;
  long nFileOffset = 0;
  unsigned short ashtUnicodeBuffer[2048] =
    { 0 };
  pFile = fopen(szFilePath, "r");
  if (pFile)
    {
      const long BUFSIZE = 2048;
      unsigned char *buffer = new unsigned char[BUFSIZE];
      //std::string str;
      long nLength = 0;
      if (startElementID)
        {
          env->CallVoidMethod(thisParser, startElementID);
        }
      do
        {
          nLength = fread(buffer, sizeof(char), BUFSIZE, pFile);
          unsigned char *start = buffer;
          if (!nFileOffset)
            {
              if (nLength >= 2 && (buffer[0] == 0xFF && buffer[1] == 0xFE))
                {
                  nFrom = ENCODING_UTF16LE;
                  nFileOffset += 2;
                }
              else if (nLength >= 2 && (buffer[0] == 0xFE && buffer[1] == 0xFF))
                {
                  nFrom = ENCODING_UTF16BE;
                  nFileOffset += 2;
                }
              else if (nLength >= 3 && (buffer[0] == 0xEF && buffer[1] == 0xBB
                  && buffer[2] == 0xBF))
                {
                  nFrom = ENCODING_UTF8;
                  nFileOffset += 3;
                }
              else if (nLength >= 4 && (buffer[0] == 0xFF && buffer[1] == 0xFE
                  && buffer[2] == 0x00 && buffer[3] == 0x00))
                {
                  nFrom = ENCODING_UTF32LE;
                  nFileOffset += 4;
                }
              else if (nLength >= 4 && (buffer[0] == 0x00 && buffer[1] == 0x00
                  && buffer[2] == 0xFE && buffer[3] == 0xFF))
                {
                  nFrom = ENCODING_UTF32BE;
                  nFileOffset += 4;
                }
              start += nFileOffset;
            }
          //LOGD(start);
          const unsigned char *end = buffer + nLength;
          for (unsigned char *ptr = start; ptr != end; ++ptr)
            {
              if (*ptr == '\n' || *ptr == '\r')
                {
                  bool skipNewLine = false;
                  if (*ptr == '\r' && (ptr + 1) != end && *(ptr + 1) == '\n')
                    {
                      skipNewLine = true;
                      *ptr = '\n';
                    }
                  if (start != ptr)
                    {
                      //str.erase();
                      //myConverter->convert(str, start, ptr + 1);
                      //characterDataHandler(str);
                      ashtUnicodeBuffer[0] = 0;
                      ZeroMemory(ashtUnicodeBuffer, sizeof(ashtUnicodeBuffer));
                      long nLen = Hanvoniconv(nFrom, ENCODING_UTF16LE, start, ptr + 1 - start, (unsigned char*)ashtUnicodeBuffer, sizeof(ashtUnicodeBuffer) - 10);
                       if (nLen > 0)
                        {
                          char szCode[500] =
                            { 0 };
                          strcpy(szCode, "guojiadeshiqijie 汉王科技");
                          jstring strCode = env->NewString(ashtUnicodeBuffer,
                              nLen / 2);
                          if (characterDataID)
                            {
                              env->CallVoidMethod(thisParser, characterDataID,
                                  strCode);
                            }
                        }
                      //LOGD(szUnicode);
                    }
                  if (skipNewLine)
                    {
                      ++ptr;
                    }
                  start = ptr + 1;
                  if (endElementID)
                    {
                      env->CallVoidMethod(thisParser, endElementID);
                    }
                  if (startElementID)
                    {
                      env->CallVoidMethod(thisParser, startElementID);
                    }
                  //newLineHandler();
                }
              else if (0/*isspace((unsigned char) *ptr)*/)
                {
                  if (*ptr != '\t')
                    {
                      *ptr = ' ';
                    }
                }
              else
                {
                }
            }
          if (start != end)
            {
              //str.erase();
              //myConverter->convert(str, start, end);
              //characterDataHandler(str);
            }
        }
      while (nLength == BUFSIZE);
      delete[] buffer;
      buffer = NULL;
      //endDocumentHandler();
      fclose(pFile);
      pFile = NULL;
      //stream.close();

    }
  else
    {
      LOGD("TxtParser_Parser:file open failed\n");
    }

  LOGD("Leave TxtParser_Parser\n");
}
<file_sep>/FingerSuite/FingerNotification/NotifWindow.h
// WTLApp1View.h : interface of the CWTLApp1View class
//
/////////////////////////////////////////////////////////////////////////////

#pragma once

#include "InterceptEngine.h"

#include <initguid.h>
//#include <piedocvw.h>
#include <webvw.h>

#define IDT_TIMER_MENU_ANIMATION  10110
#define TMR_MENU_ANIMATION        10

#define BORDER_WIDTH           10
#define UM_STARTANIM    WM_USER + 1 
#define UM_MINIMIZE     WM_USER + 2

#define IDC_HTMLVIEW     10

//#define CUSTOM_CSS _T("INPUT[type='button'] { BORDER-RIGHT: #7b8194 1px solid; PADDING-RIGHT: 4px; BACKGROUND-POSITION: left bottom; BORDER-TOP: #a5a9b6 1px solid; PADDING-LEFT: 4px; FONT-WEIGHT: bold; FONT-SIZE: 9pt! important; BACKGROUND-IMAGE: url(btn_background.gif); PADDING-BOTTOM: 4px; MARGIN: 2px; VERTICAL-ALIGN: middle; BORDER-LEFT: #a5a9b6 1px solid; COLOR: #586073! important; LINE-HEIGHT: 20px; PADDING-TOP: 4px; BORDER-BOTTOM: #7b8194 1px solid; BACKGROUND-REPEAT: repeat-x; FONT-FAMILY: Tahoma; WHITE-SPACE: nowrap; BACKGROUND-COLOR: #ffffff; TEXT-ALIGN: center; TEXT-DECORATION: none }")

#define CUSTOM_CSS _T("INPUT[type='button'] { BORDER: none; PADDING-RIGHT: 4px; BACKGROUND-POSITION: left bottom; PADDING-LEFT: 4px; FONT-WEIGHT: bold; FONT-SIZE: 9pt! important; BACKGROUND-IMAGE: url(fngrnotif_btn_bkg.gif); PADDING-BOTTOM: 4px; MARGIN: 2px; VERTICAL-ALIGN: middle; COLOR: #000000! important; LINE-HEIGHT: 20px; PADDING-TOP: 4px; BACKGROUND-REPEAT: repeat-x; FONT-FAMILY: Tahoma; WHITE-SPACE: nowrap; BACKGROUND-COLOR: #ffffff; TEXT-ALIGN: center; TEXT-DECORATION: none }")

template <class T>
class CNotifWindow : public CWindowImpl<T, CWindow, CControlWinTraits>
{
public:
	DECLARE_WND_CLASS(NULL)

	CNotifWindow ()
	{
	}

	BOOL PreTranslateMessage(MSG* pMsg)
	{
		pMsg;
		return FALSE;
	}

	void SetScaleFactor(int value)
	{
		m_scaleFactor = value;
	}

	int GetScaleFactor()
	{
		return m_scaleFactor;
	}

	void Show()
	{
		ModifyShape();
		StartAnimation();
	}

	BOOL SetNotification(LPNOTIFICATIONINFO pData)
	{
		m_pInfo = pData;

		return TRUE;
	}

	void DoPaint(CBufferedPaintDC /*dc*/)
	{
		// must be implemented in a derived class
		ATLASSERT(FALSE);
	}



	BEGIN_MSG_MAP(CNotifWindow)
		MESSAGE_HANDLER(WM_CREATE, OnCreate)
		MESSAGE_HANDLER(WM_SIZE, OnSize)
		MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBackground)
		MESSAGE_HANDLER(WM_TIMER, OnTimer)
		MESSAGE_HANDLER(WM_PAINT, OnPaint)
		MESSAGE_HANDLER(UM_STARTANIM, OnStartAnim)
		//MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown)
		//MESSAGE_HANDLER(WM_LBUTTONUP, OnLButtonUp)
		//MESSAGE_HANDLER(WM_KEYDOWN, OnKeyDown)
		FORWARD_NOTIFICATIONS()
	END_MSG_MAP()

	LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		ModifyTopShape();

		if (m_fCaption != NULL)
		{
			LOGFONT lf; m_fCaption.GetLogFont(&lf);
			lf.lfHeight += 7 * m_scaleFactor;
			m_fCalendar.CreateFontIndirect(&lf);
		}

		return 0;
	}

	LRESULT OnSize(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled)
	{
		return 0;
	}

	LRESULT OnEraseBackground(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		return 1;
	}

	LRESULT OnPaint(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled)
	{
		RECT rc; GetClientRect(&rc);
		CBufferedPaintDC dc(m_hWnd, 0);

		RECT rcHead; CopyRect(&rcHead, &rc);
		rcHead.bottom = m_imgHeader.GetHeight();
		m_imgHeader.Draw(dc, rcHead);

		// draw title
		dc.SetBkMode(TRANSPARENT);
		dc.SetTextColor(m_clCaptionText);
		CFont oldFont = dc.SelectFont(m_fCaption);

		UINT uFormat = DT_CENTER | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS;

		if (m_pInfo->grfFlagsOriginal & SHNF_TITLETIME)
		{
			WCHAR szTitle[256];
			WCHAR szTime[50];
			::GetTimeFormat(LOCALE_USER_DEFAULT, TIME_NOSECONDS, NULL, NULL, szTime, 12);
			wsprintf(szTitle, L"%s | %s", szTime, m_pInfo->nd.pszTitle);
			rcHead.left += m_imgCalendar.GetWidth();
			dc.DrawText(szTitle, -1, &rcHead, uFormat);

			// draw icon calendar
			WCHAR szMonth[50];
			WCHAR szDay[50];
			::GetDateFormat(LOCALE_USER_DEFAULT, 0, NULL, L"MMM", szMonth, 50);
			::GetDateFormat(LOCALE_USER_DEFAULT, 0, NULL, L"d", szDay, 50);

			m_imgCalendar.Draw(dc);

			RECT rcCal;
			SetRect(&rcCal, 0, 0, m_imgCalendar.GetWidth(), 10 * m_scaleFactor);
			CFont oldCalFont = dc.SelectFont(m_fCalendar);
			dc.DrawText(szMonth, -1, &rcCal, DT_CENTER | DT_BOTTOM | DT_SINGLELINE | DT_END_ELLIPSIS);
			dc.SelectFont(oldCalFont);

			SetRect(&rcCal, 0, 0, m_imgCalendar.GetWidth(), m_imgCalendar.GetHeight() - 5 * m_scaleFactor);
			dc.SetTextColor(RGB(0,0,0));
			dc.DrawText(szDay, -1, &rcCal, DT_CENTER | DT_BOTTOM | DT_SINGLELINE | DT_END_ELLIPSIS);
		}
		else
			dc.DrawText(m_pInfo->nd.pszTitle, -1, &rcHead, uFormat);
		dc.SelectFont(oldFont);
		
		bHandled = FALSE;
		return 0;
	}

	LRESULT OnTimer(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled)
	{
		if (wParam == IDT_TIMER_MENU_ANIMATION)
		{
			m_iStep = m_iStep / 2;
			RECT animRect; CopyRect(&animRect, &m_animRect);
			animRect.top = animRect.top + m_iStep;
			MoveWindow(&animRect, TRUE);

			if (m_iStep == 0)
			{
				KillTimer(IDT_TIMER_MENU_ANIMATION);
				m_bAnimating = FALSE;
				m_iStep = 0;
			}	

			bHandled = TRUE;
			return 0;
		}

		bHandled = FALSE;
		return 0;
	}

	LRESULT OnStartAnim(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		ModifyShape();
		StartAnimation();
		return 0;
	}
	
	void ModifyTopShape()
	{
		int nUsedRects = 3 * m_scaleFactor;
		m_heightHrgnTop = nUsedRects;

		if (m_hrgnTop != NULL)
		{
			DeleteObject(m_hrgnTop);
			m_hrgnTop = NULL;
		}

		RECT rcParent; GetParent().GetClientRect(&rcParent);
		int iWidth = rcParent.right - 2 * BORDER_WIDTH * m_scaleFactor;

		RGNDATA *pRgnData;
		RECT *pRect;		
		DWORD dwTemp = sizeof(RGNDATAHEADER) + nUsedRects * sizeof(RECT);
		pRgnData = (RGNDATA*)malloc(dwTemp);	
		pRgnData->rdh.dwSize = sizeof(RGNDATAHEADER);
		pRgnData->rdh.iType = RDH_RECTANGLES;
		pRgnData->rdh.nCount = nUsedRects;
		pRgnData->rdh.nRgnSize = 0;
		pRgnData->rdh.rcBound.left = pRgnData->rdh.rcBound.top = 0;
		pRgnData->rdh.rcBound.right = iWidth;
		pRgnData->rdh.rcBound.bottom = nUsedRects;		


		if (nUsedRects == 3)
		{
			// 1st
			pRect = &(((RECT *)&pRgnData->Buffer)[0]);
			pRect->top = 0;
			pRect->bottom = 1;
			pRect->left = 2;
			pRect->right = iWidth - 2;

			// 2nd
			pRect = &(((RECT *)&pRgnData->Buffer)[1]);
			pRect->top = 1;
			pRect->bottom = 2;
			pRect->left = 1;
			pRect->right = iWidth - 1;

			// 3rd
			pRect = &(((RECT *)&pRgnData->Buffer)[2]);
			pRect->top = 2;
			pRect->bottom = 3;
			pRect->left = 0;
			pRect->right = iWidth;
		}
		else if (nUsedRects == 6)
		{
			// 1st
			pRect = &(((RECT *)&pRgnData->Buffer)[0]);
			pRect->top = 0;
			pRect->bottom = 1;
			pRect->left = 5;
			pRect->right = iWidth - 5;

			// 2nd
			pRect = &(((RECT *)&pRgnData->Buffer)[1]);
			pRect->top = 1;
			pRect->bottom = 2;
			pRect->left = 3;
			pRect->right = iWidth - 3;

			// 3rd
			pRect = &(((RECT *)&pRgnData->Buffer)[2]);
			pRect->top = 2;
			pRect->bottom = 3;
			pRect->left = 2;
			pRect->right = iWidth - 2;

			// 4th
			pRect = &(((RECT *)&pRgnData->Buffer)[3]);
			pRect->top = 3;
			pRect->bottom = 4;
			pRect->left = 1;
			pRect->right = iWidth - 1;

			// 5th
			pRect = &(((RECT *)&pRgnData->Buffer)[4]);
			pRect->top = 4;
			pRect->bottom = 5;
			pRect->left = 1;
			pRect->right = iWidth - 1;

			// 6th
			pRect = &(((RECT *)&pRgnData->Buffer)[5]);
			pRect->top = 5;
			pRect->bottom = 6;
			pRect->left = 0;
			pRect->right = iWidth;

		}

		m_hrgnTop = ExtCreateRegion(NULL, dwTemp, pRgnData);
		free(pRgnData);

	}

	void AddStyle()
	{
	}

	void SubmitForm()
	{
		// must be implemented in a derived class
		ATLASSERT(FALSE);
	}


public:
	RECT m_animRect; 
	BOOL m_bAnimating;
	int m_iStep;
	int m_scaleFactor;
	int m_height;
	BOOL m_bMouseIsDown;
	HRGN m_hrgnTop;
	int m_heightHrgnTop;
	int m_iBodyHeight;
	NOTIFICATIONINFO* m_pInfo;
	COLORREF m_clCaptionText;
	CFontHandle m_fCaption;
	CFontHandle m_fCalendar;
	CxImage m_imgCalendar;
	CxImage m_imgHeader;
	BOOL m_bEnableAnimation;

	void ModifyShape()
	{
		m_height = m_iBodyHeight + m_imgHeader.GetHeight(); 

		RECT rcParent; GetParent().GetClientRect(&rcParent);
		int iWidth = rcParent.right - 2 * BORDER_WIDTH * m_scaleFactor;

		HRGN hrgnBottom = ::CreateRectRgn(0, 0, iWidth, m_height - m_heightHrgnTop);
		::OffsetRgn(hrgnBottom, 0, m_heightHrgnTop);

		CombineRgn(hrgnBottom, m_hrgnTop, hrgnBottom, RGN_OR);

		SetWindowRgn(hrgnBottom, FALSE);
	}

	void StartAnimation()
	{
		int m_itemHeight = 5 * m_scaleFactor;
		// window position
		m_bAnimating = (m_bEnableAnimation) ? TRUE : FALSE;
		m_iStep = (m_bEnableAnimation) ? m_itemHeight / 3 : 0;

		RECT rcParent; GetParent().GetClientRect(&rcParent);

		m_animRect.left = BORDER_WIDTH * m_scaleFactor;
		m_animRect.right = rcParent.right - BORDER_WIDTH * m_scaleFactor;
		m_animRect.top = rcParent.bottom - m_height;
		m_animRect.bottom = rcParent.bottom;


		RECT animRect; CopyRect(&animRect, &m_animRect);
		animRect.top = animRect.top + m_iStep;
		MoveWindow(&animRect, TRUE);

		if (m_bEnableAnimation)
			SetTimer(IDT_TIMER_MENU_ANIMATION, TMR_MENU_ANIMATION);
	}



};

class CHTMLNotifWindow : public CNotifWindow<CHTMLNotifWindow>
{
public:
	DECLARE_WND_CLASS(NULL)

	typedef CNotifWindow<CHTMLNotifWindow> Super;

	CHtmlCtrl m_html;

	BOOL SetNotification(LPNOTIFICATIONINFO pData)
	{
		Super::SetNotification(pData);

		m_html.Clear();
		m_html.AddStyle(CUSTOM_CSS);

		RECT rcParent; GetParent().GetClientRect(&rcParent);
		int iWidth = rcParent.right - 2 * BORDER_WIDTH * m_scaleFactor;
		m_html.ResizeClient(iWidth, 0);

		m_html.SendMessage(WM_SETTEXT, 0, (LPARAM)(LPCTSTR)_T(""));
		m_html.AddHTML(m_pInfo->nd.pszHTML);
		m_html.EndOfSource();

		m_iBodyHeight = m_html.GetLayoutHeight() + 25 * m_scaleFactor; 

		return TRUE;
	}

	void SubmitForm()
	{
		IDispatch* pDisp = NULL;
		m_html.GetDocumentDispatch(&pDisp);

		IPIEHTMLDocument *pHTMLDocument = NULL; 
		HRESULT hr = pDisp->QueryInterface(IID_IPIEHTMLDocument, (void**)&pHTMLDocument);

		if (FAILED(hr)) { 
			if (hr == E_NOINTERFACE) 
				LOG(L"Interface doesn't exist\n"); 
			if (hr == E_NOTIMPL) 
				LOG(L"Queryinterface not implemented\n"); 
			return;
		}

		IPIEHTMLElementCollection *pElementCollection = NULL; 
		if ( pHTMLDocument->get_forms ( &pElementCollection ) == S_OK ) 
		{
			if (pElementCollection != NULL)
			{
				long celem = 0;
			
				if ( pElementCollection->get_length( &celem ) == S_OK )
				{
					for ( long i = 0; i < celem; i++ )
					{
						VARIANT vtIndex;
						vtIndex.vt = VT_I4;
						vtIndex.lVal = i;


						IDispatch* pItem = NULL;
						if( pElementCollection->item( vtIndex, vtIndex, (IDispatch**)&pItem ) == S_OK )
						{
							IPIEHTMLFormElement* form = NULL;
							if( pItem->QueryInterface(__uuidof(IPIEHTMLFormElement), (void**)&form ) == S_OK )
							{
								form->put_method((BSTR)L"get");
								hr = form->submit();
								LOG(L"Tutto OK\n");
							}
						}
					}
				}
			}
		}
	}


	BEGIN_MSG_MAP(CHTMLNotifWindow)
		MESSAGE_HANDLER(WM_CREATE, OnCreate)
		MESSAGE_HANDLER(WM_SIZE, OnSize)
		MESSAGE_HANDLER(WM_PAINT, OnPaint)
		MESSAGE_HANDLER(UM_STARTANIM, OnStartAnim)
		CHAIN_MSG_MAP(Super)
	END_MSG_MAP()

	LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)
	{
		// html control
		InitHTMLControl(ModuleHelper::GetModuleInstance());

		m_html.Create(m_hWnd, rcDefault, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS, IDC_HTMLVIEW);
		m_html.SetFocus();
		m_html.SendMessage(WM_SETTEXT, 0, (LPARAM)(LPCTSTR)_T(""));

		bHandled = FALSE;
		return 0;
	}

	LRESULT OnSize(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled)
	{
		RECT rc; GetClientRect(&rc);
		rc.top += m_imgHeader.GetHeight();
		m_html.SetWindowPos(0, &rc, SWP_NOZORDER);

		bHandled = FALSE;
		return 0;
	}

};<file_sep>/FingerSuite/Common/atlceactivesync.h
#if !defined(AFX_ATLCEACTIVESYNC_H__20040110_01FC_0634_DA35_0080AD509054__INCLUDED_)
#define AFX_ATLCEACTIVESYNC_H__20040110_01FC_0634_DA35_0080AD509054__INCLUDED_

/////////////////////////////////////////////////////////////////////////////
// atlceactivesync - Active Sync for Win CE implementation
//
// Written by <NAME> (<EMAIL>)
// Copyright (c) 2004 <NAME>.
//
// This code may be used in compiled form in any way you desire. This
// file may be redistributed by any means PROVIDING it is 
// not sold for profit without the authors written consent, and 
// providing that this notice and the authors name is included. 
//
// This file is provided "as is" with no expressed or implied warranty.
// The author accepts no liability if it causes any damage to you or your
// computer whatsoever. It's free, so don't hassle me about it.
//
// Beware of bugs.
//

#pragma once

#include <cesync.h>


/////////////////////////////////////////////////////////////////////////////
// Macros

#ifndef _ASSERTE
   #define _ASSERTE(x)
#endif


#define PROP_TAG(ulPropType, ulPropID)    ((((ULONG)(ulPropID))<<16)|((ULONG)(ulPropType)))
#define PROP_TYPE(ulPropTag)              (((ULONG)(ulPropTag))&0x0000FFFF)


#define GET_STREAM_WORD(x)      x = * (LPWORD) pData; pData += sizeof(WORD); cbData -= sizeof(WORD)
#define GET_STREAM_DWORD(x)     x = * (LPDWORD) pData; pData += sizeof(DWORD); cbData -= sizeof(DWORD)
#define GET_STREAM_BYTES(x, n)  memcpy(x, pData, n); pData += (n); cbData -= (n)

#define PUT_STREAM_WORD(x)      * (LPWORD) pData = x; pData += sizeof(WORD); cbData += sizeof(WORD)
#define PUT_STREAM_DWORD(x)     * (LPDWORD) pData = x; pData += sizeof(DWORD); cbData += sizeof(DWORD)
#define PUT_STREAM_BYTES(x, n)  memcpy(pData, x, n); pData += (n); cbData += (n)


/////////////////////////////////////////////////////////////////////////////
// Debug Helpers

#ifdef DEBUG

inline void _cdecl Log(LPCWSTR lpszFormat, ...)
{
   // Format text
   va_list args;
   va_start(args, lpszFormat);
   WCHAR szBuffer[256] = { 0 };
   int nBuf = _vsnwprintf(szBuffer, (sizeof(szBuffer) / sizeof(WCHAR)) - 1, lpszFormat, args);
   va_end(args);
   // A truely crappy semaphore
   static volatile bool s_bLocked = false;
   DWORD dwTick = ::GetTickCount();
   while( s_bLocked && ::GetTickCount() - dwTick < 1000UL ) ::Sleep(0L);
   s_bLocked = true;
   // Append to file
   HANDLE hFile = ::CreateFile(L"\\sync.log", GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
   if( hFile != INVALID_HANDLE_VALUE ) {
      ::SetFilePointer(hFile, 0, NULL, FILE_END);
      DWORD dwWritten = 0;
      ::WriteFile(hFile, szBuffer, nBuf * sizeof(WCHAR), &dwWritten, NULL);
      ::FlushFileBuffers(hFile);
      ::CloseHandle(hFile);
   }
   s_bLocked = false;
}

#else

inline void _cdecl LogStub(LPCWSTR lpszFormat, ...) { };
#define Log 1 ? (void)0 : LogStub

#endif

/////////////////////////////////////////////////////////////////////////////
// Base Folder

class CReplFolder
{
public:
   CReplFolder(){};
   virtual ~CReplFolder() { };

public:
   virtual LPCWSTR GetName() const = 0;
   virtual BOOL Initialize(IReplObjHandler** ppObjHandler, UINT uPartnerBit) = 0;
   virtual BOOL UnInitialize() = 0;
   virtual HRESULT FindObjects(PFINDOBJINFO pFind) = 0;
   virtual BOOL ObjectNotify(POBJNOTIFY pObjNotify) = 0;
   virtual BOOL GetObjTypeInfo(POBJTYPEINFO pInfo) = 0;
   virtual BOOL SyncData(PSDREQUEST psd) = 0;
};


/////////////////////////////////////////////////////////////////////////////
// Store Implementation

class CReplStore
{
public:
   enum { MAX_FOLDERS = 10 };

   CReplFolder* m_aFolders[MAX_FOLDERS];
   int m_nFolders;

   CReplStore() : m_nFolders(0)
   {
   }
   virtual ~CReplStore()
   {
      for( int i = 0; i < m_nFolders; i++ ) delete m_aFolders[i];
   }

   virtual BOOL InitObjType(LPWSTR lpszObjType, IReplObjHandler **ppObjHandler, UINT uPartnerBit)
   {
      Log(L"CReplStore::InitObjType (%s)\r\n", lpszObjType == NULL ? L"<null>" : lpszObjType);
      if( lpszObjType == NULL ) 
      {
         // Uninitialize
         BOOL fRet = TRUE;
         for( int i = 0; i < m_nFolders; i++ ) {
            if( !m_aFolders[i]->UnInitialize() ) fRet = FALSE;
         }
         return fRet;
      }
      else 
      {
         // Initialize
         *ppObjHandler = NULL;
         CReplFolder* pFolder = GetFolderByName(lpszObjType);
         if( pFolder ) return pFolder->Initialize(ppObjHandler, uPartnerBit);
         return FALSE;
      }
   }
   virtual HRESULT FindObjects(PFINDOBJINFO pFind)
   {
      Log(L"CReplStore::FindObjects\r\n");
      if( pFind == NULL ) return E_INVALIDARG;
      CReplFolder* pFolder = GetFolderByName(pFind->szObjType);
      if( pFolder ) return pFolder->FindObjects(pFind);
      return E_INVALIDARG;
   }
   virtual BOOL ObjectNotify(POBJNOTIFY pNotify)
   {
      Log(L"CReplStore::ObjectNotify\r\n");
      if( pNotify == NULL ) return FALSE;
      CReplFolder* pFolder = GetFolderByName(pNotify->szObjType);
      if( pFolder ) return pFolder->ObjectNotify(pNotify);
      return FALSE;
   }
   virtual BOOL GetObjTypeInfo(POBJTYPEINFO pInfo)
   {
      Log(L"CReplStore::GetObjTypeInfo\r\n");
      if( pInfo == NULL ) return FALSE;
      CReplFolder* pFolder = GetFolderByName(pInfo->szObjType);
      if( pFolder ) return pFolder->GetObjTypeInfo(pInfo);
      return FALSE;
   }
   virtual BOOL ReportStatus(LPWSTR lpszObjType, UINT uCode, UINT uParam)
   {
      Log(L"CReplStore::ReportStatus %04X\r\n", uCode);
      return TRUE;
   }
   virtual BOOL SyncData(PSDREQUEST psd)
   {
      Log(L"CReplStore::SyncData\r\n");
      CReplFolder* pFolder = GetFolderByName(psd->szObjType);
      if( pFolder ) return pFolder->SyncData(psd);
      return FALSE;
   }

   CReplFolder* GetFolderByName(LPWSTR wszName) const
   {
      for( int i = 0; i < m_nFolders; i++ ) {
         if( wcscmp(m_aFolders[i]->GetName(), wszName) == 0 ) return m_aFolders[i];
      }
      return NULL;
   }
};


/////////////////////////////////////////////////////////////////////////////
// IReplObjHandler

template< class T >
class IReplObjHandlerImpl : public IReplObjHandler
{
public:
   enum { MAX_DATASIZE = 6000 };

   IReplObjHandlerImpl() : m_cRef(1)
   {
   }

   // IUnknown

   STDMETHODIMP_(ULONG) AddRef()
   {
      return ::InterlockedIncrement(&m_cRef);
   }
   STDMETHODIMP_(ULONG) Release()
   {
      ULONG urc;
      if( (urc = ::InterlockedDecrement(&m_cRef)) == 0 ) delete this;
      return urc;
   }
   STDMETHODIMP QueryInterface(REFIID iid, LPVOID* ppvObj)
   {      
      *ppvObj = NULL;
      return E_NOINTERFACE;
   }

   // IReplObjHandler

   STDMETHODIMP Setup(PREPLSETUP pSetup)
   {
      Log(L"IReplObjHandlerImpl::Setup\r\n");
      if( pSetup->fRead ) {
         m_pReadSetup = pSetup; 
         m_dwReadPos = 0;
         m_pData = (LPBYTE) ::LocalAlloc(LMEM_FIXED, MAX_DATASIZE);
         if( m_pData == NULL ) return E_OUTOFMEMORY;
      }
      else {
         m_pWriteSetup = pSetup;
         m_dwWritePos = 0;
      }
      return NOERROR;
   }
   STDMETHODIMP Reset(PREPLSETUP pSetup)
   {
      Log(L"IReplObjHandlerImpl::Reset\r\n");
      if( pSetup->fRead ) ::LocalFree(m_pData);
      return NOERROR;
   }

   LONG m_cRef;
   PREPLSETUP m_pReadSetup;
   PREPLSETUP m_pWriteSetup;
   DWORD m_dwReadPos;
   DWORD m_dwWritePos;
   LPBYTE m_pData;
};


/////////////////////////////////////////////////////////////////////////////
// CCeDatabase

class CCeDatabase
{
public:
   CEGUID m_Guid;
   CEOID m_Oid;
   HANDLE m_Db;
   bool m_bManaged;

   CCeDatabase() : m_Db(INVALID_HANDLE_VALUE), m_bManaged(false)
   {
      CREATE_INVALIDGUID(&m_Guid);
   }
   CCeDatabase(CEGUID Guid) : m_Db(INVALID_HANDLE_VALUE), m_Guid(Guid), m_bManaged(false)
   {
   }
   ~CCeDatabase()
   {
      Close();
      if( m_bManaged ) Unmount();
   }
   BOOL Create(LPWSTR pstrVolume, UINT uFlags = CREATE_ALWAYS)
   {
      _ASSERTE(pstrVolume);
      _ASSERTE(CHECK_INVALIDGUID(&m_Guid));
      return ::CeMountDBVol(&m_Guid, pstrVolume, uFlags);
   }
   BOOL MountObjectStore()
   {
      _ASSERTE(CHECK_INVALIDGUID(&m_Guid));
      CREATE_SYSTEMGUID(&m_Guid);
      m_bManaged = true;
      return TRUE;
   }
   BOOL Mount(LPWSTR pstrVolume)
   {
      _ASSERTE(pstrVolume);
      _ASSERTE(CHECK_INVALIDGUID(&m_Guid));
      BOOL bRes = ::CeMountDBVol(&m_Guid, pstrVolume, OPEN_EXISTING);
      m_bManaged = true;
      return bRes;
   }
   void Unmount()
   {
      if( CHECK_INVALIDGUID(&m_Guid) ) return;
      if( !CHECK_SYSTEMGUID(&m_Guid) ) ::CeUnmountDBVol(&m_Guid);
      CREATE_INVALIDGUID(&m_Guid);
      m_bManaged = false;
   }
   CEOID FindDatabase(LPWSTR pstrFile, DWORD dwType)
   {
      _ASSERTE(!CHECK_INVALIDGUID(&m_Guid));
      // Validate we're mounted
      if( CHECK_INVALIDGUID(&m_Guid) ) return 0;
      // First search for the database
      CEOID oid = 0;
      HANDLE hFind = ::CeFindFirstDatabaseEx(&m_Guid, dwType);
      if( hFind != INVALID_HANDLE_VALUE ) {
         while( true ) {
            CEOIDINFO oidInfo;
            oid = ::CeFindNextDatabase(hFind);   
            if( oid == 0
                || (::CeOidGetInfoEx(&m_Guid, oid, &oidInfo) 
                    && oidInfo.wObjType == OBJTYPE_DATABASE 
                    && wcscmp(oidInfo.infDatabase.szDbaseName, pstrFile) == 0) ) 
            {
               break;
            }
         }
         ::CloseHandle(hFind);
      }
      return oid;
   }
   BOOL Open(LPWSTR pstrFile, DWORD dwType, BOOL bCreateIfNotExists = TRUE)
   {
      _ASSERTE(!CHECK_INVALIDGUID(&m_Guid));
      // Validate we're mounted
      if( CHECK_INVALIDGUID(&m_Guid) ) return FALSE;
      // First search for the database
      CEOID oid = FindDatabase(pstrFile, dwType);
      // If not found, create a new database
      if( bCreateIfNotExists && oid == 0 ) {
         CEDBASEINFO info = { 0 };
         info.dwFlags = CEDB_VALIDNAME | CEDB_VALIDTYPE;
         ::lstrcpy(info.szDbaseName, pstrFile);
         info.dwDbaseType = dwType;
         oid = ::CeCreateDatabaseEx(&m_Guid, &info);
      }
      // Finally open the database
      if( oid ) {
         m_Db = ::CeOpenDatabaseEx(&m_Guid, &oid, NULL, NULL, 0, NULL);
         m_Oid = oid;
      }
      return m_Oid != 0 && m_Db != INVALID_HANDLE_VALUE;
   }
   BOOL Open(LPWSTR pstrFile, DWORD dwType, CEPROPID Prop, DWORD dwFlags = CEDB_AUTOINCREMENT, CENOTIFYREQUEST* pReq = NULL)
   {
      _ASSERTE(!CHECK_INVALIDGUID(&m_Guid));
      // Validate we're mounted
      if( CHECK_INVALIDGUID(&m_Guid) ) return FALSE;
      // First search for the database
      CEOID oid = FindDatabase(pstrFile, dwType);
      // Open the database
      if( oid ) {
         m_Db = ::CeOpenDatabaseEx(&m_Guid, &oid, NULL, Prop, dwFlags, pReq);
         m_Oid = oid;
      }
      return m_Oid != 0 && m_Db != INVALID_HANDLE_VALUE;
   }
   void Close()
   {
      if( m_Db != INVALID_HANDLE_VALUE ) {
         ::CloseHandle(m_Db);
         m_Db = INVALID_HANDLE_VALUE;
      }
   }
   BOOL DeleteDatabase()
   {
      _ASSERTE(!IsOpen());
      _ASSERTE(!CHECK_INVALIDGUID(&m_Guid));
      // Use Open() before calling this!
      Close();
      return ::CeDeleteDatabaseEx(&m_Guid, m_Oid);
   }
   BOOL IsOpen() const
   {
      return m_Db != INVALID_HANDLE_VALUE;
   }
   BOOL IsMounted() const
   {
      return CHECK_INVALIDGUID(&m_Guid);
   }
   BOOL IsVolume(CEGUID* pData, UINT cbData) const
   {
      // Compare data with GUID structure
      if( CHECK_SYSTEMGUID(&m_Guid) ) return pData == NULL || (cbData == sizeof(CEGUID) && CHECK_SYSTEMGUID(pData));
      return cbData == sizeof(CEGUID) && memcmp(pData, &m_Guid, sizeof(CEGUID)) == 0;
   }

   BOOL GetInfoEx(CEOIDINFO* oidInfo)
   {
      _ASSERTE(IsOpen());
      return ::CeOidGetInfoEx(&m_Guid, m_Oid, oidInfo);
   }

   DWORD Seek(DWORD dwType, DWORD dwValue, DWORD* pdwIndex = NULL)
   {
      _ASSERTE(IsOpen());
      DWORD dwTempIndex = 0;
      if( pdwIndex == NULL ) pdwIndex = &dwTempIndex;
      return ::CeSeekDatabase(m_Db, dwType, dwValue, pdwIndex);
   }
   DWORD SeekMatch(DWORD dwType, const CEPROPVAL* pValue, DWORD* pdwIndex = NULL)
   {
      return Seek(dwType, (DWORD) pValue, pdwIndex);
   }
   DWORD SeekOid(CEOID oid, DWORD* pdwIndex = NULL)
   {
      return Seek(CEDB_SEEK_CEOID, (DWORD) oid, pdwIndex);
   }
   DWORD SeekNext(DWORD* pdwIndex = NULL)
   {
      return Seek(CEDB_SEEK_CURRENT, 1, pdwIndex);
   }
   DWORD ReadRecord(LPBYTE* lplpBuffer, LPDWORD lpcbBuffer, LPWORD lpcPropID, CEPROPID* rgPropID = NULL, DWORD dwFlags = CEDB_ALLOWREALLOC)
   {
      _ASSERTE(IsOpen());
      _ASSERTE(lplpBuffer);
      _ASSERTE(lpcbBuffer);
      return ::CeReadRecordProps(m_Db, dwFlags, lpcPropID, rgPropID, lplpBuffer, lpcbBuffer);
   }
   DWORD ReadRecord(CEPROPVAL** lplpBuffer, LPDWORD lpcbBuffer, LPWORD lpcPropID, CEPROPID* rgPropID = NULL, DWORD dwFlags = CEDB_ALLOWREALLOC)
   {
      _ASSERTE(IsOpen());
      _ASSERTE(lplpBuffer);
      _ASSERTE(lpcbBuffer);
      return ::CeReadRecordProps(m_Db, dwFlags, lpcPropID, rgPropID, (LPBYTE*) lplpBuffer, lpcbBuffer);
   }
   DWORD UpdateRecord(CEOID oid, WORD cPropID, CEPROPVAL* rgPropVal)
   {
      _ASSERTE(IsOpen());
      _ASSERTE(rgPropVal);
      return ::CeWriteRecordProps(m_Db, oid, cPropID, rgPropVal);
   }
   DWORD CreateRecord(WORD cPropID, CEPROPVAL* rgPropVal)
   {
      _ASSERTE(IsOpen());
      _ASSERTE(rgPropVal);
      return ::CeWriteRecordProps(m_Db, 0, cPropID, rgPropVal);
   }
   BOOL DeleteRecord(CEOID oid)
   {
      _ASSERTE(IsOpen());
      return ::CeDeleteRecord(m_Db, oid);
   }

   operator HANDLE() const
   {
      return m_Db;
   }
   operator CEGUID() const
   {
      return m_Guid;
   }
   operator CEOID() const
   {
      return m_Oid;
   }
};


#endif // !defined(AFX_ATLCEACTIVESYNC_H__20040110_01FC_0634_DA35_0080AD509054__INCLUDED_)
<file_sep>/7-Zip/CPP/7zip/Archive/Udf/UdfRegister.cpp
// UdfRegister.cpp

#include "StdAfx.h"

#include "../../Common/RegisterArc.h"

#include "UdfHandler.h"
static IInArchive *CreateArc() { return new NArchive::NUdf::CHandler; }

static CArcInfo g_ArcInfo =
  { L"Udf", L"iso", 0, 0xE0, { 0, 'N', 'S', 'R', '0' }, 5, false, CreateArc, 0 };

REGISTER_ARC(Udf)
<file_sep>/FingerSuite/Common/fngrbtn.h
#ifndef __FNGRBTN_H__
#define __FNGRBTN_H__

#pragma once

#ifndef __cplusplus
	#error ATL requires C++ compilation (use a .cpp suffix)
#endif

#ifndef __ATLAPP_H__
	#error fngrscrl.h requires atlapp.h to be included first
#endif

#ifndef __ATLWIN_H__
	#error fngrscrl.h requires atlwin.h to be included first
#endif

#ifndef __CXIMAGE_H
	#error fngrscrl.h requires ximage.h to be included first
#endif


#define FNGRBTN_CLASS		  L"FingerBtn"
//#define NS_FINGERBTN         (WS_CHILD | WS_CLIPSIBLINGS)

#define  FNGRBTN_TYPE_TEXT    0x00
#define  FNGRBTN_TYPE_STATIC  0x01
#define  FNGRBTN_TYPE_DYNAMIC 0x02
#define  FNGRBTN_TYPE_ICON    0x04

typedef enum enumState
{
	NOT_DEFINED = -1,
	NORMAL = 0,
	PUSHED = 3,
	FOCUSED = 6
} STATE;



inline void AddDynamicSet(CxImage arrImages[], STATE state, LPCTSTR szFileNameLeft, LPCTSTR szFileNameCenter, LPCTSTR szFileNameRight)
{
	arrImages[state].Load(szFileNameLeft, CXIMAGE_FORMAT_PNG);
	arrImages[state + 1].Load(szFileNameCenter, CXIMAGE_FORMAT_PNG);
	arrImages[state + 2].Load(szFileNameRight, CXIMAGE_FORMAT_PNG);
}

inline void AddStaticSet(CxImage arrImages[], STATE state, LPCTSTR szFileName)
{
	arrImages[state].Load(szFileName, CXIMAGE_FORMAT_PNG);
}



class CFingerButton : public CWindowImpl<CFingerButton>
{
public:
	DECLARE_WND_CLASS(NULL)

	typedef CWindowImpl<CFingerButton>	Super;
	
	// Constructor/Destructor
	CFingerButton() : 
			m_fNormal(1), 
			m_fPressed(0),
			m_fFocused(0)
	{
	}

	~CFingerButton()
	{
	}

	// Creation
	HWND Create(HWND hParentWnd, DWORD type, BOOL bVisible, COLORREF clBkg, COLORREF clBtnText, COLORREF clBtnSelText,
						LPCTSTR szText, HFONT fBtn, UINT nID)
	{
		SetText(szText);
		m_type = type;
		m_fNormal = 1; 
		m_fPressed = 0;
		m_fFocused = 0;
		m_clBkg = clBkg;
		m_clBtnText = clBtnText;
		m_clBtnSelText = clBtnSelText;
		m_fBtn = fBtn;
		m_icon = NULL;
		return Super::Create(hParentWnd, rcDefault, FNGRBTN_CLASS, (bVisible ? WS_VISIBLE  : 0), 0, nID);
	};

	HWND Create(HWND hParentWnd, DWORD type, BOOL bVisible, COLORREF clBkg, int iconSize, UINT nID)
	{
		m_type = type;
		m_fNormal = 1; 
		m_fPressed = 0;
		m_fFocused = 0;
		m_icon = NULL;
		m_iconSize = iconSize;
		m_clBkg = clBkg;
		return Super::Create(hParentWnd, rcDefault, FNGRBTN_CLASS, (bVisible ? WS_VISIBLE  : 0), 0, nID);
	};

	/*
	void MoveUpDownWindow(int offset)
	{
		
		RECT rc; GetWindowRect(&rc);
		SetWindowPos(NULL, rc.left, rc.top + offset, 0, 0, SWP_NOZORDER | SWP_NOSIZE);

		LOG(L"rc.top = %d offset = %d\n", rc.top, offset);
	}
	*/

	void SetArrayImageSet(CxImage* arrImages)
	{
		m_arrImages = arrImages;
	}

	// Overrideables
	void DoPaint(CDCHandle dc)
	{
		RECT rc; GetClientRect(&rc);


		// paint background
		dc.FillSolidRect(&rc, m_clBkg);


		STATE state = NOT_DEFINED;
		COLORREF clText = 0;
		if (m_fNormal)
		{
			state = NORMAL;
			clText = m_clBtnText;
		}
		if (m_fPressed)
		{
			state = PUSHED;
			clText = m_clBtnSelText;
		}
		if (m_fFocused)
			state = FOCUSED;

		if (m_type & FNGRBTN_TYPE_DYNAMIC)
		{
			int x = m_arrImages[0].GetWidth();
			int y = m_arrImages[0].GetHeight();

			int iWidth =  (rc.right - rc.left) - 2 * x;

			m_arrImages[state].Draw(dc, 0, 0);
			m_arrImages[state + 1].Draw(dc, x, 0, iWidth, y);
			m_arrImages[state + 2].Draw(dc, x + iWidth, 0);
		}

		if (m_type & FNGRBTN_TYPE_STATIC)
		{
			m_arrImages[state].Draw(dc);
		}

		// draw icon
		if ((m_type & FNGRBTN_TYPE_ICON) && (m_icon != NULL))
		{
			int px = (rc.right - m_iconSize) / 2;
			int py = (rc.bottom - m_iconSize) / 2;

			m_icon.DrawIconEx(dc, px, py, m_iconSize, m_iconSize);
		}

		// draw icon 2
		if ((m_type & FNGRBTN_TYPE_ICON) && (m_icon2 != NULL))
		{
			int px = (rc.right - m_iconSize) / 2;
			int py = (rc.bottom - m_iconSize) / 2;

			m_icon2.DrawIconEx(dc, px, py, m_iconSize, m_iconSize);
		}

		if (!(m_type & FNGRBTN_TYPE_ICON))
		{
			CFont oldFont = dc.SelectFont(m_fBtn);
			dc.SetBkMode(TRANSPARENT);
			dc.SetTextColor(clText);
			dc.DrawText(m_text, -1, &rc, DT_CENTER | DT_VCENTER | DT_SINGLELINE); 
			dc.SelectFont(oldFont);
		}

	}

	void SetText(LPCTSTR szText)
	{
		if (szText != NULL)
			lstrcpy(m_text, szText);
	}

	void SetIcon (HICON hIcon)
	{
		m_icon = hIcon;

		Invalidate();
		UpdateWindow();
	}

	void SetIcon2 (HICON hIcon)
	{
		m_icon2 = hIcon;

		//Invalidate();
		//UpdateWindow();
	}

// Message map and handlers
	BEGIN_MSG_MAP(CBitmapButton)
		MESSAGE_HANDLER(WM_CREATE, OnCreate)
		MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
		MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBackground)
		MESSAGE_HANDLER(WM_PAINT, OnPaint)
		MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown)
		MESSAGE_HANDLER(WM_LBUTTONUP, OnLButtonUp)
		MESSAGE_HANDLER(WM_CAPTURECHANGED, OnCaptureChanged)
		MESSAGE_HANDLER(WM_MOUSEMOVE, OnMouseMove)
	END_MSG_MAP()

	LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)
	{
		return 0;
	}

	LRESULT OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)
	{
		bHandled = FALSE;
		return 1;
	}

	LRESULT OnEraseBackground(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		return 1;   // no background needed
	}

	LRESULT OnPaint(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		if(wParam != NULL)
		{
			DoPaint((HDC)wParam);
		}
		else
		{
			CBufferedPaintDC dc(m_hWnd, 0);
			DoPaint(dc.m_hDC);
		}
		return 0;
	}

	LRESULT OnLButtonDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/)
	{
		SetCapture();
		if(::GetCapture() == m_hWnd)
		{
			m_fPressed = 1;
			m_fNormal = 0;
			Invalidate();
			UpdateWindow();
		}
		return 0;
	}

	LRESULT OnLButtonUp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/)
	{
		if(::GetCapture() == m_hWnd)
		{
			if(m_fPressed == 1)
				::SendMessage(GetParent(), WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(), BN_CLICKED), (LPARAM)m_hWnd);
			::ReleaseCapture();
		}
		return 0;
	}

	LRESULT OnCaptureChanged(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)
	{
		if(m_fPressed == 1)
		{
			m_fPressed = 0;
			m_fNormal = 1;
			Invalidate();
			UpdateWindow();
		}
		bHandled = FALSE;
		return 1;
	}

	LRESULT OnMouseMove(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled)
	{
		if(::GetCapture() == m_hWnd)
		{
			POINT ptCursor = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
			ClientToScreen(&ptCursor);
			RECT rect = { 0 };
			GetWindowRect(&rect);
			unsigned int uPressed = ::PtInRect(&rect, ptCursor) ? 1 : 0;
			if(m_fPressed != uPressed)
			{
				m_fPressed = uPressed;
				m_fNormal = 1;
				Invalidate();
				UpdateWindow();
			}
		}
		return 1;
	}

public:
	CxImage* m_arrImages;

protected:
	DWORD m_type;

	// Internal states
	unsigned m_fNormal:1;
	unsigned m_fPressed:1;
	unsigned m_fFocused:1;

	COLORREF m_clBtnText;
	COLORREF m_clBtnSelText;
	COLORREF m_clBkg;

	WCHAR m_text[32];
	CFontHandle m_fBtn;

	CIconHandle m_icon;
	CIconHandle m_icon2;
	int m_iconSize;

};

#endif // __FNGRBTN_H__<file_sep>/7-Zip/CPP/7zip/Archive/Tar/TarOut.cpp
// TarOut.cpp

#include "StdAfx.h"

#include "Common/IntToString.h"

#include "../../Common/StreamUtils.h"

#include "TarOut.h"

namespace NArchive {
namespace NTar {

HRESULT COutArchive::WriteBytes(const void *buffer, UInt32 size)
{
  return WriteStream(m_Stream, buffer, size);
}

void COutArchive::Create(ISequentialOutStream *outStream)
{
  m_Stream = outStream;
}

static AString MakeOctalString(UInt64 value)
{
  char s[32];
  ConvertUInt64ToString(value, s, 8);
  return AString(s) + ' ';
}

static void MyStrNCpy(char *dest, const char *src, int size)
{
  for (int i = 0; i < size; i++)
  {
    char c = src[i];
    dest[i] = c;
    if (c == 0)
      break;
  }
}

static bool MakeOctalString8(char *s, UInt32 value)
{
  AString tempString = MakeOctalString(value);

  const int kMaxSize = 8;
  if (tempString.Length() >= kMaxSize)
    return false;
  int numSpaces = kMaxSize - (tempString.Length() + 1);
  for(int i = 0; i < numSpaces; i++)
    s[i] = ' ';
  MyStringCopy(s + numSpaces, (const char *)tempString);
  return true;
}

static bool MakeOctalString12(char *s, UInt64 value)
{
  AString tempString  = MakeOctalString(value);
  const int kMaxSize = 12;
  if (tempString.Length() > kMaxSize)
    return false;
  int numSpaces = kMaxSize - tempString.Length();
  for(int i = 0; i < numSpaces; i++)
    s[i] = ' ';
  memmove(s + numSpaces, (const char *)tempString, tempString.Length());
  return true;
}

static bool CopyString(char *dest, const AString &src, int maxSize)
{
  if (src.Length() >= maxSize)
    return false;
  MyStringCopy(dest, (const char *)src);
  return true;
}

#define RETURN_IF_NOT_TRUE(x) { if (!(x)) return E_FAIL; }

HRESULT COutArchive::WriteHeaderReal(const CItem &item)
{
  char record[NFileHeader::kRecordSize];
  char *cur = record;
  int i;
  for (i = 0; i < NFileHeader::kRecordSize; i++)
    record[i] = 0;

  // RETURN_IF_NOT_TRUE(CopyString(header.Name, item.Name, NFileHeader::kNameSize));
  if (item.Name.Length() > NFileHeader::kNameSize)
    return E_FAIL;
  MyStrNCpy(cur, item.Name, NFileHeader::kNameSize);
  cur += NFileHeader::kNameSize;

  RETURN_IF_NOT_TRUE(MakeOctalString8(cur, item.Mode));
  cur += 8;
  RETURN_IF_NOT_TRUE(MakeOctalString8(cur, item.UID));
  cur += 8;
  RETURN_IF_NOT_TRUE(MakeOctalString8(cur, item.GID));
  cur += 8;

  RETURN_IF_NOT_TRUE(MakeOctalString12(cur, item.Size));
  cur += 12;
  RETURN_IF_NOT_TRUE(MakeOctalString12(cur, item.MTime));
  cur += 12;
  
  memmove(cur, NFileHeader::kCheckSumBlanks, 8);
  cur += 8;

  *cur++ = item.LinkFlag;

  RETURN_IF_NOT_TRUE(CopyString(cur, item.LinkName, NFileHeader::kNameSize));
  cur += NFileHeader::kNameSize;

  memmove(cur, item.Magic, 8);
  cur += 8;

  RETURN_IF_NOT_TRUE(CopyString(cur, item.User, NFileHeader::kUserNameSize));
  cur += NFileHeader::kUserNameSize;
  RETURN_IF_NOT_TRUE(CopyString(cur, item.Group, NFileHeader::kGroupNameSize));
  cur += NFileHeader::kGroupNameSize;


  if (item.DeviceMajorDefined)
    RETURN_IF_NOT_TRUE(MakeOctalString8(cur, item.DeviceMajor));
  cur += 8;

  if (item.DeviceMinorDefined)
    RETURN_IF_NOT_TRUE(MakeOctalString8(cur, item.DeviceMinor));
  cur += 8;


  UInt32 checkSumReal = 0;
  for(i = 0; i < NFileHeader::kRecordSize; i++)
    checkSumReal += Byte(record[i]);

  RETURN_IF_NOT_TRUE(MakeOctalString8(record + 148, checkSumReal));

  return WriteBytes(record, NFileHeader::kRecordSize);
}

HRESULT COutArchive::WriteHeader(const CItem &item)
{
  int nameSize = item.Name.Length();
  if (nameSize < NFileHeader::kNameSize)
    return WriteHeaderReal(item);

  CItem modifiedItem = item;
  int nameStreamSize = nameSize + 1;
  modifiedItem.Size = nameStreamSize;
  modifiedItem.LinkFlag = 'L';
  modifiedItem.Name = NFileHeader::kLongLink;
  modifiedItem.LinkName.Empty();
  RINOK(WriteHeaderReal(modifiedItem));
  RINOK(WriteBytes(item.Name, nameStreamSize));
  RINOK(FillDataResidual(nameStreamSize));

  modifiedItem = item;
  modifiedItem.Name = item.Name.Left(NFileHeader::kNameSize - 1);
  return WriteHeaderReal(modifiedItem);
}

HRESULT COutArchive::FillDataResidual(UInt64 dataSize)
{
  UInt32 lastRecordSize = UInt32(dataSize & (NFileHeader::kRecordSize - 1));
  if (lastRecordSize == 0)
    return S_OK;
  UInt32 residualSize = NFileHeader::kRecordSize - lastRecordSize;
  Byte residualBytes[NFileHeader::kRecordSize];
  for (UInt32 i = 0; i < residualSize; i++)
    residualBytes[i] = 0;
  return WriteBytes(residualBytes, residualSize);
}

HRESULT COutArchive::WriteFinishHeader()
{
  Byte record[NFileHeader::kRecordSize];
  int i;
  for (i = 0; i < NFileHeader::kRecordSize; i++)
    record[i] = 0;
  for (i = 0; i < 2; i++)
  {
    RINOK(WriteBytes(record, NFileHeader::kRecordSize));
  }
  return S_OK;
}

}}
<file_sep>/FingerSuite/FingerMsgBox/skins/default/settings_fingermsgbox.ini
[general]
;CenterCaption=true

[colors]
BkgColor=255 255 255
CaptionTextColor=255 255 255
TextColor=0 0 0 
ButtonTextColor=0 0 0
SelButtonTextColor=255 255 255
LineColor=160 160 160


; Font settings.
; Options (separated by comma)
; 1. font weight: must be one in "regular", "italic", "bold", "bold italic"
; 2. font height in points
; 3. font face name
[fonts]
TextFont=regular,9p,
CaptionFont=bold,10p,
ButtonFont=bold,10p,


; Sound settings
; specify full path of wav file to be played
[sounds]
DefaultSound=\Windows\Alarm2.wav
ErrorSound=
WarningSound=
InfoSound=
QuestionSound=
<file_sep>/SQLCEHelper/Source/BlobStream.cpp

#include "stdafx.h"
#include "../Include/BlobStream.h"


CBlobStream::CBlobStream()
:	m_pBuffer	(NULL),
	m_nLength	(0),
	m_iPosRead	(0),
	m_iPosWrite	(0),
	m_nRef		(0),
	m_dbStatus	(DBSTATUS_S_OK)
{
	AddRef();
}


CBlobStream::~CBlobStream()
{
	Clear();
}


// CBlobStream::Clear
//
//		Clears the buffer
//
void CBlobStream::Clear()
{
	CoTaskMemFree(m_pBuffer);
	m_pBuffer = NULL;

	m_nLength	= 0;
	m_iPosRead	= 0;
	m_iPosWrite	= 0;
	m_dbStatus	= DBSTATUS_S_OK;
}


ULONG CBlobStream::AddRef()
{
	return ++m_nRef;
}


// CBlobStream::Release
//
//		Deletes the object when the reference count reaches zero
//
ULONG CBlobStream::Release()
{
	if(m_nRef)
	{
		--m_nRef;
		if(m_nRef == 0)
			delete this;
	}
	return m_nRef;
}


HRESULT CBlobStream::QueryInterface(REFIID riid, void** ppv)
{
	*ppv = NULL;

	if(riid == IID_IUnknown)
		*ppv = this;

	if(riid == IID_ISequentialStream)
		*ppv = this;

	if(*ppv)
	{
		((IUnknown*) *ppv)->AddRef();

		return S_OK;
	}

	return E_NOINTERFACE;
}


// CBlobStream::Read
//
//		Reads data from the BLOB stream
//
HRESULT CBlobStream::Read(void *pv, ULONG cb, ULONG* pcbRead)
{
	//
	// Check parameters.
	//
	if(pcbRead)
		*pcbRead = 0;

	if(!pv)
		return STG_E_INVALIDPOINTER;

	if(0 == cb)
		return S_OK; 

	//
	// Calculate bytes left and bytes to read.
	//
	ULONG cBytesLeft = m_nLength - m_iPosRead;
	ULONG cBytesRead = cb > cBytesLeft ? cBytesLeft : cb;

	//
	// Return bytes read to caller.
	//
	if(pcbRead)
		*pcbRead = cBytesRead;

	//
	// If no more bytes to retrive return S_FALSE.
	//
	if(0 == cBytesLeft)
		return S_OK;

	//
	// Copy to users buffer the number of bytes requested or remaining
	//
	memcpy(pv, (void*)(m_pBuffer + m_iPosRead), cBytesRead);
	m_iPosRead += cBytesRead;

	if(cb != cBytesRead)
		return S_FALSE; 

	return S_OK;
}


// CBlobStream::Write
//
//		Writes data to the BLOB stream
//
HRESULT CBlobStream::Write(const void *pv, ULONG cb, ULONG* pcbWritten)
{
	//
	// Check parameters.
	//
	if(!pv)
		return STG_E_INVALIDPOINTER;

	if(pcbWritten)
		*pcbWritten = 0;

	if(0 == cb)
		return S_OK;

	//
	// Enlarge the current buffer.
	//
	m_nLength += cb;

	//
	// Grow internal buffer to new size.
	//
	m_pBuffer = (BYTE*)CoTaskMemRealloc(m_pBuffer, m_nLength);

	//
	// Check for out of memory situation.
	//
	if(NULL == m_pBuffer) 
	{
		Clear();
		return E_OUTOFMEMORY;
	}

	//
	// Copy callers memory to internal bufffer and update write position.
	//
	memcpy((void*)(m_pBuffer + m_iPosWrite), pv, cb );
	m_iPosWrite += cb;

	//
	// Return bytes written to caller.
	//
	if(pcbWritten)
		*pcbWritten = cb;

	return S_OK;
}


// CBlobStream::WriteFromStream
//
//		Writes data to the blob stream from an open IStream
//
HRESULT CBlobStream::WriteFromStream(IStream *pStream, ULONG cb, ULONG *pcbWritten)
{
	HRESULT	hr;

	//
	// Check parameters.
	//
	if(!pStream)
		return STG_E_INVALIDPOINTER;

	if(pcbWritten)
		*pcbWritten = 0;

	if(0 == cb)
		return S_OK;

	//
	// Enlarge the current buffer.
	//
	m_nLength += cb;

	//
	// Grow internal buffer to new size.
	//
	m_pBuffer = (BYTE*)CoTaskMemRealloc(m_pBuffer, m_nLength);

	//
	// Check for out of memory situation.
	//
	if(NULL == m_pBuffer) 
	{
		Clear();
		return E_OUTOFMEMORY;
	}

	hr = pStream->Read((void*)(m_pBuffer + m_iPosWrite), cb, pcbWritten);
	if(SUCCEEDED(hr))
		m_iPosWrite += cb;

	return hr;
}


// CBlobStream::WriteFromStream
//
//		Writes data to the blob stream from an open ISequentialStream
//
HRESULT CBlobStream::WriteFromStream(ISequentialStream *pStream, ULONG cb, ULONG *pcbWritten)
{
	HRESULT	hr;

	//
	// Check parameters.
	//
	if(!pStream)
		return STG_E_INVALIDPOINTER;

	if(pcbWritten)
		*pcbWritten = 0;

	if(0 == cb)
		return S_OK;

	//
	// Enlarge the current buffer.
	//
	m_nLength += cb;

	//
	// Grow internal buffer to new size.
	//
	m_pBuffer = (BYTE*)CoTaskMemRealloc(m_pBuffer, m_nLength);

	//
	// Check for out of memory situation.
	//
	if(NULL == m_pBuffer) 
	{
		Clear();
		return E_OUTOFMEMORY;
	}

	hr = pStream->Read((void*)(m_pBuffer + m_iPosWrite), cb, pcbWritten);
	if(SUCCEEDED(hr))
		m_iPosWrite += cb;

	return hr;
}
<file_sep>/FingerSuite/FingerMenuRES/resource.h
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by FingerMenuRES.rc
//
#define IDS_MENU_ADDTOEXCLUSIONLIST     130
#define IDS_MENU_SHOWORIGINAL           131
#define IDS_MENU_ABOUT                  132
#define IDS_MENU_EXIT                   133
#define IDS_SOFTKEY_CLOSE               134
#define IDS_MENU_ADDTOWNDEXCLUSIONLIST  136
#define IDS_SOFTKEY_BACK                205

// Next default values for new objects
// 
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE        102
#define _APS_NEXT_COMMAND_VALUE         40001
#define _APS_NEXT_CONTROL_VALUE         1001
#define _APS_NEXT_SYMED_VALUE           101
#endif
#endif
<file_sep>/FingerSuite/Common/fngrsplash.h
#pragma once

#include <atlmisc.h>


class CSplashWindow :
	public CWindowImpl<CSplashWindow, CWindow, CWinTraits<WS_POPUP | WS_VISIBLE, WS_EX_TOOLWINDOW> >
{

public:
	CSplashWindow(HWND hParent = NULL, UINT nIconId = IDR_MAINFRAME, LPCWCHAR lpwszMessage = NULL)
		: m_hParent(hParent)
	{
		// Create the window rect (we will centre the window later)
		int sx = ::GetSystemMetrics(SM_CXSCREEN);
		int sy = ::GetSystemMetrics(SM_CYSCREEN);


		// Create the window

		int ix = 0;
		int iy = 0;
		if (nIconId != NULL)
		{
			m_hIcon = AtlLoadIconImage(nIconId);

			ICONINFO ii;
			BITMAP bmp;
			GetIconInfo(m_hIcon, &ii);
			GetObject(ii.hbmColor, sizeof(BITMAP), &bmp);

			ix = bmp.bmWidth;
			iy = bmp.bmHeight;

		}



		if (lpwszMessage != NULL)
			StringCchCopy(m_szText, MAX_PATH, lpwszMessage);

		CRect rect(0, 0, (int)(sx * 0.8), iy);
		
		if (!Create(NULL, rect))
		{
			ATLTRACE(_T("Failed to create splash window\n"));
			return;
		}
		UpdateWindow();
	}

	void Dismiss()
	{
		PostMessage(WM_CLOSE);
	}

	virtual void OnFinalMessage(HWND /*hWnd*/)
	{
		delete this;
	}

	BEGIN_MSG_MAP(CSplashWindow)
		MESSAGE_HANDLER(WM_CREATE, OnCreate)
		MESSAGE_HANDLER(WM_PAINT, OnPaint)
		MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBkgnd)
	END_MSG_MAP()

	LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		CenterWindow(m_hParent);

		return 0;
	}

	LRESULT OnPaint(UINT /*uMsg*/, WPARAM /*wParam*/, 
		LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		CPaintDC dc(m_hWnd);
		RECT rc; GetClientRect(&rc);

		dc.FillSolidRect(&rc, RGB(226, 226, 226));

		dc.DrawIcon(0, 0, m_hIcon);

		RECT rcText;
		SetRect(&rcText, (rc.bottom - rc.top), rc.top, rc.right, rc.bottom);
		dc.SetBkMode(TRANSPARENT);
		dc.DrawText(m_szText, -1, &rcText, DT_CENTER | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS); 

		return 0;
	}

	LRESULT OnEraseBkgnd(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		// No need to paint a background

		return TRUE;
	}

private:
	HWND m_hParent;
	HICON m_hIcon;
	WCHAR m_szText[MAX_PATH];

};<file_sep>/FingerSuite/Common/atlcectrls.h

#ifndef __ATLCECTRLS_H__
#define __ATLCECTRLS_H__

#pragma once

#ifndef __cplusplus
   #error ATL requires C++ compilation (use a .cpp suffix)
#endif

#ifndef __ATLCTRLS_H__
   #error atlcectrls.h requires atlctrls.h to be included first
#endif

#ifndef _WIN32_WCE
   #error atlcectrls.h compiles under Windows CE only
#endif

#if (_WIN32_WCE < 400)
   #error This file requires a newer version of the platform.
#endif

#include <htmlctrl.h>
#pragma comment(lib, "htmlview.lib")

#include <richink.h>
#pragma comment(lib, "richink.lib")

#include <inkx.h>
#pragma comment(lib, "inkx.lib")

#include <voicectl.h>
#pragma comment(lib, "voicectl.lib")

#include <doclist.h>
#pragma comment(lib, "doclist.lib")


///////////////////////////////////////////////////////////////////////////////
// Classes in this file:
//
// CHtmlCtrlT<TBase> - CHtmlCtrl
// CRichInkCtrlT<TBase> - CRichInkCtrl
// CInkXCtrlT<TBase> - CInkXCtrl
// CVoiceRecorderCtrlT<TBase> - CVoiceRecorderCtrl
// CDocListCtrlT<TBase> - CDocListCtrl
// CCapEdit<TBase> - CCapEdit
// CTTStatic<TBase> - CTTStatic
// CTTButton<TBase> - CTTButton
//

namespace WTL
{

// These are wrapper classes for the Windows CE 4.2 controls
// To implement a window based on a control, use following:
// Example: Implementing a window based on a list box
//
// class CMyHtml : CWindowImpl<CMyHtml, CHtmlCtrl>
// {
// public:
//      BEGIN_MSG_MAP(CMyHtml)
//          // put your message handler entries here
//      END_MSG_MAP()
// };


///////////////////////////////////////////////////////////////////////////////
// CHtmlCtrl

template< class TBase >
class CHtmlCtrlT : public TBase
{
public:
   // Constructors
   
   CHtmlCtrlT(HWND hWnd = NULL) : TBase(hWnd)
   { 
   }

   CHtmlCtrlT< TBase >& operator =(HWND hWnd)
   {
      m_hWnd = hWnd;
      return *this;
   }

   HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL,
         DWORD dwStyle = 0, DWORD dwExStyle = 0,
         ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL)
   {
      HWND hWnd = TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam);
      ATLASSERT(hWnd!=NULL); // Did you remember to call InitHTMLControl(hInstance) ??
      return hWnd;
   }

   // Attributes

   static LPCTSTR GetWndClassName()
   {
      return WC_HTML;
   }

   void AddStyle(LPCWSTR pszStyle)
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ::SendMessage(m_hWnd, DTM_ADDSTYLE, 0, (LPARAM) pszStyle);
   }

   void AddText(BOOL bPlainText, LPCSTR pszText)
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ::SendMessage(m_hWnd, DTM_ADDTEXT, (WPARAM) bPlainText, (LPARAM) pszText);
   }

   void AddHTML(LPCSTR pszHTML)
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ::SendMessage(m_hWnd, DTM_ADDTEXT, (WPARAM) FALSE, (LPARAM) pszHTML);
   }

   void AddText(BOOL bPlainText, LPCWSTR pszText)
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ::SendMessage(m_hWnd, DTM_ADDTEXTW, (WPARAM) bPlainText, (LPARAM) pszText);
   }

   void AddHTML(LPCWSTR pszHTML)
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ::SendMessage(m_hWnd, DTM_ADDTEXTW, (WPARAM) FALSE, (LPARAM) pszHTML);
   }

   void Anchor(LPCSTR pszAnchor)
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ::SendMessage(m_hWnd, DTM_ANCHOR, 0, (LPARAM) pszAnchor);
   }

   void Anchor(LPCWSTR pszAnchor)
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ::SendMessage(m_hWnd, DTM_ANCHORW, 0, (LPARAM) pszAnchor);
   }

   void GetBrowserDispatch(IDispatch** ppDispatch)
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ATLASSERT(ppDispatch);
      ATLASSERT(*ppDispatch==NULL);
      ::SendMessage(m_hWnd, DTM_BROWSERDISPATCH, 0, (LPARAM) ppDispatch);
   }

   void Clear()
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ::SendMessage(m_hWnd, DTM_CLEAR, 0, 0L);
   }

   void EnableClearType(BOOL bEnable = TRUE)
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ::SendMessage(m_hWnd, DTM_ENABLECLEARTYPE, 0, (LPARAM) bEnable);
   }

   void EnableContextMenu(BOOL bEnable = TRUE)
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ::SendMessage(m_hWnd, DTM_ENABLECONTEXTMENU, 0, (LPARAM) bEnable);
   }

   void EnableScripting(BOOL bEnable = TRUE)
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ::SendMessage(m_hWnd, DTM_ENABLESCRIPTING, 0, (LPARAM) bEnable);
   }

   void EnableShrink(BOOL bEnable = TRUE)
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ::SendMessage(m_hWnd, DTM_ENABLESHRINK, 0, (LPARAM) bEnable);
   }

   void EndOfSource()
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ::SendMessage(m_hWnd, DTM_ENDOFSOURCE, 0, 0L);
   }

   void ImageFail(DWORD dwCookie)
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ::SendMessage(m_hWnd, DTM_IMAGEFAIL, 0, (LPARAM) dwCookie);
   }

   int GetLayoutHeight() const
   {
      ATLASSERT(::IsWindow(m_hWnd));
      return (int) ::SendMessage(m_hWnd, DTM_LAYOUTHEIGHT, 0, 0L);
   }

   int GetLayoutWidth() const
   {
      ATLASSERT(::IsWindow(m_hWnd));
      return (int) ::SendMessage(m_hWnd, DTM_LAYOUTWIDTH, 0, 0L);
   }

   void Navigate(LPCTSTR pstrURL, UINT uFlags = 0)
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ATLASSERT(pstrURL);
      ::SendMessage(m_hWnd, DTM_NAVIGATE, (WPARAM) uFlags, (LPARAM) pstrURL);
   }

   void SelectAll()
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ::SendMessage(m_hWnd, DTM_SELECTALL, 0, 0L);
   }

   void SetImage(INLINEIMAGEINFO* pImageInfo)
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ATLASSERT(pImageInfo);
      ::SendMessage(m_hWnd, DTM_SETIMAGE, 0, (LPARAM) pImageInfo);
   }

   void ZoomLevel(int iLevel)
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ::SendMessage(m_hWnd, DTM_ZOOMLEVEL, 0, (LPARAM) iLevel);
   }
   
   void Stop()
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ::SendMessage(m_hWnd, DTM_STOP, 0, 0L);
   }

   void GetScriptDispatch(IDispatch** ppDispatch)
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ATLASSERT(ppDispatch);
      ATLASSERT(*ppDispatch==NULL);
      ::SendMessage(m_hWnd, DTM_SCRIPTDISPATCH, 0, (LPARAM) ppDispatch);
   }
};

typedef CHtmlCtrlT<ATL::CWindow> CHtmlCtrl;


///////////////////////////////////////////////////////////////////////////////
// CRichInkCtrl

template< class TBase >
class CRichInkCtrlT : public TBase
{
public:
   // Constructors
   
   CRichInkCtrlT(HWND hWnd = NULL) : TBase(hWnd)
   { 
   }

   CRichInkCtrlT< TBase >& operator =(HWND hWnd)
   {
      m_hWnd = hWnd;
      return *this;
   }

   HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL,
         DWORD dwStyle = 0, DWORD dwExStyle = 0,
         ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL)
   {
      HWND hWnd = TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam);
      ATLASSERT(hWnd!=NULL); // Did you remember to call InitRichInkDLL() ??
      return hWnd;
   }

   // Attributes

   static LPCTSTR GetWndClassName()
   {
      return WC_RICHINK;
   }

   BOOL CanPaste(UINT uFormat = 0) const
   {
      ATLASSERT(::IsWindow(m_hWnd));
      return (BOOL) ::SendMessage(m_hWnd, EM_CANPASTE, (WPARAM) uFormat, 0L);
   }

   BOOL CanRedo() const
   {
      ATLASSERT(::IsWindow(m_hWnd));
      return (BOOL) ::SendMessage(m_hWnd, EM_CANREDO, 0, 0L);
   }

   BOOL CanUndo() const
   {
      ATLASSERT(::IsWindow(m_hWnd));
      return (BOOL) ::SendMessage(m_hWnd, EM_CANUNDO, 0, 0L);
   }

   void ClearAll(BOOL bRepaint = TRUE) const
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ::SendMessage(m_hWnd, EM_CLEARALL, (WPARAM) bRepaint, 0L);
   }

   BOOL GetModify() const
   {
      ATLASSERT(::IsWindow(m_hWnd));
      return (BOOL) ::SendMessage(m_hWnd, EM_GETMODIFY, 0, 0L);
   }

   UINT GetPageStyle() const
   {
      ATLASSERT(::IsWindow(m_hWnd));
      return (UINT) ::SendMessage(m_hWnd, EM_GETPAGESTYLE, 0, 0L);
   }

   UINT GetPenMode() const
   {
      ATLASSERT(::IsWindow(m_hWnd));
      return (UINT) ::SendMessage(m_hWnd, EM_GETPENMODE, 0, 0L);
   }

   UINT GetViewStyle() const
   {
      ATLASSERT(::IsWindow(m_hWnd));
      return (UINT) ::SendMessage(m_hWnd, EM_GETVIEW, 0, 0L);
   }

   UINT GetWrapMode() const
   {
      ATLASSERT(::IsWindow(m_hWnd));
      return (UINT) ::SendMessage(m_hWnd, EM_GETWRAPMODE, 0, 0L);
   }

   UINT GetZoomPercent() const
   {
      ATLASSERT(::IsWindow(m_hWnd));
      return (UINT) ::SendMessage(m_hWnd, EM_GETZOOMPERCENT, 0, 0L);
   }

   void InsertLinks(LPWSTR lpString, int cchLength = -1)
   {
      ATLASSERT(::IsWindow(m_hWnd));
      if( cchLength == -1 ) strLength = lstrlen(lpString);
      ::SendMessage(m_hWnd, EM_INSERTLINKS, (WPARAM) cchLength, (LPARAM) lpString);
   }

   void RedoEvent()
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ::SendMessage(m_hWnd, EM_REDOEVENT, 0, 0L);
   }

   UINT SetInkLayer(UINT uLayer)
   {
      ATLASSERT(::IsWindow(m_hWnd));
      return (UINT) ::SendMessage(m_hWnd, EM_SETINKLAYER, (WPARAM) uLayer, 0L);
   }

   void SetPageStyle(UINT uStyle)
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ::SendMessage(m_hWnd, EM_SETPAGESTYLE, (WPARAM) uStyle, 0L);
   }

   void SetPenMode(UINT uMode)
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ::SendMessage(m_hWnd, EM_SETPENMODE, (WPARAM) uMode, 0L);
   }

   void SetViewStyle(UINT uStyle)
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ::SendMessage(m_hWnd, EM_SETVIEW, (WPARAM) uStyle, 0L);
   }

   void SetViewAttributes(VIEWATTRIBUTES* pAttribs)
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ATLASSERT(pAttribs);
      ::SendMessage(m_hWnd, EM_SETVIEWATTRIBUTES, 0, (LPARAM) pAttribs);
   }

   void SetWrapMode(UINT uMode)
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ::SendMessage(m_hWnd, EM_SETWRAPMODE, (WPARAM) uMode, 0L);
   }

   void SetZoomPercent(UINT uPercent)
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ::SendMessage(m_hWnd, EM_SETZOOMPERCENT, (WPARAM) uPercent, 0L);
   }

   LONG StreamIn(UINT uFormat, EDITSTREAM& es)
   {
      ATLASSERT(::IsWindow(m_hWnd));
      return (LONG) ::SendMessage(m_hWnd, EM_STREAMIN, (WPARAM) uFormat, (LPARAM) &es);
   }

   LONG StreamOut(UINT uFormat, EDITSTREAM& es)
   {
      ATLASSERT(::IsWindow(m_hWnd));
      return (LONG) ::SendMessage(m_hWnd, EM_STREAMOUT, (WPARAM) uFormat, (LPARAM) &es);
   }

   void UndoEvent()
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ::SendMessage(m_hWnd, EM_UNDOEVENT, 0, 0L);
   }

   // Standard EM_xxx messages

   DWORD GetSel() const
   {
      ATLASSERT(::IsWindow(m_hWnd));
      return (DWORD) ::SendMessage(m_hWnd, EM_GETSEL, 0, 0L);
   }

   void GetSel(int& nStartChar, int& nEndChar) const
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ::SendMessage(m_hWnd, EM_GETSEL, (WPARAM) &nStartChar, (LPARAM) &nEndChar);
   }

   void ReplaceSel(LPCTSTR lpszNewText, BOOL bCanUndo = FALSE)
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ::SendMessage(m_hWnd, EM_REPLACESEL, (WPARAM) bCanUndo, (LPARAM) lpszNewText);
   }

   void SetModify(BOOL bModified = TRUE)
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ::SendMessage(m_hWnd, EM_SETMODIFY, (WPARAM) bModified, 0L);
   }

   int GetTextLength() const
   {
      ATLASSERT(::IsWindow(m_hWnd));
      return (int) ::SendMessage(m_hWnd, WM_GETTEXTLENGTH, 0, 0L);
   }

   // Clipboard operations
   
   void Clear()
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ::SendMessage(m_hWnd, WM_CLEAR, 0, 0L);
   }

   void Copy()
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ::SendMessage(m_hWnd, WM_COPY, 0, 0L);
   }

   void Cut()
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ::SendMessage(m_hWnd, WM_CUT, 0, 0L);
   }

   void Paste()
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ::SendMessage(m_hWnd, WM_PASTE, 0, 0L);
   }
};

typedef CRichInkCtrlT<ATL::CWindow> CRichInkCtrl;


///////////////////////////////////////////////////////////////////////////////
// CInkXCtrl

template< class TBase >
class CInkXCtrlT : public TBase
{
public:
   // Constructors
   
   CInkXCtrlT(HWND hWnd = NULL) : TBase(hWnd)
   { 
   }

   CInkXCtrlT< TBase >& operator =(HWND hWnd)
   {
      m_hWnd = hWnd;
      return *this;
   }

   HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL,
         DWORD dwStyle = 0, DWORD dwExStyle = 0,
         ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL)
   {
      HWND hWnd = TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam);
      ATLASSERT(hWnd!=NULL); // Did you remember to call InitInkX() ??
      return hWnd;
   }

   // Attributes

   static LPCTSTR GetWndClassName()
   {
      return WC_INKX;
   }

   static UINT GetHotRecordingMessage()
   {
      return ::RegisterWindowMessage(szHotRecording);
   }

   void ClearAll()
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ::SendMessage(m_hWnd, IM_CLEARALL, 0, 0L);
   }

   int GetData(BYTE* lpBuffer, INT cbBuffer) const
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ATLASSERT(lpBuffer);
      return (int) ::SendMessage(m_hWnd, IM_GETDATA, (WPARAM) cbBuffer, (LPARAM) lpBuffer);
   }

   int GetDataLen() const
   {
      ATLASSERT(::IsWindow(m_hWnd));
      return (int) ::SendMessage(m_hWnd, IM_GETDATALEN, 0, 0L);
   }

   CRichInkCtrl GetRichInk() const
   {
      ATLASSERT(::IsWindow(m_hWnd));
      return (HWND) ::SendMessage(m_hWnd, IM_GETRICHINK, 0, 0L);
   }

   BOOL IsRecording() const
   {
      ATLASSERT(::IsWindow(m_hWnd));
      return (BOOL) ::SendMessage(m_hWnd, IM_RECORDING, 0, 0L);
   }

   void ReInit()
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ::SendMessage(m_hWnd, IM_REINIT, 0, 0L);
   }

   void SetData(const BYTE* lpInkData, INT cbInkData)
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ATLASSERT(lpInkData);
      ::SendMessage(m_hWnd, IM_SETDATA, (WPARAM) cbInkData, (LPARAM) lpInkData);
   }

   void VoicePlay()
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ::SendMessage(m_hWnd, IM_VOICE_PLAY, 0, 0L);
   }

   BOOL IsVoicePlaying() const
   {
      ATLASSERT(::IsWindow(m_hWnd));
      return (BOOL) ::SendMessage(m_hWnd, IM_VOICE_PLAYING, 0, 0L);
   }

   BOOL VoiceRecord()
   {
      ATLASSERT(::IsWindow(m_hWnd));
      return (BOOL) ::SendMessage(m_hWnd, IM_VOICE_RECORD, 0, 0L);
   }

   void VoiceStop()
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ::SendMessage(m_hWnd, IM_VOICE_STOP, 0, 0L);
   }

   void ShowVoiceBar(BOOL bShow = TRUE)
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ::SendMessage(m_hWnd, IM_VOICEBAR, (WPARAM) bShow, 0L);
   }
};

typedef CInkXCtrlT<ATL::CWindow> CInkXCtrl;


///////////////////////////////////////////////////////////////////////////////
// CVoiceRecorderCtrl

template< class TBase >
class CVoiceRecorderCtrlT : public TBase
{
public:
   // Constructors
   
   CVoiceRecorderCtrlT(HWND hWnd = NULL) : TBase(hWnd)
   { 
   }

   CVoiceRecorderCtrlT< TBase >& operator =(HWND hWnd)
   {
      m_hWnd = hWnd;
      return *this;
   }

   HWND Create(HWND hWndParent, const POINT pt, LPTSTR pstrFileName,
         UINT nID, DWORD dwStyle = 0)
   {
      ATLASSERT(pstrFileName);
      CM_VOICE_RECORDER cmvr = { 0 };
      cmvr.cb = sizeof(CM_VOICE_RECORDER);
      cmvr.dwStyle = dwStyle;
      cmvr.xPos = pt.x;
      cmvr.yPos = pt.y;
      cmvr.hwndParent = hWndParent;
      cmvr.id = nID;
      cmvr.lpszRecordFileName = pstrFileName;
      m_hWnd = VoiceRecorder_Create(&cmvr);
      return m_hWnd;
   }

   HWND Create(LPCM_VOICE_RECORDER pAttribs)
   {
      ATLASSERT(pAttribs);
      m_hWnd = VoiceRecorder_Create(pAttribs);
      return m_hWnd;
   }

   // Attributes

   void Record()
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ::SendMessage(m_hWnd, VRM_RECORD, 0, 0L);
   }

   void Play()
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ::SendMessage(m_hWnd, VRM_PLAY, 0, 0L);
   }

   void Stop()
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ::SendMessage(m_hWnd, VRM_STOP, 0, 0L);
   }

   void Cancel()
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ::SendMessage(m_hWnd, VRM_CANCEL, 0, 0L);
   }

   void Done()
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ::SendMessage(m_hWnd, VRM_OK, 0, 0L);
   }
};

typedef CVoiceRecorderCtrlT<ATL::CWindow> CVoiceRecorderCtrl;


///////////////////////////////////////////////////////////////////////////////
// CDocListCtrl

template< class TBase >
class CDocListCtrlT : public TBase
{
public:
   // Attributes

   DOCLISTCREATE m_dlc;
   TCHAR m_szPath[MAX_PATH];

   // Constructors
   
   CDocListCtrlT(HWND hWnd = NULL) : TBase(hWnd)
   { 
   }

   CDocListCtrlT< TBase >& operator =(HWND hWnd)
   {
      m_hWnd = hWnd;
      return *this;
   }

   HWND Create(HWND hWndParent, WORD wId, LPCTSTR pszFolder = NULL, LPCTSTR pstrFilter = NULL,
      WORD wFilterIndex = 0, DWORD dwFlags = DLF_SHOWEXTENSION)
   {
      ATLASSERT(pstrFilter); // It seems to need a filter badly!!
      ::ZeroMemory(&m_dlc, sizeof(DOCLISTCREATE));
      ::ZeroMemory(m_szPath, sizeof(m_szPath));
      if( pszFolder ) ::lstrcpyn(m_szPath, pszFolder, MAX_PATH - 1);
      m_dlc.dwStructSize = sizeof(DOCLISTCREATE);
      m_dlc.hwndParent = hWndParent;
      m_dlc.pszFolder = m_szPath;
      m_dlc.pstrFilter = pstrFilter;
      m_dlc.wFilterIndex = wFilterIndex;
      m_dlc.wId = wId;
      m_dlc.dwFlags = dwFlags;
      m_hWnd = DocList_Create(&m_dlc);
      return m_hWnd;
   }

   HWND Create(DOCLISTCREATE* pDlc)
   {
      m_dlc = *pDlc;
      m_hWnd = DocList_Create(&m_dlc);
      return m_hWnd;
   }

   // Attributes

   void DeleteSel()
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ::SendMessage(m_hWnd, DLM_DELETESEL, 0, 0L);
   }

   void DisableUpdates()
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ::SendMessage(m_hWnd, DLM_DISABLEUPDATES, 0, 0L);
   }

   void EnableUpdates()
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ::SendMessage(m_hWnd, DLM_ENABLEUPDATES, 0, 0L);
   }

   int GetFilterIndex() const
   {
      ATLASSERT(::IsWindow(m_hWnd));
      return (int) ::SendMessage(m_hWnd, DLM_GETFILTERINDEX, 0, 0L);
   }

   int GetItemCount() const
   {
      ATLASSERT(::IsWindow(m_hWnd));
      return (int) ::SendMessage(m_hWnd, DLM_GETITEMCOUNT, 0, 0L);
   }

   int GetNextItem(int iIndex, DWORD dwRelation = LVNI_ALL) const
   {
      ATLASSERT(::IsWindow(m_hWnd));
      return (int) ::SendMessage(m_hWnd, DLM_GETNEXTITEM, (WPARAM) iIndex, (LPARAM) dwRelation);
   }

   int GetFirstItem(DWORD dwRelation = LVNI_ALL) const
   {
      ATLASSERT(::IsWindow(m_hWnd));
      return (int) ::SendMessage(m_hWnd, DLM_GETNEXTITEM, (WPARAM) -1, (LPARAM) dwRelation);
   }

   BOOL GetNextWave(int* pIndex) const
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ATLASSERT(pIndex);
      return (BOOL) ::SendMessage(m_hWnd, DLM_GETNEXTWAVE, 0, (LPARAM) pIndex);
   }

   BOOL GetPrevWave(int* pIndex) const
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ATLASSERT(pIndex);
      return (BOOL) ::SendMessage(m_hWnd, DLM_GETPREVWAVE, 0, (LPARAM) pIndex);
   }

   int GetSelCount() const
   {
      ATLASSERT(::IsWindow(m_hWnd));
      return (int) ::SendMessage(m_hWnd, DLM_GETSELCOUNT, 0, 0L);
   }

   BOOL GetSelPathName(LPTSTR pstrPath, int cchMax) const
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ATLASSERT(pstrPath);
      return (BOOL) ::SendMessage(m_hWnd, DLM_GETSELPATHNAME, (WPARAM) cchMax, (LPARAM) pstrPath);
   }

   void ReceiveIR(LPCTSTR pstrPath) const
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ATLASSERT(pstrPath);
      ::SendMessage(m_hWnd, DLM_RECEIVEIR, 0, (LPARAM) pstrPath);
   }

   void Refresh()
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ::SendMessage(m_hWnd, DLM_REFRESH, 0, 0L);
   }

   BOOL RenameMoveSelectedItems()
   {
      ATLASSERT(::IsWindow(m_hWnd));
      return (BOOL) ::SendMessage(m_hWnd, DLM_RENAMEMOVE, 0, 0L);
   }

   int SelectAll()
   {
      ATLASSERT(::IsWindow(m_hWnd));
      return (int) ::SendMessage(m_hWnd, DLM_SELECTALL, 0, 0L);
   }

   HRESULT SelectItem(LPCTSTR pstrPath, BOOL bVisible = TRUE)
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ATLASSERT(pstrPath);
      return (HRESULT) ::SendMessage(m_hWnd, DLM_SELECTITEM, (WPARAM) bVisible, (LPARAM) pstrPath);
   }

   void SendEMail(LPCTSTR pstrAttachment)
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ::SendMessage(m_hWnd, DLM_SENDEMAIL, 0, (LPARAM) pstrAttachment);
   }

   void SendIR(LPCTSTR pstrPath)
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ::SendMessage(m_hWnd, DLM_SENDIR, 0, (LPARM) pstrPath);
   }

   HRESULT SetFilterIndex(int iIndex)
   {
      ATLASSERT(::IsWindow(m_hWnd));
      return (HRESULT) ::SendMessage(m_hWnd, DLM_SETFILTERINDEX, (WPARAM) iIndex, 0L);
   }

   void SetFolder(LPCTSTR pstrPath)
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ATLASSERT(pstrPath);
      ::SendMessage(m_hWnd, DLM_SETFOLDER, 0, (LPARAM) pstrPath);
   }

   BOOL SetItemState(int iIndex, const LVITEM* pItem)
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ATLASSERT(pItem);
      return (BOOL) ::SendMessage(m_hWnd, DLM_SETITEMSTATE, (WPARAM) iIndex, (LPARAM) pItem);
   }

   BOOL SetItemState(int iIndex, UINT uState, UINT uMask)
   {
      ATLASSERT(::IsWindow(m_hWnd));
      LV_ITEM lvi = { 0 };
      lvi.stateMask = uMask;
      lvi.state = uState;
      return (BOOL) ::SendMessage(m_hWnd, DLM_SETITEMSTATE, (WPARAM) iIndex, (LPARAM) pItem);
   }

   void SetOneItem(int iIndex, LPCVOID pPA)
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ::SendMessage(m_hWnd, DLM_SETONEITEM, (WPARAM) iIndex, (LPARAM) pPA);
   }

   void SetSelect(int iIndex)
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ::SendMessage(m_hWnd, DLM_SETSELECT, (WPARAM) iIndex, 0L);
   }

   void SetSelPathName(LPCTSTR pstrPath)
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ATLASSERT(pstrPath);
      ::SendMessage(m_hWnd, DLM_SETSELPATHNAME, 0, (LPARAM) pstrPath);
   }

   BOOL SetSortOrder()
   {
      ATLASSERT(::IsWindow(m_hWnd));
      return (BOOL) ::SendMessage(m_hWnd, DLM_SETSORTORDER, 0, 0L);
   }

   HRESULT Update()
   {
      ATLASSERT(::IsWindow(m_hWnd));
      return (HRESULT) ::SendMessage(m_hWnd, DLM_UPDATE, 0, 0L);
   }

   BOOL ValidateFolder()
   {
      ATLASSERT(::IsWindow(m_hWnd));
      return (BOOL) ::SendMessage(m_hWnd, DLM_VALIDATEFOLDER, 0, 0L);
   }

   // Functions

   BOOL GetFirstSelectedWaveFile(int* pIndex, LPTSTR szPath, const size_t cchPath)
   {
      ATLASSERT(::IsWindow(m_hWnd));
      return DocList_GetFirstSelectedWaveFile(m_hWnd, pIndex, szPath, cchPath);
   }

   BOOL GetNextSelectedWaveFile(int* pIndex, LPTSTR szPath, const size_t cchPath)
   {
      ATLASSERT(::IsWindow(m_hWnd));
      return DocList_GetNextSelectedWaveFile(m_hWnd, pIndex, szPath, cchPath);
   }
};

typedef CDocListCtrlT<ATL::CWindow> CDocListCtrl;


///////////////////////////////////////////////////////////////////////////////
// CCapEdit

template< class TBase >
class CCapEditT : public TBase
{
public:
   // Constructors
   
   CCapEditT(HWND hWnd = NULL) : TBase(hWnd)
   { 
   }

   CCapEditT< TBase >& operator =(HWND hWnd)
   {
      m_hWnd = hWnd;
      return *this;
   }

   HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL,
         DWORD dwStyle = 0, DWORD dwExStyle = 0,
         ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL)
   {
      HWND hWnd = TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam);
      ATLASSERT(hWnd!=NULL); // Did you remember to call SHInitExtraControls() ??
      return hWnd;
   }

   // Attributes

   static LPCTSTR GetWndClassName()
   {
      return WC_CAPEDIT;
   }
};

typedef CCapEditT<WTL::CEdit> CCapEdit;


///////////////////////////////////////////////////////////////////////////////
// CTTStatic

template< class TBase >
class CTTStaticT : public TBase
{
public:
   // Constructors
   
   CTTStaticT(HWND hWnd = NULL) : TBase(hWnd)
   { 
   }

   CTTStaticT< TBase >& operator =(HWND hWnd)
   {
      m_hWnd = hWnd;
      return *this;
   }

   HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL,
         DWORD dwStyle = 0, DWORD dwExStyle = 0,
         ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL)
   {
      HWND hWnd = TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam);
      ATLASSERT(hWnd!=NULL); // Did you remember to call SHInitExtraControls() ??
      return hWnd;
   }

   // Attributes

   static LPCTSTR GetWndClassName()
   {
      return WC_TSTATIC;
   }

   // Operations

   int SetToolTipText(LPCTSTR pstrTipText)
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ATLASSERT(pstrTipText);
      ATLASSERT(lstrlen(pstrTipText)<=253);
      LPTSTR pstr = _alloca((lstrlen(pstrTipText) + 3) * sizeof(TCHAR));
      ::lstrcpy(pstr, _T("~~"));
      ::lstrcat(pstr, pstrTipText);
      return SetWindowText(pstr);
   }
};

typedef CTTStaticT<WTL::CStatic> CTTStatic;


///////////////////////////////////////////////////////////////////////////////
// CTTButton

template< class TBase >
class CTTButtonT : public TBase
{
public:
   // Constructors
   
   CTTButtonT(HWND hWnd = NULL) : TBase(hWnd)
   { 
   }

   CTTButtonT< TBase >& operator =(HWND hWnd)
   {
      m_hWnd = hWnd;
      return *this;
   }

   HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL,
         DWORD dwStyle = 0, DWORD dwExStyle = 0,
         ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL)
   {
      HWND hWnd = TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam);
      ATLASSERT(hWnd!=NULL); // Did you remember to call SHInitExtraControls() ??
      return hWnd;
   }

   // Attributes

   static LPCTSTR GetWndClassName()
   {
      return WC_TBUTTON;
   }

   // Operations

   int SetToolTipText(LPCTSTR pstrTipText)
   {
      ATLASSERT(::IsWindow(m_hWnd));
      ATLASSERT(pstrTipText);
      ATLASSERT(lstrlen(pstrTipText)<=253);
      LPTSTR pstr = _alloca((lstrlen(pstrTipText) + 3) * sizeof(TCHAR));
      ::lstrcpy(pstr, _T("~~"));
      ::lstrcat(pstr, pstrTipText);
      return SetWindowText(pstr);
   }
};

typedef CTTButtonT<WTL::CButton> CTTButton;


}; // namespace


#endif // __ATLCECTRLS_H__
<file_sep>/7-Zip/CPP/7zip/Archive/Tar/TarHandlerOut.cpp
// TarHandlerOut.cpp

#include "StdAfx.h"

#include "Common/ComTry.h"
#include "Common/StringConvert.h"

#include "Windows/PropVariant.h"
#include "Windows/Time.h"

#include "TarHandler.h"
#include "TarUpdate.h"

using namespace NWindows;

namespace NArchive {
namespace NTar {

STDMETHODIMP CHandler::GetFileTimeType(UInt32 *type)
{
  *type = NFileTimeType::kUnix;
  return S_OK;
}

static HRESULT GetPropString(IArchiveUpdateCallback *callback, UInt32 index, PROPID propId, AString &res)
{
  NCOM::CPropVariant prop;
  RINOK(callback->GetProperty(index, propId, &prop));
  if (prop.vt == VT_BSTR)
    res = UnicodeStringToMultiByte(prop.bstrVal, CP_OEMCP);
  else if (prop.vt != VT_EMPTY)
    return E_INVALIDARG;
  return S_OK;
}

STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numItems,
    IArchiveUpdateCallback *callback)
{
  COM_TRY_BEGIN
  if ((_stream && !_isGood) || _seqStream)
    return E_NOTIMPL;
  CObjectVector<CUpdateItem> updateItems;
  for (UInt32 i = 0; i < numItems; i++)
  {
    CUpdateItem ui;
    Int32 newData;
    Int32 newProps;
    UInt32 indexInArchive;
    if (!callback)
      return E_FAIL;
    RINOK(callback->GetUpdateItemInfo(i, &newData, &newProps, &indexInArchive));
    ui.NewProps = IntToBool(newProps);
    ui.NewData = IntToBool(newData);
    ui.IndexInArchive = indexInArchive;
    ui.IndexInClient = i;

    if (IntToBool(newProps))
    {
      {
        NCOM::CPropVariant prop;
        RINOK(callback->GetProperty(i, kpidIsDir, &prop));
        if (prop.vt == VT_EMPTY)
          ui.IsDir = false;
        else if (prop.vt != VT_BOOL)
          return E_INVALIDARG;
        else
          ui.IsDir = (prop.boolVal != VARIANT_FALSE);
      }

      {
        NCOM::CPropVariant prop;
        RINOK(callback->GetProperty(i, kpidPosixAttrib, &prop));
        if (prop.vt == VT_EMPTY)
          ui.Mode = 0777 | (ui.IsDir ? 0040000 : 0100000);
        else if (prop.vt != VT_UI4)
          return E_INVALIDARG;
        else
          ui.Mode = prop.ulVal;
      }
      {
        NCOM::CPropVariant prop;
        RINOK(callback->GetProperty(i, kpidMTime, &prop));
        if (prop.vt == VT_EMPTY)
          ui.Time = 0;
        else if (prop.vt != VT_FILETIME)
          return E_INVALIDARG;
        else if (!NTime::FileTimeToUnixTime(prop.filetime, ui.Time))
          ui.Time = 0;
      }
      {
        NCOM::CPropVariant prop;
        RINOK(callback->GetProperty(i, kpidPath, &prop));
        if (prop.vt == VT_BSTR)
          ui.Name = UnicodeStringToMultiByte(NItemName::MakeLegalName(prop.bstrVal), CP_OEMCP);
        else if (prop.vt != VT_EMPTY)
          return E_INVALIDARG;
        if (ui.IsDir)
          ui.Name += '/';
      }
      RINOK(GetPropString(callback, i, kpidUser, ui.User));
      RINOK(GetPropString(callback, i, kpidGroup, ui.Group));
    }
    if (IntToBool(newData))
    {
      NCOM::CPropVariant prop;
      RINOK(callback->GetProperty(i, kpidSize, &prop));
      if (prop.vt != VT_UI8)
        return E_INVALIDARG;
      ui.Size = prop.uhVal.QuadPart;
      if (ui.Size >= ((UInt64)1 << 33))
        return E_INVALIDARG;
    }
    updateItems.Add(ui);
  }
  return UpdateArchive(_stream, outStream, _items, updateItems, callback);
  COM_TRY_END
}

}}
<file_sep>/7-Zip/CPP/7zip/Archive/Tar/TarIn.cpp
// TarIn.cpp

#include "StdAfx.h"

#include "Common/StringToInt.h"

#include "../../Common/StreamUtils.h"

#include "TarIn.h"

namespace NArchive {
namespace NTar {
 
static void MyStrNCpy(char *dest, const char *src, int size)
{
  for (int i = 0; i < size; i++)
  {
    char c = src[i];
    dest[i] = c;
    if (c == 0)
      break;
  }
}

static bool OctalToNumber(const char *srcString, int size, UInt64 &res)
{
  char sz[32];
  MyStrNCpy(sz, srcString, size);
  sz[size] = 0;
  const char *end;
  int i;
  for (i = 0; sz[i] == ' '; i++);
  res = ConvertOctStringToUInt64(sz + i, &end);
  return (*end == ' ' || *end == 0);
}

static bool OctalToNumber32(const char *srcString, int size, UInt32 &res)
{
  UInt64 res64;
  if (!OctalToNumber(srcString, size, res64))
    return false;
  res = (UInt32)res64;
  return (res64 <= 0xFFFFFFFF);
}

#define RIF(x) { if (!(x)) return S_FALSE; }

static bool IsRecordLast(const char *buf)
{
  for (int i = 0; i < NFileHeader::kRecordSize; i++)
    if (buf[i] != 0)
      return false;
  return true;
}

static void ReadString(const char *s, int size, AString &result)
{
  char temp[NFileHeader::kRecordSize + 1];
  MyStrNCpy(temp, s, size);
  temp[size] = '\0';
  result = temp;
}

static HRESULT GetNextItemReal(ISequentialInStream *stream, bool &filled, CItemEx &item, size_t &processedSize)
{
  item.LongLinkSize = 0;
  char buf[NFileHeader::kRecordSize];
  char *p = buf;

  filled = false;

  processedSize = NFileHeader::kRecordSize;
  RINOK(ReadStream(stream, buf, &processedSize));
  if (processedSize == 0 || (processedSize == NFileHeader::kRecordSize && IsRecordLast(buf)))
    return S_OK;
  if (processedSize < NFileHeader::kRecordSize)
    return S_FALSE;
  
  ReadString(p, NFileHeader::kNameSize, item.Name); p += NFileHeader::kNameSize;

  RIF(OctalToNumber32(p, 8, item.Mode)); p += 8;

  if (!OctalToNumber32(p, 8, item.UID)) item.UID = 0; p += 8;
  if (!OctalToNumber32(p, 8, item.GID)) item.GID = 0; p += 8;

  RIF(OctalToNumber(p, 12, item.Size)); p += 12;
  RIF(OctalToNumber32(p, 12, item.MTime)); p += 12;
  
  UInt32 checkSum;
  RIF(OctalToNumber32(p, 8, checkSum));
  memcpy(p, NFileHeader::kCheckSumBlanks, 8); p += 8;

  item.LinkFlag = *p++;

  ReadString(p, NFileHeader::kNameSize, item.LinkName); p += NFileHeader::kNameSize;

  memcpy(item.Magic, p, 8); p += 8;

  ReadString(p, NFileHeader::kUserNameSize, item.User); p += NFileHeader::kUserNameSize;
  ReadString(p, NFileHeader::kGroupNameSize, item.Group); p += NFileHeader::kGroupNameSize;

  item.DeviceMajorDefined = (p[0] != 0); RIF(OctalToNumber32(p, 8, item.DeviceMajor)); p += 8;
  item.DeviceMinorDefined = (p[0] != 0); RIF(OctalToNumber32(p, 8, item.DeviceMinor)); p += 8;

  AString prefix;
  ReadString(p, NFileHeader::kPrefixSize, prefix);
  p += NFileHeader::kPrefixSize;
  if (!prefix.IsEmpty() && item.IsMagic() &&
      (item.LinkFlag != 'L' /* || prefix != "00000000000" */ ))
    item.Name = prefix + AString('/') + item.Name;

  if (item.LinkFlag == NFileHeader::NLinkFlag::kLink)
    item.Size = 0;
 
  UInt32 checkSumReal = 0;
  for (int i = 0; i < NFileHeader::kRecordSize; i++)
    checkSumReal += (Byte)buf[i];
  
  if (checkSumReal != checkSum)
    return S_FALSE;

  filled = true;
  return S_OK;
}

HRESULT ReadItem(ISequentialInStream *stream, bool &filled, CItemEx &item)
{
  size_t processedSize;
  RINOK(GetNextItemReal(stream, filled, item, processedSize));
  if (!filled)
    return S_OK;
  // GNUtar extension
  if (item.LinkFlag == 'L' || // NEXT file has a long name
      item.LinkFlag == 'K') // NEXT file has a long linkname
  {
    if (item.Name.Compare(NFileHeader::kLongLink) != 0)
      if (item.Name.Compare(NFileHeader::kLongLink2) != 0)
        return S_FALSE;

    AString fullName;
    if (item.Size > (1 << 15))
      return S_FALSE;
    int packSize = (int)item.GetPackSize();
    char *buffer = fullName.GetBuffer(packSize + 1);

    RINOK(ReadStream_FALSE(stream, buffer, packSize));
    processedSize += packSize;
    buffer[item.Size] = '\0';
    fullName.ReleaseBuffer();

    UInt64 headerPosition = item.HeaderPosition;
    if (item.LinkFlag == 'L')
    {
      size_t processedSize2;
      RINOK(GetNextItemReal(stream, filled, item, processedSize2));
      item.LongLinkSize = (unsigned)processedSize;
    }
    else
    {
      item.LongLinkSize = (unsigned)processedSize - NFileHeader::kRecordSize;
      item.Size = 0;
    }
    item.Name = fullName;
    item.HeaderPosition = headerPosition;
  }
  else if (item.LinkFlag == 'g' || item.LinkFlag == 'x' || item.LinkFlag == 'X')
  {
    // pax Extended Header
    return S_OK;
  }
  else if (item.LinkFlag == NFileHeader::NLinkFlag::kDumpDir)
  {
    // GNU Extensions to the Archive Format
    return S_OK;
  }
  else if (item.LinkFlag > '7' || (item.LinkFlag < '0' && item.LinkFlag != 0))
    return S_FALSE;
  return S_OK;
}

}}
<file_sep>/SQLCEHelper/Source/Index.cpp

#include "stdafx.h"

using namespace OLEDBCLI;


//-------------------------------------------------------------------------
//
//	CIndex - manipulates the table index schema
//
//-------------------------------------------------------------------------


// CIndex::CIndex
//
//		Default constructor
//
CIndex::CIndex()
:	m_bUnique		(false),
	m_bPrimary		(false),
	m_bConstraint	(false)
{
}


CIndex::CIndex(LPCTSTR pszIndexName, bool bUnique, bool bPrimary)
:	m_strName		(pszIndexName),
	m_bUnique		(bUnique),
	m_bPrimary		(bPrimary),
	m_bConstraint	(false)
{
}


// CIndex::CIndex
//
//		Initialize a CIndex from an OLE DB constraint description.
//		This constructor is used for UNIQUE constraints.
//
CIndex::CIndex(DBCONSTRAINTDESC* pConstraintDesc)
:	m_bUnique		(true),
	m_bPrimary		(false),
	m_bConstraint	(false)
{
	ULONG	i;

	ATLASSERT(pConstraintDesc != NULL);

	m_strName		= pConstraintDesc->pConstraintID->uName.pwszName;
	m_bConstraint	= pConstraintDesc->ConstraintType == DBCONSTRAINTTYPE_UNIQUE;
	m_bPrimary		= pConstraintDesc->ConstraintType == DBCONSTRAINTTYPE_PRIMARYKEY;

	for(i = 0; i < pConstraintDesc->cColumns; ++i)
		AddColumn(pConstraintDesc->rgColumnList[i].uName.pwszName, DB_COLLATION_ASC, i + 1);
}


CIndex::~CIndex()
{
	size_t i, n = m_columns.GetCount();

	for(i = 0; i < n; ++i)
		delete m_columns[i];
}


// CIndex::AddColumn
//
//		Adds a new index column to the list
//
void CIndex::AddColumn(LPCTSTR pszColumnName, short nCollation, ULONG nOrdinal)
{
	CIndexColumn* pIndexColumn = new CIndexColumn(pszColumnName, nCollation, nOrdinal);

	if(pIndexColumn != NULL)
		m_columns.Add(pIndexColumn);
}


// CIndex::FindColumn
//
//		Finds an index column given its name.
//		Returns the zero-based index of the column or -1 if not found.
//
int CIndex::FindColumn(LPCTSTR pszColumnName)
{
	int i, n = int(m_columns.GetCount());

	for(i = 0; i < n; ++i)
	{
		if(wcsicmp(pszColumnName, m_columns[i]->GetName()) == 0)
			return i;
	}
	return -1;
}
<file_sep>/7-Zip/CPP/7zip/Archive/Nsis/NsisDecode.cpp
// NsisDecode.cpp

#include "StdAfx.h"

#include "NsisDecode.h"

#include "../../Common/StreamUtils.h"

#include "../../Common/MethodId.h"
#include "../../Common/CreateCoder.h"

namespace NArchive {
namespace NNsis {

static const CMethodId k_Copy    = 0x0;
static const CMethodId k_Deflate = 0x040901;
static const CMethodId k_BZip2   = 0x040902;
static const CMethodId k_LZMA    = 0x030101;
static const CMethodId k_BCJ_X86 = 0x03030103;

HRESULT CDecoder::Init(
    DECL_EXTERNAL_CODECS_LOC_VARS
    IInStream *inStream, NMethodType::EEnum method, bool thereIsFilterFlag, bool &useFilter)
{
  useFilter = false;
  CObjectVector< CMyComPtr<ISequentialInStream> > inStreams;

  if (_decoderInStream)
    if (method != _method)
      Release();
  _method = method;
  if (!_codecInStream)
  {
    CMethodId methodID;
    switch (method)
    {
      case NMethodType::kCopy: methodID = k_Copy; break;
      case NMethodType::kDeflate: methodID = k_Deflate; break;
      case NMethodType::kBZip2: methodID = k_BZip2; break;
      case NMethodType::kLZMA: methodID = k_LZMA; break;
      default: return E_NOTIMPL;
    }
    CMyComPtr<ICompressCoder> coder;
    RINOK(CreateCoder(
        EXTERNAL_CODECS_LOC_VARS
        methodID, coder, false));
    if (!coder)
      return E_NOTIMPL;
    coder.QueryInterface(IID_ISequentialInStream, &_codecInStream);
    if (!_codecInStream)
      return E_NOTIMPL;
  }

  if (thereIsFilterFlag)
  {
    UInt32 processedSize;
    BYTE flag;
    RINOK(inStream->Read(&flag, 1, &processedSize));
    if (processedSize != 1)
      return E_FAIL;
    if (flag > 1)
      return E_NOTIMPL;
    useFilter = (flag != 0);
  }
  
  if (useFilter)
  {
    if (!_filterInStream)
    {
      CMyComPtr<ICompressCoder> coder;
      RINOK(CreateCoder(
          EXTERNAL_CODECS_LOC_VARS
          k_BCJ_X86, coder, false));
      if (!coder)
        return E_NOTIMPL;
      coder.QueryInterface(IID_ISequentialInStream, &_filterInStream);
      if (!_filterInStream)
        return E_NOTIMPL;
    }
    CMyComPtr<ICompressSetInStream> setInStream;
    _filterInStream.QueryInterface(IID_ICompressSetInStream, &setInStream);
    if (!setInStream)
      return E_NOTIMPL;
    RINOK(setInStream->SetInStream(_codecInStream));
    _decoderInStream = _filterInStream;
  }
  else
    _decoderInStream = _codecInStream;

  if (method == NMethodType::kLZMA)
  {
    CMyComPtr<ICompressSetDecoderProperties2> setDecoderProperties;
    _codecInStream.QueryInterface(IID_ICompressSetDecoderProperties2, &setDecoderProperties);
    if (setDecoderProperties)
    {
      static const UInt32 kPropertiesSize = 5;
      BYTE properties[kPropertiesSize];
      UInt32 processedSize;
      RINOK(inStream->Read(properties, kPropertiesSize, &processedSize));
      if (processedSize != kPropertiesSize)
        return E_FAIL;
      RINOK(setDecoderProperties->SetDecoderProperties2((const Byte *)properties, kPropertiesSize));
    }
  }

  {
    CMyComPtr<ICompressSetInStream> setInStream;
    _codecInStream.QueryInterface(IID_ICompressSetInStream, &setInStream);
    if (!setInStream)
      return E_NOTIMPL;
    RINOK(setInStream->SetInStream(inStream));
  }

  {
    CMyComPtr<ICompressSetOutStreamSize> setOutStreamSize;
    _codecInStream.QueryInterface(IID_ICompressSetOutStreamSize, &setOutStreamSize);
    if (!setOutStreamSize)
      return E_NOTIMPL;
    RINOK(setOutStreamSize->SetOutStreamSize(NULL));
  }

  if (useFilter)
  {
    /*
    CMyComPtr<ICompressSetOutStreamSize> setOutStreamSize;
    _filterInStream.QueryInterface(IID_ICompressSetOutStreamSize, &setOutStreamSize);
    if (!setOutStreamSize)
      return E_NOTIMPL;
    RINOK(setOutStreamSize->SetOutStreamSize(NULL));
    */
  }

  return S_OK;
}

HRESULT CDecoder::Read(void *data, size_t *processedSize)
{
  return ReadStream(_decoderInStream, data, processedSize);;
}

}}
<file_sep>/SQLCEHelper/Source/DbPropSet.cpp

#include "stdafx.h"

using namespace OLEDBCLI;


CDbPropSet::CDbPropSet(GUID guid)
{
	guidPropertySet	= guid;
	cProperties		= 0;
	rgProperties	= NULL;
}


CDbPropSet::~CDbPropSet()
{
	Clear();
}


void CDbPropSet::Clear()
{
	ULONG	i;

	for(i = 0; i < cProperties; ++i)
		VariantClear(&rgProperties[i].vValue);

	cProperties = 0;
	CoTaskMemFree(rgProperties);
	rgProperties = NULL;
}


bool CDbPropSet::AddProperty(const CDbProp &prop)
{
	DBPROP*	pProps = (DBPROP*)CoTaskMemRealloc(rgProperties, (cProperties + 1) * sizeof(DBPROP));

	if(pProps != NULL)
	{
		prop.CopyTo(pProps + cProperties);
		rgProperties = pProps;
		++cProperties;
		return true;
	}
	return false;
}


bool CDbPropSet::AddProperty(DBPROPID id, int propVal)
{
	CDbProp prop;

	prop.dwPropertyID	= id;
	prop.dwOptions		= DBPROPOPTIONS_REQUIRED;
	prop.dwStatus		= DBPROPSTATUS_OK;
	prop.colid			= DB_NULLID;
	prop.vValue.vt		= VT_I4;
	prop.vValue.intVal	= propVal;

	return AddProperty(prop);
}


bool CDbPropSet::AddProperty(DBPROPID id, bool propVal)
{
	CDbProp prop;

	prop.dwPropertyID	= id;
	prop.dwOptions		= DBPROPOPTIONS_REQUIRED;
	prop.dwStatus		= DBPROPSTATUS_OK;
	prop.colid			= DB_NULLID;
	prop.vValue.vt		= VT_BOOL;
	prop.vValue.boolVal	= propVal ? VARIANT_TRUE : VARIANT_FALSE;

	return AddProperty(prop);
}


bool CDbPropSet::AddProperty(DBPROPID id, LPCTSTR propVal)
{
	CDbProp prop;

	prop.dwPropertyID	= id;
	prop.dwOptions		= DBPROPOPTIONS_REQUIRED;
	prop.dwStatus		= DBPROPSTATUS_OK;
	prop.colid			= DB_NULLID;
	prop.vValue.vt		= VT_BSTR;
	prop.vValue.bstrVal	= SysAllocString(propVal);

	if(prop.vValue.bstrVal == NULL)
		return false;

	return AddProperty(prop);
}
<file_sep>/FBReaderJ/src/org/parser/txt/TxtParser.java
package org.parser.txt;

import java.io.InputStream;

import org.geometerplus.zlibrary.core.txt.ZLTxtReader;

import android.util.Log;

public final class TxtParser {
	static {
		System.loadLibrary("TxtParser");		
	}
	protected String strFilePath;
	protected ZLTxtReader txtReader;
	///////////////////////////////////////////////////////////////////
	private static native void Parser(TxtParser parser, String strPath);
	/////////////////////////////////////////////////////////////////////
	public TxtParser(ZLTxtReader txtReader, String strPath) {
		strFilePath = new String(strPath);
		this.txtReader = txtReader;
	}		
	public void Check(int nLen) {
		Parser(this, new String("123"));
	}	
	public void doIt() {
		if (strFilePath != null) {
			Parser(this, strFilePath);
		}		
	}
	public void characterDataHandler(String strContent) {
		Log.d("TEXT Reader:", strContent);
		//byte[] bContent = tag.getBytes();
		// addByteData(bContent, 0, bContent.length);
		txtReader.characterDataHandler(new String(strContent));
	}

	public void startElementHandler() {
		// startNewParagraph();
		Log.d("TEXT Reader:", "startElementHandler");
		txtReader.startElementHandler();
	}

	public void endElementHandler() {
		// endParagraph();
		Log.d("TEXT Reader:", "endElementHandler");
		txtReader.endElementHandler();

	}
}
<file_sep>/FingerSuite/FingerMenuCTRL/Commons.h
#pragma once

#define MENU_ITEM_TEXT_SIZE  1024


typedef struct tagMENUINFO
{
	MENUITEMINFO mii;
	WCHAR text[MENU_ITEM_TEXT_SIZE];
	BOOL bFollowSeparator;
	HMENU hOwnerMenu;
	HWND hDestWnd;
	DWORD fPosition;
} MENUINFO, *LPMENUINFO;

typedef struct tagMENU
{
	HMENU hMenu;
	BOOL bInitMenuSent;
	HMENU hPrevMenu;
} MENU, *LPMENU;
<file_sep>/SQLCEHelper/Source/SchemaRowset.cpp

#include "stdafx.h"

using namespace OLEDBCLI;


CSchemaRowset::CSchemaRowset(CSession& session)
:	m_pSchemaRowset(NULL)
{
	IUnknown* pUnknown = session;

	pUnknown->QueryInterface(IID_IDBSchemaRowset, (void**)&m_pSchemaRowset);
}

CSchemaRowset::~CSchemaRowset()
{
	if(m_pSchemaRowset != NULL)
	{
		m_pSchemaRowset->Release();
		m_pSchemaRowset = NULL;
	}
}


HRESULT	CSchemaRowset::Open(REFGUID rguidSchema, ULONG cRestrictions, const VARIANT rgRestrictions[], CRowset &rowset)
{
	HRESULT		hr;
	IRowset*	pRowset	= NULL;

	ATLASSERT(m_pSchemaRowset != NULL);

	hr = m_pSchemaRowset->GetRowset(NULL, rguidSchema, cRestrictions, rgRestrictions, IID_IRowset, 0, NULL, (IUnknown**)&pRowset);
	if(FAILED(hr))
		return hr;

	hr = rowset.Open(pRowset);
	return hr;
}


// CTablesRowset::Open
//
//		Opens the tables rowset
//
HRESULT CTablesRowset::Open(LPCTSTR pszCatalog, LPCTSTR pszSchema, LPCTSTR pszTable, LPCTSTR pszType, CRowset &rowset)
{
	HRESULT		hr;
	CComVariant	varParam[4];

	if(pszCatalog != NULL)
		varParam[0] = pszCatalog;
	if(pszSchema != NULL)
		varParam[1] = pszSchema;
	if(pszTable != NULL)
		varParam[2] = pszTable;
	if(pszType != NULL)
		varParam[3] = pszType;

	hr = CSchemaRowset::Open(DBSCHEMA_TABLES, 4, varParam, rowset);

	return hr;
}


HRESULT CViewsRowset::Open(LPCTSTR pszCatalog, LPCTSTR pszSchema, LPCTSTR pszTable, CRowset &rowset)
{
	HRESULT		hr;
	CComVariant	varParam[3];

	if(pszCatalog != NULL)
		varParam[0] = pszCatalog;
	if(pszSchema != NULL)
		varParam[1] = pszSchema;
	if(pszTable != NULL)
		varParam[2] = pszTable;

	hr = CSchemaRowset::Open(DBSCHEMA_VIEWS, 3, varParam, rowset);

	return hr;
}


// CColumnsRowset::Open
//
//		Opens the columns rowset with the given restrictions
//
HRESULT CColumnsRowset::Open(LPCTSTR	pszTableCatalog, 
							 LPCTSTR	pszTableSchema, 
							 LPCTSTR	pszTableName, 
							 LPCTSTR	pszColumnName,
							 CRowset&	rowset)
{
	HRESULT		hr;
	CComVariant	varParam[4];

	if(pszTableCatalog != NULL)
		varParam[0] = pszTableCatalog;
	if(pszTableSchema != NULL)
		varParam[1] = pszTableSchema;
	if(pszTableName != NULL)
		varParam[2] = pszTableName;
	if(pszColumnName != NULL)
		varParam[3] = pszColumnName;

	hr = CSchemaRowset::Open(DBSCHEMA_COLUMNS, 4, varParam, rowset);

	return hr;
}


// CIndexesRowset::Open
//
//		Opens the indexes rowset with the given restrictions
//
HRESULT CIndexesRowset::Open(LPCTSTR	pszCatalog, 
							 LPCTSTR	pszTableSchema, 
							 LPCTSTR	pszIndexName, 
							 LPCTSTR	pszType, 
							 LPCTSTR	pszTableName, 
							 CRowset&	rowset)
{
	HRESULT		hr;
	CComVariant	varParam[5];

	if(pszCatalog != NULL)
		varParam[0] = pszCatalog;
	if(pszTableSchema != NULL)
		varParam[1] = pszTableSchema;
	if(pszIndexName != NULL)
		varParam[2] = pszIndexName;
	if(pszType != NULL)
		varParam[3] = pszType;
	if(pszTableName != NULL)
		varParam[4] = pszTableName;

	hr = CSchemaRowset::Open(DBSCHEMA_INDEXES, 5, varParam, rowset);

	return hr;
}
<file_sep>/7-Zip/CPP/7zip/Archive/Zip/ZipCompressionMode.h
// CompressionMode.h

#ifndef __ZIP_COMPRESSION_MODE_H
#define __ZIP_COMPRESSION_MODE_H

#include "Common/MyString.h"

namespace NArchive {
namespace NZip {

struct CCompressionMethodMode
{
  CRecordVector<Byte> MethodSequence;
  UString MatchFinder;
  UInt32 Algo;
  UInt32 NumPasses;
  UInt32 NumFastBytes;
  bool NumMatchFinderCyclesDefined;
  UInt32 NumMatchFinderCycles;
  UInt32 DicSize;
  #ifndef _7ZIP_ST
  UInt32 NumThreads;
  #endif
  bool PasswordIsDefined;
  AString Password;
  bool IsAesMode;
  Byte AesKeyMode;
  
  CCompressionMethodMode():
      NumMatchFinderCyclesDefined(false),
      PasswordIsDefined(false),
      IsAesMode(false),
      AesKeyMode(3)
      {}
};

}}

#endif
<file_sep>/FingerSuite/FingerMenuCTRL/resource.h
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by FingerMenu.rc
//
#define IDR_MAINFRAME                   128
#define IDS_MENU_CONFIGURE              129
#define IDS_MENU_ADDTOEXCLUSIONLIST     130
#define IDS_MENU_SHOWORIGINAL           131
#define IDS_MENU_ABOUT                  132
#define IDS_MENU_EXIT                   133
#define IDS_SOFTKEY_CLOSE               134
#define IDS_MENU_ADDTOWNDEXCLUSIONLIST  136
#define IDS_SOFTKEY_BACK                205

#define IDS_UNKNOWN_ERROR               444


#define IDR_CHECKED                     201
#define IDR_SUBMENU                     202
#define ID_MENU_EXIT                    32776
#define ID_MENU_CONFIGURE               32777
#define ID_MENU_ADDTOEXCLUSIONLIST      32778
#define ID_MENU_ABOUT                   32779
#define ID_MENU_SHOWORIGINAL            32780
#define ID_BACK                         32781
#define ID_MENU_ADDTOWNDEXCLUSIONLIST   32782
#define FM_IDW_MENU_BAR                 0xE803
#define FM_IDW_BACK_MENU_BAR            0xE804

// Next default values for new objects
// 
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE        217
#define _APS_NEXT_COMMAND_VALUE         32780
#define _APS_NEXT_CONTROL_VALUE         1003
#define _APS_NEXT_SYMED_VALUE           101
#endif
#endif
<file_sep>/FingerSuite/FingerNotification/NotifListWindow.h
// WTLApp1View.h : interface of the CWTLApp1View class
//
/////////////////////////////////////////////////////////////////////////////

#pragma once



#include <Connmgr_status.h>
//#include "snapi.h"

#ifndef __FNGRSCRL_H__
	#error menu.h requires fngrscrl.h to be included first
#endif

#define UM_SELECTNOTIF WM_USER + 98
#define UM_STATENOTIF  WM_USER + 99
#define UM_MINIMIZE    WM_USER + 100
#define UM_ACTIVATEMINIMIZETIMER WM_USER + 101
#define UM_STOPMINIMIZETIMER WM_USER + 102

#define IDT_AUTOMINIMIZE   100001

// Which values to refresh
//#define TB_BLUETOOTH_MASK       0x10
//#define TB_TIME_MASK            0x04
//#define TB_CONNECTIONS_MASK     0x40
#define TB_BATTERY_MASK              0x08
#define TB_VOLUME_MASK               0x20
#define TB_SIGNAL_MASK               0x01
#define TB_OPERATOR_MASK             0x02
#define TB_PHONE_STATUS_MASK         0x80
#define TB_CELLSYSTEMCONNECTED_MASK  0x0100
#define TB_PHONEACTIVECALLCOUNT_MASK 0x0200

#define SN_RINGMODE_ROOT        HKEY_CURRENT_USER
#define SN_RINGMODE_PATH        TEXT("ControlPanel\\Notifications\\ShellOverrides")
#define SN_RINGMODE_VALUE       TEXT("Mode")
#define SN_RINGMODE_SOUND       0
#define SN_RINGMODE_VIBRATE     1
#define SN_RINGMODE_MUTE        2

#define BTN_ICON_SIZE  16

#define IDC_BTN_VOLUME          10001
#define IDC_BTN_BATTERY         10002
#define IDC_BTN_CELLULAR        10003


class CListWindow : public CWindowImpl<CListWindow>, public CFingerScrollImpl<CListWindow, true, false>
{
public:
	DECLARE_WND_CLASS(NULL)

	BOOL PreTranslateMessage(MSG* pMsg)
	{
		pMsg;
		return FALSE;
	}

	CListWindow()
	{
	}

	void DoPaint(CDCHandle dc)
	{
		int cx = 32 * m_scaleFactor;
		int cy = 32 * m_scaleFactor;

		RECT rc; GetClientRect(&rc);
		// background
		dc.FillSolidRect(&rc, m_clBkg);

		CFont oldFont = dc.SelectFont(m_fText);

		if (g_pNotifications.GetSize() == 0)
		{
			RECT rcText; CopyRect(&rcText, &rc);

			// draw text 
			rcText.top = rcText.top + 5 * m_scaleFactor;
			dc.SetBkMode(TRANSPARENT);
			dc.SetTextColor(m_clText);
			dc.DrawText( LoadResourceString(IDS_NO_NEW_NOTIFICATIONS), -1, &rcText, DT_CENTER | DT_TOP | DT_SINGLELINE | DT_END_ELLIPSIS); 
		}

		for (int i = 0; i < g_pNotifications.GetSize(); i++)
		{
			RECT rcItem = {0, i * m_itemHeight, rc.right, (i + 1) * m_itemHeight};
			LPNOTIFICATIONINFO pInfo = g_pNotifications[i];
			
			// background
			//dc.FillSolidRect(&rcItem, m_clBkg);

			if (i == m_idxSelected)
			{
				m_imgSelection.Draw(dc, rcItem);
			}

			// draw icon
			RECT rcImg = {0, rcItem.top + (m_itemHeight - cy)/2, cx, rcItem.bottom - (m_itemHeight - cy)/2};
			OffsetRect(&rcImg, 2 * m_scaleFactor, 0);
			//m_imgIconBkg.Draw(dc, rcImg);
			
			InflateRect(&rcImg, -2 * m_scaleFactor, -2 * m_scaleFactor);
			CIconHandle icon = pInfo->nd.hicon;
			icon.DrawIconEx(dc, rcImg.left, rcImg.top, (rcImg.right - rcImg.left), (rcImg.bottom - rcImg.top));

			// draw text 
			RECT rcText; CopyRect(&rcText, &rcItem);
			rcText.left = cx + 16 * m_scaleFactor;
			dc.SetBkMode(TRANSPARENT);
			dc.SetTextColor(m_clText);
			dc.DrawText(pInfo->nd.pszTitle, -1, &rcText, DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS); 


			// dotted line 1px
			CPen pen2; pen2.CreatePen(PS_DASH, 1, m_clLine);
			CPen penOld2 = dc.SelectPen(pen2);
			dc.MoveTo(rcItem.left, rcItem.bottom - 1);
			dc.LineTo(rcItem.right, rcItem.bottom - 1);
			dc.SelectPen(penOld2);	
		}

		dc.SelectFont(oldFont);
	}

	void DoScroll(int yOffset)
	{
		//LOG(L"offset = %d\n", -yOffset);
		//ScrollWindowEx(0, -yOffset, SW_SCROLLCHILDREN | SW_INVALIDATE); 
		//m_btnBattery.MoveUpDownWindow(yOffset);
	}	

	void AddIcon(CString key, CString path)
	{
		CxImage img;
		img.Load(path, CXIMAGE_FORMAT_PNG);

		m_icons.Add(key, img);
	}

	typedef CFingerScrollImpl<CListWindow, true, false> scrollbaseClass;

	BEGIN_MSG_MAP(CListWindow)
		MESSAGE_HANDLER(WM_CREATE, OnCreate)
		//MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
		MESSAGE_HANDLER(WM_SIZE, OnSize)
		MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBackground)
		MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown)
		MESSAGE_HANDLER(WM_MOUSEMOVE, OnMouseMove)
		MESSAGE_HANDLER(WM_LBUTTONUP, OnLButtonUp)
		CHAIN_MSG_MAP(scrollbaseClass)
	END_MSG_MAP()

	LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		m_itemHeight = m_imgSelection.GetHeight();		
		return 0;
	}

	LRESULT OnSize(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled)
	{
		if(wParam != SIZE_MINIMIZED)
		{
			RECT rc; GetClientRect(&rc);
			SetFingerScrollRegion(g_pNotifications.GetSize() * m_itemHeight, rc.bottom);
		}
		return 0;
	}

	LRESULT OnEraseBackground(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		return 1;
	}

	LRESULT OnLButtonDown(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled)
	{
		// gesture recognize
		SHRGINFO    shrg;
		shrg.cbSize = sizeof(shrg);
		shrg.hwndClient = GetParent().GetParent();
		shrg.ptDown.x = LOWORD(lParam);
		shrg.ptDown.y = GetOffset() + HIWORD(lParam);
		shrg.dwFlags = SHRG_RETURNCMD;
		if (SHRecognizeGesture(&shrg) == GN_CONTEXTMENU) 
		{
			GetParent().SendMessage(UM_STOPMINIMIZETIMER);
			
			HMENU hMenu = ::AtlLoadMenu(IDR_MAINFRAME);
			HMENU hSubMenu = GetSubMenu(hMenu, 0);
			BOOL bRes = TrackPopupMenuEx(hSubMenu, TPM_LEFTALIGN, LOWORD(lParam), GetOffset() + HIWORD(lParam), GetParent().GetParent(), NULL);

			GetParent().SendMessage(UM_ACTIVATEMINIMIZETIMER);

			return 0;
			//GetParent().GetParent().PostMessage(UM_MINIMIZE);
		}


		m_xPos = LOWORD(lParam);
		m_yPos = HIWORD(lParam);
		m_bMouseIsDown = TRUE;

		m_idxSelected = (GetOffset() + m_yPos) / m_itemHeight;
		m_idxDPadSelected = -1;

		if ((m_idxSelected >= 0) && (m_idxSelected < g_pNotifications.GetSize()))
		{
			InvalidateRect(NULL, FALSE);
			UpdateWindow();
		}
		else
			m_idxSelected = -1;

		bHandled = FALSE; // very important
		return 0;
	}

	LRESULT OnMouseMove(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled)
	{
		int y = HIWORD(lParam);
		if  (abs(y - m_yPos) >  GetThreshold())
		{
			if (m_idxSelected != -1)
			{
				m_idxSelected = -1;
				InvalidateRect(NULL, FALSE);
				UpdateWindow();
			}
		}

		m_yPos = HIWORD(lParam);

		GetParent().PostMessage(UM_ACTIVATEMINIMIZETIMER); 

 		bHandled = FALSE; // very important
		return 0;
	}

	LRESULT OnLButtonUp(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled)
	{
		m_bMouseIsDown = FALSE;

		// normal mode
		if (m_idxSelected != -1)
		{
			GetParent().GetParent().SendMessage(UM_SELECTNOTIF, (WPARAM)m_idxSelected, 0);
		}

		bHandled = FALSE; // very important
		return 0;
	}

private:
	int m_xPos;
	int m_yPos;
	int m_idxSelected;
	int m_idxDPadSelected;
	BOOL m_bMouseIsDown;

	CSimpleMap<CString, CxImage> m_icons;

public:
	int m_itemHeight;
	CxImage m_imgSelection;
	CFontHandle m_fText;
	int m_scaleFactor;
	COLORREF m_clText;
	COLORREF m_clLine;
	COLORREF m_clBkg;

	
};


class CNotifListWindow : public CWindowImpl<CNotifListWindow>, public COffscreenDraw<CNotifListWindow>
{
public:
	DECLARE_WND_CLASS(NULL)

	CListWindow m_notiflist;

	BOOL PreTranslateMessage(MSG* pMsg)
	{
		pMsg;
		return FALSE;
	}

	CNotifListWindow()
	{
	}

	void Show()
	{
		//m_notiflist.m_idxSelected = -1;
		RECT rc; GetParent().GetClientRect(&rc);
		MoveWindow(&rc, TRUE);

		ActivateMinimizeTimer();
	}



	void DoPaint(CDCHandle dc)
	{
		RECT rc; GetClientRect(&rc);
		

		SIZE imgSize;
		imgSize.cx = m_imgIconBkg.GetWidth();
		imgSize.cy = m_imgIconBkg.GetHeight();

		RECT rcHHTaskTar; ::GetClientRect(::FindWindow(L"HHTaskBar", NULL), &rcHHTaskTar);
		int hTaskBar = rcHHTaskTar.bottom - rcHHTaskTar.top;

		// HEADER
		RECT rcHeader;
		int h = m_arrStaticImages[0].GetHeight();
		int w = m_arrStaticImages[0].GetWidth();

		CPen pen; pen.CreatePen(PS_SOLID, 1, m_clLine);	
		CPen oldPen = dc.SelectPen(pen);
		dc.SetBkMode(TRANSPARENT);
		dc.SetTextColor(m_clText);

		// title
		CFont oldFont = dc.SelectFont(m_fTitleText);
		dc.DrawText( LoadResourceString(IDR_MAINFRAME), -1, &rcHHTaskTar, DT_CENTER | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS); 
		dc.SelectFont(oldFont);

		
		// volume
		SetRect(&rcHeader, 0, hTaskBar, rc.right, hTaskBar + h);
		dc.FillSolidRect(&rcHeader, m_clBkgHeader);
		dc.MoveTo(rcHeader.left, rcHeader.bottom );
		dc.LineTo(rcHeader.right, rcHeader.bottom );
		rcHeader.left += 10 * m_scaleFactor;
		oldFont = dc.SelectFont(m_fHeaderText);
		dc.DrawText(LoadResourceString(IDS_VOLUME), -1, &rcHeader, DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS); 
		
		// battery
		SetRect(&rcHeader, 0, hTaskBar + h + 1, rc.right, hTaskBar + h + 1 + h);
		dc.FillSolidRect(&rcHeader, m_clBkgHeader);
		dc.MoveTo(rcHeader.left, rcHeader.bottom );
		dc.LineTo(rcHeader.right, rcHeader.bottom );
		//InflateRect(&rcHeader, -10 * m_scaleFactor, 0);
		rcHeader.left += 10 * m_scaleFactor;
		dc.DrawText(LoadResourceString(IDS_BATTERY), -1, &rcHeader, DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS); 
		rcHeader.right -= (w + 5 * m_scaleFactor);
		WCHAR text[50];
		wsprintf(text, L"%d%%", m_nBatteryPercent);
		if (m_nBatteryPercent != BATTERY_PERCENTAGE_UNKNOWN)
			dc.DrawText(text, -1, &rcHeader, DT_RIGHT | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS); 

		// cellular
		SetRect(&rcHeader, 0, hTaskBar + h + 1 + h + 1 + 1, rc.right, hTaskBar + h + 1 + h + 1 + h);
		dc.FillSolidRect(&rcHeader, m_clBkgHeader);
		dc.MoveTo(rcHeader.left, rcHeader.bottom );
		dc.LineTo(rcHeader.right, rcHeader.bottom );
		rcHeader.left += 10 * m_scaleFactor;
		dc.DrawText(m_szCarrier, -1, &rcHeader, DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS); 



		dc.SelectPen(oldPen);	
		dc.SelectFont(oldFont);		


	}

	typedef CWindowImpl<CNotifListWindow>  winbaseClass;
	typedef COffscreenDraw<CNotifListWindow> offscreenbaseClass;

	BEGIN_MSG_MAP(CNotifListWindow)
		MESSAGE_HANDLER(WM_CREATE, OnCreate)
		MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
		MESSAGE_HANDLER(WM_SIZE, OnSize)
		MESSAGE_HANDLER(WM_TIMER, OnTimer)
		MESSAGE_HANDLER(UM_STATENOTIF, OnStateNotif)
		MESSAGE_HANDLER(UM_ACTIVATEMINIMIZETIMER, OnActivateMinimizeTimer)
		MESSAGE_HANDLER(UM_STOPMINIMIZETIMER, OnStopMinimizeTimer)
		CHAIN_MSG_MAP(offscreenbaseClass)
	END_MSG_MAP()

	LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		m_notiflist.Create(m_hWnd, rcDefault, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN);

		m_btnVolume.Create(m_hWnd, FNGRBTN_TYPE_STATIC | FNGRBTN_TYPE_ICON, TRUE, m_clBkgHeader, BTN_ICON_SIZE * m_scaleFactor, IDC_BTN_VOLUME);
		m_btnBattery.Create(m_hWnd, FNGRBTN_TYPE_STATIC | FNGRBTN_TYPE_ICON, TRUE, m_clBkgHeader, BTN_ICON_SIZE * m_scaleFactor, IDC_BTN_BATTERY);
		m_btnCellular.Create(m_hWnd, FNGRBTN_TYPE_STATIC | FNGRBTN_TYPE_ICON, TRUE, m_clBkgHeader, BTN_ICON_SIZE * m_scaleFactor, IDC_BTN_CELLULAR);

		m_btnVolume.SetArrayImageSet(m_arrStaticImages);
		m_btnBattery.SetArrayImageSet(m_arrStaticImages);
		m_btnCellular.SetArrayImageSet(m_arrStaticImages);

		// notifications
		// Speaker / Volume
		HRESULT hr = ::RegistryNotifyWindow( SN_RINGMODE_ROOT,
										   SN_RINGMODE_PATH,	
	                                       SN_RINGMODE_VALUE,
                                           m_hWnd, UM_STATENOTIF, TB_VOLUME_MASK,
		                                   NULL, &m_hVolume);

		// Battery
		hr = ::RegistryNotifyWindow(
					SN_POWERBATTERYSTRENGTH_ROOT, 
					SN_POWERBATTERYSTRENGTH_PATH, 
					SN_POWERBATTERYSTRENGTH_VALUE,
					m_hWnd, UM_STATENOTIF, TB_BATTERY_MASK,
					NULL, &m_hBattery);

		// phone status
		hr = ::RegistryNotifyWindow(
					SN_PHONERADIOOFF_ROOT, 
					SN_PHONERADIOOFF_PATH, 
					SN_PHONERADIOOFF_VALUE,
					m_hWnd, UM_STATENOTIF, TB_PHONE_STATUS_MASK,
					NULL, &m_hPhoneStatus);

		// signal strengh
		hr = ::RegistryNotifyWindow(
					SN_PHONESIGNALSTRENGTH_ROOT,
					SN_PHONESIGNALSTRENGTH_PATH,
					SN_PHONESIGNALSTRENGTH_VALUE, 
					m_hWnd, UM_STATENOTIF, TB_SIGNAL_MASK,
					NULL, &m_hSignal);

		// operator name
		hr = ::RegistryNotifyWindow(
					SN_PHONEOPERATORNAME_ROOT, 
					SN_PHONEOPERATORNAME_PATH, 
					SN_PHONEOPERATORNAME_VALUE,  
					m_hWnd, UM_STATENOTIF, TB_OPERATOR_MASK,
					NULL, &m_hOperator);

		// cell system
		hr = ::RegistryNotifyWindow(
					SN_CELLSYSTEMCONNECTED_ROOT, 
					SN_CELLSYSTEMCONNECTED_PATH, 
					SN_CELLSYSTEMCONNECTED_VALUE,  
					m_hWnd, UM_STATENOTIF, TB_CELLSYSTEMCONNECTED_MASK,
					NULL, &m_hCellSystem);


		// active phone call
		hr = ::RegistryNotifyWindow(
					SN_PHONEACTIVECALLCOUNT_ROOT, 
					SN_PHONEACTIVECALLCOUNT_PATH, 
					SN_PHONEACTIVECALLCOUNT_VALUE,  
					m_hWnd, UM_STATENOTIF, TB_PHONEACTIVECALLCOUNT_MASK,
					NULL, &m_hActivePhoneCall);


		BOOL dummy;
		OnStateNotif(0, 0, 0xFFFF, dummy);

		return 0;
	}

	LRESULT OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		if (m_hVolume != NULL)
			RegistryCloseNotification(m_hVolume);

		if (m_hBattery != NULL)
			RegistryCloseNotification(m_hBattery);

		return 0;
	}

	LRESULT OnStateNotif(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/)
	{
		DWORD dwWhich = (UINT)lParam;
		
		if (
                (dwWhich & TB_SIGNAL_MASK) 
             || (dwWhich & TB_OPERATOR_MASK) 
			 || (dwWhich & TB_PHONE_STATUS_MASK) 
             || (dwWhich & TB_CELLSYSTEMCONNECTED_MASK) 
             || (dwWhich & TB_PHONEACTIVECALLCOUNT_MASK) 
		   )	
			dwWhich |= TB_SIGNAL_MASK | TB_OPERATOR_MASK | TB_PHONE_STATUS_MASK | TB_CELLSYSTEMCONNECTED_MASK | TB_PHONEACTIVECALLCOUNT_MASK;


		RefreshStatus(dwWhich);


		if (m_bSpeakerOn)
			m_btnVolume.SetIcon( AtlLoadIcon(IDI_VOLUME_ON) );
		else if (m_bVibrate)
			m_btnVolume.SetIcon( AtlLoadIcon(IDI_VOLUME_VIBRATE) );
		else
			m_btnVolume.SetIcon( AtlLoadIcon(IDI_VOLUME_OFF) );		

		if (m_bCharging)
			m_btnBattery.SetIcon( AtlLoadIcon(IDI_BATTERY_CHARGING) );
		else if (m_bNoBattery)
			m_btnBattery.SetIcon( AtlLoadIcon(IDI_BATTERY_ABSENT) );
		else if (m_bBatteryCritical)
			m_btnBattery.SetIcon( AtlLoadIcon(IDI_BATTERY_CRITICAL) );
		else
		{
			if (m_nBatteryPercent != BATTERY_PERCENTAGE_UNKNOWN)
			{
				if ((m_nBatteryPercent >= 0) && (m_nBatteryPercent <= 20))
					m_btnBattery.SetIcon( AtlLoadIcon(IDI_BATTERY_1) );
				if ((m_nBatteryPercent >= 21) && (m_nBatteryPercent <= 40))
					m_btnBattery.SetIcon( AtlLoadIcon(IDI_BATTERY_2) );
				if ((m_nBatteryPercent >= 41) && (m_nBatteryPercent <= 60))
					m_btnBattery.SetIcon( AtlLoadIcon(IDI_BATTERY_3) );
				if ((m_nBatteryPercent >= 61) && (m_nBatteryPercent <= 80))
					m_btnBattery.SetIcon( AtlLoadIcon(IDI_BATTERY_4) );
				if ((m_nBatteryPercent >= 81) && (m_nBatteryPercent <= 100))
					m_btnBattery.SetIcon( AtlLoadIcon(IDI_BATTERY_5) );
			}
		}

		// phone
		if (m_bPhoneOff)
		{
			wsprintf(m_szCarrier, L"No service");
			m_btnCellular.SetIcon( AtlLoadIcon(IDI_PHONE) );
			m_btnCellular.SetIcon2( AtlLoadIcon(IDI_OFF) );
		}
		else
		{
			if (m_bActiveDataCall)
			{
				if (m_dwConnectionType & SN_CELLSYSTEMCONNECTED_GPRS_BITMASK)
					m_btnCellular.SetIcon( AtlLoadIcon(IDI_CONN_G) );

				if (m_dwConnectionType & SN_CELLSYSTEMCONNECTED_EDGE_BITMASK)
					m_btnCellular.SetIcon( AtlLoadIcon(IDI_CONN_E) );

				if (m_dwConnectionType & SN_CELLSYSTEMCONNECTED_UMTS_BITMASK)
					m_btnCellular.SetIcon( AtlLoadIcon(IDI_CONN_3G) );

				if (m_dwConnectionType & SN_CELLSYSTEMCONNECTED_HSDPA_BITMASK)
					m_btnCellular.SetIcon( AtlLoadIcon(IDI_CONN_H) );

			}
			else if (m_bActiveCall)
				m_btnCellular.SetIcon( AtlLoadIcon(IDI_INCALL) );
			else
				m_btnCellular.SetIcon( AtlLoadIcon(IDI_PHONE) );
		}

		if (m_bNoService)
		{
			if (!(m_bPhoneOff))
			{
				wsprintf(m_szCarrier, L"No service");
				m_btnCellular.SetIcon2( AtlLoadIcon(IDI_NO_SERVICE) );
			}
		}
		else if (m_bSearchingForService)
		{
			wsprintf(m_szCarrier, L"Searching");
			m_btnCellular.SetIcon2( AtlLoadIcon(IDI_SEARCHING) );
		}
		else
		{
			m_nBars -= 1;

			if (m_nBars == 0)
				m_btnCellular.SetIcon2( NULL );
			if (m_nBars == 1)
				m_btnCellular.SetIcon2( AtlLoadIcon(IDI_SIGNAL_1) );
			if (m_nBars == 2)
				m_btnCellular.SetIcon2( AtlLoadIcon(IDI_SIGNAL_2) );
			if (m_nBars == 3)
				m_btnCellular.SetIcon2( AtlLoadIcon(IDI_SIGNAL_3) );
			if (m_nBars == 4)
				m_btnCellular.SetIcon2( AtlLoadIcon(IDI_SIGNAL_4) );
		}




		return 0;
	}


	LRESULT OnSize(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled)
	{
		if(wParam != SIZE_MINIMIZED)
		{
			RECT rc; GetClientRect(&rc);

			// move buttons
			RECT rcHHTaskTar; ::GetClientRect(::FindWindow(L"HHTaskBar", NULL), &rcHHTaskTar);
			int hTaskBar = rcHHTaskTar.bottom - rcHHTaskTar.top;


			int h = m_arrStaticImages[0].GetHeight();
			int w = m_arrStaticImages[0].GetWidth();
			
			RECT rcBtn;
			SetRect(&rcBtn, rc.right - w, hTaskBar, rc.right, hTaskBar + h);
			m_btnVolume.MoveWindow(&rcBtn);

			SetRect(&rcBtn, rc.right - w, hTaskBar + h + 1, rc.right, hTaskBar + h + 1 + h);
			m_btnBattery.MoveWindow(&rcBtn);

			SetRect(&rcBtn, rc.right - w, hTaskBar + h + 1 + h + 1 + 1, rc.right, hTaskBar + h + 1 + h + 1 + h);
			m_btnCellular.MoveWindow(&rcBtn);


			int headOffset = hTaskBar + 3 * (h + 1);
			RECT rcNotifyList = {0, headOffset, rc.right, rc.bottom};
			m_notiflist.MoveWindow(&rcNotifyList);


		}

		bHandled = FALSE;
		return 0;
	}


	LRESULT OnTimer(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
	{
		if ((wParam == IDT_AUTOMINIMIZE) && (IsWindowVisible()))
		{
			StopMinimizeTimer();
			GetParent().PostMessage(UM_MINIMIZE);
		}

		return 0;
	}

	LRESULT OnActivateMinimizeTimer(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		ActivateMinimizeTimer();
		return 0;
	}

	LRESULT OnStopMinimizeTimer(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		StopMinimizeTimer();
		return 0;
	}

public: 

	CxImage m_imgIconBkg;
	CFontHandle m_fHeaderText;
	CFontHandle m_fTitleText;
	COLORREF m_clText;
	COLORREF m_clLine;

	COLORREF m_clBkgHeader;
	int m_scaleFactor;
	DWORD m_tmrMinimize;

	CxImage m_arrStaticImages[9];

	void SetScaleFactor(int value)
	{
		m_scaleFactor = value;
		m_notiflist.m_scaleFactor = value;
	}

	void ActivateMinimizeTimer()
	{
		KillTimer(IDT_AUTOMINIMIZE);
		SetTimer(IDT_AUTOMINIMIZE, m_tmrMinimize);
	}

	void StopMinimizeTimer()
	{
		KillTimer(IDT_AUTOMINIMIZE);
	}


private:
	// notifications
	HREGNOTIFY m_hVolume;
	HREGNOTIFY m_hBattery;
	HREGNOTIFY m_hPhoneStatus;
	HREGNOTIFY m_hSignal;
	HREGNOTIFY m_hOperator;
	HREGNOTIFY m_hCellSystem;
	HREGNOTIFY m_hActivePhoneCall;

	BYTE m_nBatteryPercent;
	BOOL m_bSpeakerOn;
	BOOL m_bVibrate;
	BOOL m_bCharging;
	BOOL m_bNoBattery;
	BOOL m_bBatteryCritical;
	BOOL m_bPhoneOff;
	BOOL m_bActiveDataCall;
	BOOL m_bActiveCall;
	BOOL m_bNoService;
	BOOL m_bSearchingForService;
	WCHAR m_szCarrier[50];
	DWORD m_dwConnectionType;
	int m_nBars; //0-5


	CFingerButton m_btnVolume;
	CFingerButton m_btnBattery;
	CFingerButton m_btnCellular;

	void RefreshStatus(DWORD dwWhich)
	{
		DWORD dw;
		HRESULT hr;


		// Speaker / volume
		if (dwWhich & TB_VOLUME_MASK) {
			hr = RegistryGetDWORD(
									SN_RINGMODE_ROOT,
									SN_RINGMODE_PATH,	
									SN_RINGMODE_VALUE,
										&dw);

			if (SUCCEEDED(hr)) {
				m_bSpeakerOn = dw == SN_RINGMODE_SOUND;
				m_bVibrate = dw == SN_RINGMODE_VIBRATE;
			}


		}

	    // Battery level & charging state
		if (dwWhich & TB_BATTERY_MASK) {
			SYSTEM_POWER_STATUS_EX2 sps = {0};
			DWORD result = ::GetSystemPowerStatusEx2(&sps,
				sizeof(SYSTEM_POWER_STATUS_EX2), false);

			if (result > 0) 
			{
				m_bCharging = (sps.BatteryFlag & BATTERY_FLAG_CHARGING) > 0;
				m_bNoBattery = (sps.BatteryFlag & BATTERY_FLAG_NO_BATTERY) > 0;
				m_bBatteryCritical = (sps.BatteryFlag & BATTERY_FLAG_CRITICAL) > 0;
				m_nBatteryPercent = sps.BatteryLifePercent;
			}


		}

		// Operator name
		if (dwWhich & TB_OPERATOR_MASK) {
			hr = RegistryGetString(
						SN_PHONEOPERATORNAME_ROOT, 
						SN_PHONEOPERATORNAME_PATH, 
						SN_PHONEOPERATORNAME_VALUE, 
						m_szCarrier, sizeof(m_szCarrier));
		}

		// Signal Strength
		if (dwWhich & TB_SIGNAL_MASK) {
			hr = RegistryGetDWORD(
						SN_PHONESIGNALSTRENGTH_ROOT, 
						SN_PHONESIGNALSTRENGTH_PATH, 
						SN_PHONESIGNALSTRENGTH_VALUE,
						&dw);
			if (SUCCEEDED(hr))
				m_nBars = (int)((double)dw / 20.0);
		}

		// connection type
		if (dwWhich & TB_CELLSYSTEMCONNECTED_MASK) {
			hr = RegistryGetDWORD(
						SN_CELLSYSTEMCONNECTED_ROOT, 
						SN_CELLSYSTEMCONNECTED_PATH, 
						SN_CELLSYSTEMCONNECTED_VALUE,
						&dw);
			if (SUCCEEDED(hr))
				m_dwConnectionType = dw;
		}
		
		// phone status
		if (dwWhich & TB_PHONE_STATUS_MASK) {
			hr = RegistryGetDWORD(
						SN_PHONERADIOOFF_ROOT, 
						SN_PHONERADIOOFF_PATH, 
						SN_PHONERADIOOFF_VALUE,
						&dw);
			if (SUCCEEDED(hr))
			{
				m_bPhoneOff = (dw & SN_PHONERADIOOFF_BITMASK) > 0;
				m_bActiveDataCall = (dw & SN_PHONEACTIVEDATACALL_BITMASK) > 0;
				m_bSearchingForService = (dw & SN_PHONESEARCHINGFORSERVICE_BITMASK) > 0;
				m_bNoService = (dw & SN_PHONENOSERVICE_BITMASK) > 0;
			}
		}

		// active call
		if (dwWhich & TB_PHONEACTIVECALLCOUNT_MASK) {
			hr = RegistryGetDWORD(
						SN_PHONEACTIVECALLCOUNT_ROOT, 
						SN_PHONEACTIVECALLCOUNT_PATH, 
						SN_PHONEACTIVECALLCOUNT_VALUE,
						&dw);
			if (SUCCEEDED(hr))
				m_bActiveCall = dw > 0;
			else
				m_bActiveCall = FALSE;
		}

		CONNMGR_CONNECTION_DETAILED_STATUS  *pConnMgrDet = NULL;
		HRESULT hResult; 
		DWORD dwBufferSize=0; //Code Snippet
		hResult = ConnMgrQueryDetailedStatus(pConnMgrDet, &dwBufferSize);

		if (hResult == (HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER)))
		{
			pConnMgrDet = (CONNMGR_CONNECTION_DETAILED_STATUS*)malloc(dwBufferSize);
			hResult = ConnMgrQueryDetailedStatus(pConnMgrDet, &dwBufferSize);
		}

		CONNMGR_CONNECTION_DETAILED_STATUS  *pCurrent = pConnMgrDet;

		if (hResult == S_OK)
		{
			while (pCurrent != NULL) 
			{
				//Do what you want eg. if you want to check cellular network
				if (pCurrent->dwType == CM_CONNTYPE_CELLULAR) 
				{
					//Do some thing 
				}

				pCurrent = pCurrent->pNext;
			}
		}

		free(pConnMgrDet);
	}


};<file_sep>/FingerSuite/Common/fngrbufdc.h
#ifndef __FNGRBUFDC_H__
#define __FNGRBUFDC_H__

#pragma once

#ifndef __cplusplus
	#error ATL requires C++ compilation (use a .cpp suffix)
#endif

#ifndef __ATLAPP_H__
	#error atlgdi.h requires atlapp.h to be included first
#endif

#ifndef __ATLGDI_H__
	#error fngrbufdc.h requires atlgdi.h to be included first
#endif

///////////////////////////////////////////////////////////////////////////////
// Classes in this file:
//
// CBufferedPaintDC

class CBufferedPaintDC : public CDC
{
public:
	HWND m_hWnd;
	PAINTSTRUCT m_ps;

// Data members
	HDC m_hPaintDC;
	RECT m_rcClient;
	CBitmap m_bmp;
	HBITMAP m_hBmpOld;
	int m_offset;

// Constructor/destructor
	CBufferedPaintDC(HWND hWnd, int offset)
	{
		ATLASSERT(::IsWindow(hWnd));
		m_hWnd = hWnd;
		m_offset = offset;
		m_hPaintDC = ::BeginPaint(hWnd, &m_ps);

		// buffer
		::GetClientRect(m_hWnd, &m_rcClient);
		m_hDC = ::CreateCompatibleDC(m_hPaintDC);
		ATLASSERT(m_hDC != NULL);
		m_bmp.CreateCompatibleBitmap(m_hPaintDC, m_rcClient.right - m_rcClient.left, m_rcClient.bottom - m_rcClient.top);
		ATLASSERT(m_bmp.m_hBitmap != NULL);
		m_hBmpOld = SelectBitmap(m_bmp);
	}

	~CBufferedPaintDC()
	{
		ATLASSERT(m_hDC != NULL);
		ATLASSERT(::IsWindow(m_hWnd));

		::BitBlt(m_hPaintDC, m_rcClient.left, m_rcClient.top, m_rcClient.right - m_rcClient.left, m_rcClient.bottom - m_rcClient.top, m_hDC, m_rcClient.left, m_rcClient.top - m_offset, SRCCOPY);
		SelectBitmap(m_hBmpOld);

		::EndPaint(m_hWnd, &m_ps);
		m_hPaintDC = NULL; // detach paint dc
		Detach();

	}
};

#endif<file_sep>/7-Zip/CPP/7zip/Archive/ElfHandler.cpp
// ElfHandler.cpp

#include "StdAfx.h"

#include "../../../C/CpuArch.h"

#include "Common/Buffer.h"
#include "Common/ComTry.h"
#include "Common/IntToString.h"

#include "Windows/PropVariantUtils.h"

#include "../Common/LimitedStreams.h"
#include "../Common/ProgressUtils.h"
#include "../Common/RegisterArc.h"
#include "../Common/StreamUtils.h"

#include "../Compress/CopyCoder.h"

static UInt16 Get16(const Byte *p, int be) { if (be) return GetBe16(p); return GetUi16(p); }
static UInt32 Get32(const Byte *p, int be) { if (be) return GetBe32(p); return GetUi32(p); }
static UInt64 Get64(const Byte *p, int be) { if (be) return GetBe64(p); return GetUi64(p); }

using namespace NWindows;

namespace NArchive {
namespace NElf {

#define ELF_CLASS_32 1
#define ELF_CLASS_64 2

#define ELF_DATA_2LSB 1
#define ELF_DATA_2MSB 2

#define NUM_SCAN_SECTIONS_MAX (1 << 6)

struct CHeader
{
  bool Mode64;
  bool Be;
  Byte Os;
  Byte AbiVer;

  UInt16 Type;
  UInt16 Machine;
  // UInt32 Version;

  // UInt64 EntryVa;
  UInt64 ProgOffset;
  UInt64 SectOffset;
  UInt32 Flags;
  UInt16 ElfHeaderSize;
  UInt16 SegmentEntrySize;
  UInt16 NumSegments;
  UInt16 SectEntrySize;
  UInt16 NumSections;
  // UInt16 SectNameStringTableIndex;

  bool Parse(const Byte *buf);

  bool CheckSegmentEntrySize() const
  {
    return (Mode64 && SegmentEntrySize == 0x38) || (!Mode64 && SegmentEntrySize == 0x20);
  };

  UInt64 GetHeadersSize() const
    { return ElfHeaderSize +
      (UInt64)SegmentEntrySize * NumSegments +
      (UInt64)SectEntrySize * NumSections; }
    
};

bool CHeader::Parse(const Byte *p)
{
  switch(p[4])
  {
    case ELF_CLASS_32: Mode64 = false; break;
    case ELF_CLASS_64: Mode64 = true; break;
    default: return false;
  }
  bool be;
  switch(p[5])
  {
    case ELF_DATA_2LSB: be = false; break;
    case ELF_DATA_2MSB: be = true; break;
    default: return false;
  }
  Be = be;
  if (p[6] != 1) // Version
    return false;
  Os = p[7];
  AbiVer = p[8];
  for (int i = 9; i < 16; i++)
    if (p[i] != 0)
      return false;

  Type = Get16(p + 0x10, be);
  Machine = Get16(p + 0x12, be);
  if (Get32(p + 0x14, be) != 1) // Version
    return false;

  if (Mode64)
  {
    // EntryVa = Get64(p + 0x18, be);
    ProgOffset = Get64(p + 0x20, be);
    SectOffset = Get64(p + 0x28, be);
    p += 0x30;
  }
  else
  {
    // EntryVa = Get32(p + 0x18, be);
    ProgOffset = Get32(p + 0x1C, be);
    SectOffset = Get32(p + 0x20, be);
    p += 0x24;
  }

  Flags = Get32(p + 0, be);
  ElfHeaderSize = Get16(p + 4, be);
  SegmentEntrySize = Get16(p + 6, be);
  NumSegments = Get16(p + 8, be);
  SectEntrySize = Get16(p + 10, be);
  NumSections = Get16(p + 12, be);
  // SectNameStringTableIndex = Get16(p + 14, be);
  return CheckSegmentEntrySize();
}

struct CSegment
{
  UInt32 Type;
  UInt32 Flags;
  UInt64 Offset;
  UInt64 Va;
  // UInt64 Pa;
  UInt64 PSize;
  UInt64 VSize;
  // UInt64 Align;

  void UpdateTotalSize(UInt64 &totalSize)
  {
    UInt64 t = Offset + PSize;
    if (t > totalSize)
      totalSize = t;
  }
  void Parse(const Byte *p, bool mode64, bool be);
};

void CSegment::Parse(const Byte *p, bool mode64, bool be)
{
  Type = Get32(p, be);
  if (mode64)
  {
    Flags = Get32(p + 4, be);
    Offset = Get64(p + 8, be);
    Va = Get64(p + 0x10, be);
    // Pa = Get64(p + 0x18, be);
    PSize = Get64(p + 0x20, be);
    VSize = Get64(p + 0x28, be);
    // Align = Get64(p + 0x30, be);
  }
  else
  {
    Offset = Get32(p + 4, be);
    Va = Get32(p + 8, be);
    // Pa = Get32(p + 12, be);
    PSize = Get32(p + 16, be);
    VSize = Get32(p + 20, be);
    Flags = Get32(p + 24, be);
    // Align = Get32(p + 28, be);
  }
}

static const CUInt32PCharPair g_MachinePairs[] =
{
  { 0, "None" },
  { 1, "AT&T WE 32100" },
  { 2, "SPARC" },
  { 3, "Intel 386" },
  { 4, "Motorola 68000" },
  { 5, "Motorola 88000" },
  { 6, "Intel 486" },
  { 7, "Intel i860" },
  { 8, "MIPS" },
  { 9, "IBM S/370" },
  { 10, "MIPS RS3000 LE" },
  { 11, "RS6000" },

  { 15, "PA-RISC" },
  { 16, "nCUBE" },
  { 17, "Fujitsu VPP500" },
  { 18, "SPARC 32+" },
  { 19, "Intel i960" },
  { 20, "PowerPC" },
  { 21, "PowerPC 64-bit" },
  { 22, "IBM S/390" },

  { 36, "NEX v800" },
  { 37, "Fujitsu FR20" },
  { 38, "TRW RH-32" },
  { 39, "Motorola RCE" },
  { 40, "ARM" },
  { 41, "Alpha" },
  { 42, "<NAME>" },
  { 43, "SPARC-V9" },
  { 44, "<NAME>" },
  { 45, "ARC" },
  { 46, "H8/300" },
  { 47, "H8/300H" },
  { 48, "H8S" },
  { 49, "H8/500" },
  { 50, "IA-64" },
  { 51, "Stanford MIPS-X" },
  { 52, "<NAME>" },
  { 53, "M68HC12" },
  { 54, "Fujitsu MMA" },
  { 55, "Siemens PCP" },
  { 56, "Sony nCPU" },
  { 57, "Denso NDR1" },
  { 58, "Motorola StarCore" },
  { 59, "Toyota ME16" },
  { 60, "ST100" },
  { 61, "Advanced Logic TinyJ" },
  { 62, "AMD64" },
  { 63, "Sony DSP" },

  { 66, "Siemens FX66" },
  { 67, "ST9+" },
  { 68, "ST7" },
  { 69, "MC68HC16" },
  { 70, "MC68HC11" },
  { 71, "MC68HC08" },
  { 72, "MC68HC05" },
  { 73, "Silicon Graphics SVx" },
  { 74, "ST19" },
  { 75, "Digital VAX" },
  { 76, "Axis CRIS" },
  { 77, "Infineon JAVELIN" },
  { 78, "Element 14 FirePath" },
  { 79, "LSI ZSP" },
  { 80, "MMIX" },
  { 81, "HUANY" },
  { 82, "SiTera Prism" },
  { 83, "Atmel AVR" },
  { 84, "Fujitsu FR30" },
  { 85, "Mitsubishi D10V" },
  { 86, "Mitsubishi D30V" },
  { 87, "NEC v850" },
  { 88, "Mitsubishi M32R" },
  { 89, "Matsushita MN10300" },
  { 90, "Matsushita MN10200" },
  { 91, "picoJava" },
  { 92, "OpenRISC" },
  { 93, "ARC Tangent-A5" },
  { 94, "Tensilica Xtensa" },
  { 0x9026, "Alpha" }
};

static const CUInt32PCharPair g_AbiOS[] =
{
  { 0, "None" },
  { 1, "HP-UX" },
  { 2, "NetBSD" },
  { 3, "Linux" },

  { 6, "Solaris" },
  { 7, "AIX" },
  { 8, "IRIX" },
  { 9, "FreeBSD" },
  { 10, "TRU64" },
  { 11, "Novell Modesto" },
  { 12, "OpenBSD" },
  { 13, "OpenVMS" },
  { 14, "HP NSK" },
  { 15, "AROS" },
  { 97, "ARM" },
  { 255, "Standalone" }
};

static const CUInt32PCharPair g_SegmentFlags[] =
{
  { 1 << 0, "Execute" },
  { 1 << 1, "Write" },
  { 1 << 2, "Read" }
};

static const char *g_Types[] =
{
  "None",
  "Relocatable file",
  "Executable file",
  "Shared object file",
  "Core file"
};

static const char *g_SegnmentTypes[] =
{
  "Unused",
  "Loadable segment",
  "Dynamic linking tables",
  "Program interpreter path name",
  "Note section",
  "SHLIB",
  "Program header table",
  "TLS"
};

class CHandler:
  public IInArchive,
  public CMyUnknownImp
{
  CMyComPtr<IInStream> _inStream;
  CObjectVector<CSegment> _sections;
  UInt32 _peOffset;
  CHeader _header;
  UInt64 _totalSize;
  HRESULT Open2(IInStream *stream);
  bool Parse(const Byte *buf, UInt32 size);
public:
  MY_UNKNOWN_IMP1(IInArchive)
  INTERFACE_IInArchive(;)
};

#define ELF_PT_PHDR 6

bool CHandler::Parse(const Byte *buf, UInt32 size)
{
  if (size < 64)
    return false;
  if (!_header.Parse(buf))
    return false;
  if (_header.ProgOffset > size ||
      _header.ProgOffset + (UInt64)_header.SegmentEntrySize * _header.NumSegments > size ||
      _header.NumSegments > NUM_SCAN_SECTIONS_MAX)
    return false;
  const Byte *p = buf + _header.ProgOffset;
  _totalSize = _header.ProgOffset;
  
  for (int i = 0; i < _header.NumSegments; i++, p += _header.SegmentEntrySize)
  {
    CSegment sect;
    sect.Parse(p, _header.Mode64, _header.Be);
    sect.UpdateTotalSize(_totalSize);
    if (sect.Type != ELF_PT_PHDR)
      _sections.Add(sect);
  }
  UInt64 total2 = _header.SectOffset + (UInt64)_header.SectEntrySize * _header.NumSections;
  if (total2 > _totalSize)
    _totalSize = total2;
  return true;
}

STATPROPSTG kArcProps[] =
{
  { NULL, kpidCpu, VT_BSTR},
  { NULL, kpidBit64, VT_BOOL},
  { NULL, kpidBigEndian, VT_BOOL},
  { NULL, kpidHostOS, VT_BSTR},
  { NULL, kpidCharacts, VT_BSTR},
  { NULL, kpidPhySize, VT_UI8},
  { NULL, kpidHeadersSize, VT_UI8}
 };

STATPROPSTG kProps[] =
{
  { NULL, kpidPath, VT_BSTR},
  { NULL, kpidSize, VT_UI8},
  { NULL, kpidPackSize, VT_UI8},
  { NULL, kpidType, VT_BSTR},
  { NULL, kpidCharacts, VT_BSTR},
  { NULL, kpidOffset, VT_UI8},
  { NULL, kpidVa, VT_UI8}
};

IMP_IInArchive_Props
IMP_IInArchive_ArcProps

STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
{
  COM_TRY_BEGIN
  NCOM::CPropVariant prop;
  switch(propID)
  {
    case kpidPhySize:  prop = _totalSize; break;
    case kpidHeadersSize:  prop = _header.GetHeadersSize(); break;
    case kpidBit64:  if (_header.Mode64) prop = _header.Mode64; break;
    case kpidBigEndian:  if (_header.Be) prop = _header.Be; break;
    case kpidCpu:  PAIR_TO_PROP(g_MachinePairs, _header.Machine, prop); break;
    case kpidHostOS:  PAIR_TO_PROP(g_AbiOS, _header.Os, prop); break;
    case kpidCharacts:  TYPE_TO_PROP(g_Types, _header.Type, prop); break;
  }
  prop.Detach(value);
  return S_OK;
  COM_TRY_END
}

STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
{
  COM_TRY_BEGIN
  NCOM::CPropVariant prop;
  const CSegment &item = _sections[index];
  switch(propID)
  {
    case kpidPath:
    {
      wchar_t sz[32];
      ConvertUInt64ToString(index, sz);
      prop = sz;
      break;
    }
    case kpidSize:  prop = (UInt64)item.VSize; break;
    case kpidPackSize:  prop = (UInt64)item.PSize; break;
    case kpidOffset:  prop = item.Offset; break;
    case kpidVa:  prop = item.Va; break;
    case kpidType:  TYPE_TO_PROP(g_SegnmentTypes, item.Type, prop); break;
    case kpidCharacts:  FLAGS_TO_PROP(g_SegmentFlags, item.Flags, prop); break;
  }
  prop.Detach(value);
  return S_OK;
  COM_TRY_END
}

HRESULT CHandler::Open2(IInStream *stream)
{
  const UInt32 kBufSize = 1 << 18;
  const UInt32 kSigSize = 4;

  CByteBuffer buffer;
  buffer.SetCapacity(kBufSize);
  Byte *buf = buffer;

  size_t processed = kSigSize;
  RINOK(ReadStream_FALSE(stream, buf, processed));
  if (buf[0] != 0x7F || buf[1] != 'E' || buf[2] != 'L' || buf[3] != 'F')
    return S_FALSE;
  processed = kBufSize - kSigSize;
  RINOK(ReadStream(stream, buf + kSigSize, &processed));
  processed += kSigSize;
  if (!Parse(buf, (UInt32)processed))
    return S_FALSE;
  UInt64 fileSize;
  RINOK(stream->Seek(0, STREAM_SEEK_END, &fileSize));
  return (fileSize == _totalSize) ? S_OK : S_FALSE;
}

STDMETHODIMP CHandler::Open(IInStream *inStream,
    const UInt64 * /* maxCheckStartPosition */,
    IArchiveOpenCallback * /* openArchiveCallback */)
{
  COM_TRY_BEGIN
  Close();
  RINOK(Open2(inStream));
  _inStream = inStream;
  return S_OK;
  COM_TRY_END
}

STDMETHODIMP CHandler::Close()
{
  _inStream.Release();
  _sections.Clear();
  return S_OK;
}

STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
{
  *numItems = _sections.Size();
  return S_OK;
}

STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
    Int32 testMode, IArchiveExtractCallback *extractCallback)
{
  COM_TRY_BEGIN
  bool allFilesMode = (numItems == (UInt32)-1);
  if (allFilesMode)
    numItems = _sections.Size();
  if (numItems == 0)
    return S_OK;
  UInt64 totalSize = 0;
  UInt32 i;
  for (i = 0; i < numItems; i++)
    totalSize += _sections[allFilesMode ? i : indices[i]].PSize;
  extractCallback->SetTotal(totalSize);

  UInt64 currentTotalSize = 0;
  UInt64 currentItemSize;
  
  NCompress::CCopyCoder *copyCoderSpec = new NCompress::CCopyCoder();
  CMyComPtr<ICompressCoder> copyCoder = copyCoderSpec;

  CLocalProgress *lps = new CLocalProgress;
  CMyComPtr<ICompressProgressInfo> progress = lps;
  lps->Init(extractCallback, false);

  CLimitedSequentialInStream *streamSpec = new CLimitedSequentialInStream;
  CMyComPtr<ISequentialInStream> inStream(streamSpec);
  streamSpec->SetStream(_inStream);

  for (i = 0; i < numItems; i++, currentTotalSize += currentItemSize)
  {
    lps->InSize = lps->OutSize = currentTotalSize;
    RINOK(lps->SetCur());
    Int32 askMode = testMode ?
        NExtract::NAskMode::kTest :
        NExtract::NAskMode::kExtract;
    UInt32 index = allFilesMode ? i : indices[i];
    const CSegment &item = _sections[index];
    currentItemSize = item.PSize;
    
    CMyComPtr<ISequentialOutStream> outStream;
    RINOK(extractCallback->GetStream(index, &outStream, askMode));
    if (!testMode && !outStream)
      continue;
      
    RINOK(extractCallback->PrepareOperation(askMode));
    RINOK(_inStream->Seek(item.Offset, STREAM_SEEK_SET, NULL));
    streamSpec->Init(currentItemSize);
    RINOK(copyCoder->Code(inStream, outStream, NULL, NULL, progress));
    outStream.Release();
    RINOK(extractCallback->SetOperationResult(copyCoderSpec->TotalSize == currentItemSize ?
        NExtract::NOperationResult::kOK:
        NExtract::NOperationResult::kDataError));
  }
  return S_OK;
  COM_TRY_END
}

static IInArchive *CreateArc() { return new CHandler; }

static CArcInfo g_ArcInfo =
  { L"ELF", L"", 0, 0xDE, { 0 }, 0, false, CreateArc, 0 };

REGISTER_ARC(Elf)

}}
<file_sep>/FingerSuite/Common/atlcedlgs.h
#ifndef __ATLCEDLGS_H__
#define __ATLCEDLGS_H__

#pragma once

#ifndef __cplusplus
   #error ATL requires C++ compilation (use a .cpp suffix)
#endif

#ifndef __ATLDLGS_H__
   #error atlcedlgs.h requires atldlgs.h to be included first
#endif

#ifndef _WIN32_WCE
   #error atlcedlgs.h compiles under Windows CE only
#endif


/////////////////////////////////////////////////////////////////////////////
// Classes in this file
//
// CCePropertyPageImpl
// CCePropertySheet
//

template< class T, class TBase = CPropertySheetWindow >
class ATL_NO_VTABLE CCePropertySheetImpl : public CPropertySheetImpl< T, TBase >
{
public:
   // Construction/Destruction

   CCePropertySheetImpl(ATL::_U_STRINGorID caption = (LPCTSTR) NULL, UINT uStartPage = 0, HWND hWndParent = NULL)
   {
      ::ZeroMemory(&m_psh, sizeof(PROPSHEETHEADER));
      m_psh.dwSize = sizeof(PROPSHEETHEADER);
      m_psh.dwFlags = PSH_USECALLBACK | PSH_MAXIMIZE;
#if (_ATL_VER >= 0x0700)
      m_psh.hInstance = ATL::_AtlBaseModule.GetResourceInstance();
#else //!(_ATL_VER >= 0x0700)
      m_psh.hInstance = _Module.GetResourceInstance();
#endif //!(_ATL_VER >= 0x0700)
      m_psh.phpage = NULL;   // will be set later
      m_psh.nPages = 0;      // will be set later
      m_psh.pszCaption = caption.m_lpstr;
      m_psh.nStartPage = uStartPage;
      m_psh.hwndParent = hWndParent;   // if NULL, will be set in DoModal/Create
      m_psh.pfnCallback = T::PropSheetCallback;
   }
   static int CALLBACK PropSheetCallback(HWND hWnd, UINT uMsg, LPARAM lParam)
   {
      if( uMsg == PSCB_INITIALIZED )
      {
         ATLASSERT(hWnd != NULL);
#if (_ATL_VER >= 0x0700)
         T* pT = (T*) ATL::_AtlWinModule.ExtractCreateWndData();
#else //!(_ATL_VER >= 0x0700)
         T* pT = (T*) _Module.ExtractCreateWndData();
#endif //!(_ATL_VER >= 0x0700)
         // Subclass the sheet window
         pT->SubclassWindow(hWnd);
         // Remove page handles array
         pT->_CleanUpPages();
         // Display empty menubar
         SHMENUBARINFO cbi = { 0 };
         cbi.cbSize = sizeof(SHMENUBARINFO);
         cbi.hwndParent = hWnd;
         cbi.dwFlags = SHCMBF_EMPTYBAR;
         ::SHCreateMenuBar( &cbi );
      }
      else if( uMsg == PSCB_GETVERSION )
      {
         return COMCTL32_VERSION;
      }
      else if( uMsg == PSCB_GETTITLE )
      {
         T::OnGetTitle((LPTSTR)lParam);
      }
      else if( uMsg = PSCB_GETLINKTEXT )
      {
         T::OnGetLinkText((LPTSTR)lParam);
      }
      return 0;
   }
   static void OnGetTitle(LPTSTR pstrTitle)
   {
   }
   static void OnGetLinkText(LPTSTR pstrText)
   {
   }
};

// for non-customized sheets
class CCePropertySheet : public CCePropertySheetImpl<CCePropertySheet>
{
public:
   CCePropertySheet(ATL::_U_STRINGorID caption = (LPCTSTR) NULL, UINT uStartPage = 0, HWND hWndParent = NULL)
      : CCePropertySheetImpl<CCePropertySheet>(caption, uStartPage, hWndParent)
   { 
   }

   BEGIN_MSG_MAP(CCePropertySheet)
      MESSAGE_HANDLER(WM_COMMAND, CCePropertySheetImpl<CCePropertySheet>::OnCommand)
   END_MSG_MAP()
};


#endif // __ATLCEDLGS_H__
<file_sep>/7-Zip/CPP/7zip/Archive/Nsis/NsisHandler.h
// NSisHandler.h

#ifndef __NSIS_HANDLER_H
#define __NSIS_HANDLER_H

#include "Common/MyCom.h"
#include "../IArchive.h"

#include "NsisIn.h"

#include "../../Common/CreateCoder.h"

namespace NArchive {
namespace NNsis {

class CHandler:
  public IInArchive,
  PUBLIC_ISetCompressCodecsInfo
  public CMyUnknownImp
{
  CMyComPtr<IInStream> _inStream;
  CInArchive _archive;

  DECL_EXTERNAL_CODECS_VARS

  bool GetUncompressedSize(int index, UInt32 &size);
  bool GetCompressedSize(int index, UInt32 &size);

  UString GetMethod(bool useItemFilter, UInt32 dictionary) const;
public:
  MY_QUERYINTERFACE_BEGIN2(IInArchive)
  QUERY_ENTRY_ISetCompressCodecsInfo
  MY_QUERYINTERFACE_END
  MY_ADDREF_RELEASE

  INTERFACE_IInArchive(;)

  DECL_ISetCompressCodecsInfo
};

}}

#endif
<file_sep>/7-Zip/CPP/7zip/Compress/PpmdSubAlloc.h
// PpmdSubAlloc.h
// 2009-05-30 : <NAME> : Public domain
// This code is based on <NAME>'s PPMdH code (public domain)

#ifndef __COMPRESS_PPMD_SUB_ALLOC_H
#define __COMPRESS_PPMD_SUB_ALLOC_H

#include "../../../C/Alloc.h"

#include "PpmdType.h"

const UINT N1=4, N2=4, N3=4, N4=(128+3-1*N1-2*N2-3*N3)/4;
const UINT UNIT_SIZE=12, N_INDEXES=N1+N2+N3+N4;

// Extra 1 * UNIT_SIZE for NULL support
// Extra 2 * UNIT_SIZE for s0 in GlueFreeBlocks()
const UInt32 kExtraSize = (UNIT_SIZE * 3);
const UInt32 kMaxMemBlockSize = 0xFFFFFFFF - kExtraSize;

struct MEM_BLK
{
  UInt16 Stamp, NU;
  UInt32 Next, Prev;
  void InsertAt(Byte *Base, UInt32 p)
  {
    Prev = p;
    MEM_BLK *pp = (MEM_BLK *)(Base + p);
    Next = pp->Next;
    pp->Next = ((MEM_BLK *)(Base + Next))->Prev = (UInt32)((Byte *)this - Base);
  }
  void Remove(Byte *Base)
  {
    ((MEM_BLK *)(Base + Prev))->Next = Next;
    ((MEM_BLK *)(Base + Next))->Prev = Prev;
  }
};


class CSubAllocator
{
  UInt32 SubAllocatorSize;
  Byte Indx2Units[N_INDEXES], Units2Indx[128], GlueCount;
  UInt32 FreeList[N_INDEXES];

  Byte *Base;
  Byte *HeapStart, *LoUnit, *HiUnit;
public:
  Byte *pText, *UnitsStart;
  CSubAllocator():
    SubAllocatorSize(0),
    GlueCount(0),
    LoUnit(0),
    HiUnit(0),
    pText(0),
    UnitsStart(0)
  {
    memset(Indx2Units, 0, sizeof(Indx2Units));
    memset(FreeList, 0, sizeof(FreeList));
  }
  ~CSubAllocator()
  {
    StopSubAllocator();
  };

  void *GetPtr(UInt32 offset) const { return (offset == 0) ? 0 : (void *)(Base + offset); }
  void *GetPtrNoCheck(UInt32 offset) const { return (void *)(Base + offset); }
  UInt32 GetOffset(void *ptr) const { return (ptr == 0) ? 0 : (UInt32)((Byte *)ptr - Base); }
  UInt32 GetOffsetNoCheck(void *ptr) const { return (UInt32)((Byte *)ptr - Base); }
  MEM_BLK *GetBlk(UInt32 offset) const { return (MEM_BLK *)(Base + offset); }
  UInt32 *GetNode(UInt32 offset) const { return (UInt32 *)(Base + offset); }

  void InsertNode(void* p, int indx)
  {
    *(UInt32 *)p = FreeList[indx];
    FreeList[indx] = GetOffsetNoCheck(p);
  }

  void* RemoveNode(int indx)
  {
    UInt32 offset = FreeList[indx];
    UInt32 *p = GetNode(offset);
    FreeList[indx] = *p;
    return (void *)p;
  }
  
  UINT U2B(int NU) const { return (UINT)(NU) * UNIT_SIZE; }
  
  void SplitBlock(void* pv, int oldIndx, int newIndx)
  {
    int i, UDiff = Indx2Units[oldIndx] - Indx2Units[newIndx];
    Byte* p = ((Byte*)pv) + U2B(Indx2Units[newIndx]);
    if (Indx2Units[i = Units2Indx[UDiff-1]] != UDiff)
    {
      InsertNode(p, --i);
      p += U2B(i = Indx2Units[i]);
      UDiff -= i;
    }
    InsertNode(p, Units2Indx[UDiff - 1]);
  }
  
  UInt32 GetUsedMemory() const
  {
    UInt32 RetVal = SubAllocatorSize - (UInt32)(HiUnit - LoUnit) - (UInt32)(UnitsStart - pText);
    for (UInt32 i = 0; i < N_INDEXES; i++)
      for (UInt32 pn = FreeList[i]; pn != 0; RetVal -= (UInt32)Indx2Units[i] * UNIT_SIZE)
        pn = *GetNode(pn);
    return (RetVal >> 2);
  }
  
  UInt32 GetSubAllocatorSize() const { return SubAllocatorSize; }

  void StopSubAllocator()
  {
    if (SubAllocatorSize != 0)
    {
      BigFree(Base);
      SubAllocatorSize = 0;
      Base = 0;
    }
  }

  bool StartSubAllocator(UInt32 size)
  {
    if (SubAllocatorSize == size)
      return true;
    StopSubAllocator();
    if (size == 0)
      Base = 0;
    else
    {
      if ((Base = (Byte *)::BigAlloc(size + kExtraSize)) == 0)
        return false;
      HeapStart = Base + UNIT_SIZE; // we need such code to support NULL;
    }
    SubAllocatorSize = size;
    return true;
  }

  void InitSubAllocator()
  {
    int i, k;
    memset(FreeList, 0, sizeof(FreeList));
    HiUnit = (pText = HeapStart) + SubAllocatorSize;
    UINT Diff = UNIT_SIZE * (SubAllocatorSize / 8 / UNIT_SIZE * 7);
    LoUnit = UnitsStart = HiUnit - Diff;
    for (i = 0, k=1; i < N1 ; i++, k += 1)        Indx2Units[i] = (Byte)k;
    for (k++; i < N1 + N2      ;i++, k += 2)      Indx2Units[i] = (Byte)k;
    for (k++; i < N1 + N2 + N3   ;i++,k += 3)     Indx2Units[i] = (Byte)k;
    for (k++; i < N1 + N2 + N3 + N4; i++, k += 4) Indx2Units[i] = (Byte)k;
    GlueCount = 0;
    for (k = i = 0; k < 128; k++)
    {
      i += (Indx2Units[i] < k+1);
        Units2Indx[k] = (Byte)i;
    }
  }
  
  void GlueFreeBlocks()
  {
    UInt32 s0 = (UInt32)(HeapStart + SubAllocatorSize - Base);

    // We need add exta MEM_BLK with Stamp=0
    GetBlk(s0)->Stamp = 0;
    s0 += UNIT_SIZE;
    MEM_BLK *ps0 = GetBlk(s0);

    UInt32 p;
    int i;
    if (LoUnit != HiUnit)
      *LoUnit=0;
    ps0->Next = ps0->Prev = s0;

    for (i = 0; i < N_INDEXES; i++)
      while (FreeList[i] != 0)
      {
        MEM_BLK *pp = (MEM_BLK *)RemoveNode(i);
        pp->InsertAt(Base, s0);
        pp->Stamp = 0xFFFF;
        pp->NU = Indx2Units[i];
      }
    for (p = ps0->Next; p != s0; p = GetBlk(p)->Next)
    {
      for (;;)
      {
        MEM_BLK *pp = GetBlk(p);
        MEM_BLK *pp1 = GetBlk(p + pp->NU * UNIT_SIZE);
        if (pp1->Stamp != 0xFFFF || int(pp->NU) + pp1->NU >= 0x10000)
          break;
        pp1->Remove(Base);
        pp->NU = (UInt16)(pp->NU + pp1->NU);
      }
    }
    while ((p = ps0->Next) != s0)
    {
      MEM_BLK *pp = GetBlk(p);
      pp->Remove(Base);
      int sz;
      for (sz = pp->NU; sz > 128; sz -= 128, p += 128 * UNIT_SIZE)
        InsertNode(Base + p, N_INDEXES - 1);
      if (Indx2Units[i = Units2Indx[sz-1]] != sz)
      {
        int k = sz - Indx2Units[--i];
        InsertNode(Base + p + (sz - k) * UNIT_SIZE, k - 1);
      }
      InsertNode(Base + p, i);
    }
  }
  void* AllocUnitsRare(int indx)
  {
    if ( !GlueCount )
    {
      GlueCount = 255;
      GlueFreeBlocks();
      if (FreeList[indx] != 0)
        return RemoveNode(indx);
    }
    int i = indx;
    do
    {
      if (++i == N_INDEXES)
      {
        GlueCount--;
        i = U2B(Indx2Units[indx]);
        return (UnitsStart - pText > i) ? (UnitsStart -= i) : (NULL);
      }
    } while (FreeList[i] == 0);
    void* RetVal = RemoveNode(i);
    SplitBlock(RetVal, i, indx);
    return RetVal;
  }
  
  void* AllocUnits(int NU)
  {
    int indx = Units2Indx[NU - 1];
    if (FreeList[indx] != 0)
      return RemoveNode(indx);
    void* RetVal = LoUnit;
    LoUnit += U2B(Indx2Units[indx]);
    if (LoUnit <= HiUnit)
      return RetVal;
    LoUnit -= U2B(Indx2Units[indx]);
    return AllocUnitsRare(indx);
  }
  
  void* AllocContext()
  {
    if (HiUnit != LoUnit)
      return (HiUnit -= UNIT_SIZE);
    if (FreeList[0] != 0)
      return RemoveNode(0);
    return AllocUnitsRare(0);
  }
  
  void* ExpandUnits(void* oldPtr, int oldNU)
  {
    int i0=Units2Indx[oldNU - 1], i1=Units2Indx[oldNU - 1 + 1];
    if (i0 == i1)
      return oldPtr;
    void* ptr = AllocUnits(oldNU + 1);
    if (ptr)
    {
      memcpy(ptr, oldPtr, U2B(oldNU));
      InsertNode(oldPtr, i0);
    }
    return ptr;
  }
  
  void* ShrinkUnits(void* oldPtr, int oldNU, int newNU)
  {
    int i0 = Units2Indx[oldNU - 1], i1 = Units2Indx[newNU - 1];
    if (i0 == i1)
      return oldPtr;
    if (FreeList[i1] != 0)
    {
      void* ptr = RemoveNode(i1);
      memcpy(ptr, oldPtr, U2B(newNU));
      InsertNode(oldPtr,i0);
      return ptr;
    }
    else
    {
      SplitBlock(oldPtr, i0, i1);
      return oldPtr;
    }
  }
  
  void FreeUnits(void* ptr, int oldNU)
  {
    InsertNode(ptr, Units2Indx[oldNU - 1]);
  }
};

#endif
<file_sep>/FBReaderJ/src/org/geometerplus/zlibrary/core/txt/ZLTxtReader.java
/*
 * Copyright (C) 2007-2010 <NAME> <<EMAIL>>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 * 02110-1301, USA.
 */

package org.geometerplus.zlibrary.core.txt;

import java.lang.String;

public interface ZLTxtReader {
	public void startDocumentHandler();
	public void endDocumentHandler();
	public void characterDataHandler(String tag);	
	public void startElementHandler();
	public void endElementHandler();
	public void setByteDecoder(String charset);
}
<file_sep>/FBReaderJ/src/org/geometerplus/fbreader/network/NetworkLink.java
/*
 * Copyright (C) 2010 <NAME> <<EMAIL>>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 * 02110-1301, USA.
 */

package org.geometerplus.fbreader.network;

import java.util.*;

import org.geometerplus.zlibrary.core.options.ZLBooleanOption;
import org.geometerplus.zlibrary.core.network.ZLNetworkRequest;

import org.geometerplus.fbreader.network.authentication.NetworkAuthenticationManager;


abstract public class NetworkLink {

	public static final String URL_MAIN = "main";
	public static final String URL_SEARCH = "search";
	public static final String URL_SIGN_IN = "signIn";
	public static final String URL_SIGN_OUT = "signOut";
	public static final String URL_SIGN_UP = "signUp";
	public static final String URL_REFILL_ACCOUNT = "refillAccount";
	public static final String URL_RECOVER_PASSWORD = "<PASSWORD>";

	public final String SiteName;
	public final String Title;
	public final String Summary;
	public final String Icon;
	public final ZLBooleanOption OnOption;
	public final TreeMap<String, String> Links;


	/**
	 * Creates new NetworkLink instance.
	 *
	 * @param siteName   name of the corresponding website. Must be not <code>null</code>.
	 * @param title      title of the corresponding library item. Must be not <code>null</code>.
	 * @param summary    description of the corresponding library item. Can be <code>null</code>.
	 * @param icon       string contains link's icon data/url. Can be <code>null</code>.
	 * @param links      map contains URLs with their identifiers; must always contain one URL with <code>URL_MAIN</code> identifier
	 */
	public NetworkLink(String siteName, String title, String summary, String icon, Map<String, String> links) {
		SiteName = siteName;
		Title = title;
		Summary = summary;
		Icon = icon;
		OnOption = new ZLBooleanOption(SiteName, "on", true);
		Links = new TreeMap(links);
	}

	public abstract ZLNetworkRequest simpleSearchRequest(String pattern, NetworkOperationData data);
	public abstract ZLNetworkRequest resume(NetworkOperationData data);

	public abstract NetworkLibraryItem libraryItem();
	public abstract NetworkAuthenticationManager authenticationManager();

	public abstract String rewriteUrl(String url, boolean isUrlExternal);
}
<file_sep>/FingerSuite/FingerNotification/resource.h
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by FingerNotification.rc
//
#define IDS_LVK_EXIT                    98
#define IDS_RVK_MENU                    99
#define IDS_NO_NEW_NOTIFICATIONS        102
#define IDS_VOLUME                      103
#define IDS_BATTERY                     104
#define IDR_MAINFRAME                   128
#define IDR_SOFTKEYMENU                 201
#define IDM_SOFTKEYMENU                 201
#define IDI_VOLUME_VIBRATE              202
#define IDI_VOLUME_OFF                  203
#define IDI_VOLUME_ON                   204
#define IDI_BATTERY_ABSENT              205
#define IDI_BATTERY_CHARGING            206
#define IDI_BATTERY_CRITICAL            208
#define IDI_BATTERY_1                   209
#define IDI_BATTERY_2                   210
#define IDI_BATTERY_3                   211
#define IDI_BATTERY_4                   212
#define IDI_BATTERY_5                   213
#define IDI_ICON6                       219
#define IDI_ICON10                      223
#define IDI_SIGNAL_4                    226
#define IDI_CONN_E                      227
#define IDI_CONN_G                      228
#define IDI_CONN_H                      229
#define IDI_INCALL                      230
#define IDI_NO_SERVICE                  231
#define IDI_OFF                         232
#define IDI_PHONE                       233
#define IDI_SEARCHING                   234
#define IDI_SIGNAL_1                    235
#define IDI_SIGNAL_2                    236
#define IDI_SIGNAL_3                    237
#define IDI_ICON1                       238
#define IDI_CONN_3G                     238
#define IDM_BTN1                        32772
#define IDM_BTN2                        32773

#define ID_MENU_SHOWORIGINAL            40003
#define ID_MENU_ABOUT                   40004
#define ID_MENU_EXIT                    40006

// Next default values for new objects
// 
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE        239
#define _APS_NEXT_COMMAND_VALUE         32774
#define _APS_NEXT_CONTROL_VALUE         1000
#define _APS_NEXT_SYMED_VALUE           101
#endif
#endif
<file_sep>/SQLCEHelper/Source/ForeignKey.cpp

#include "stdafx.h"

using namespace OLEDBCLI;


//-------------------------------------------------------------------------
//
//	CForeignKey - table foreign key schema
//
//-------------------------------------------------------------------------


CForeignKey::CForeignKey(DBCONSTRAINTDESC* pConstraintDesc)
{
	ULONG	i;

	ATLASSERT(pConstraintDesc != NULL);
	ATLASSERT(pConstraintDesc->ConstraintType == DBCONSTRAINTTYPE_FOREIGNKEY);
	ATLASSERT(pConstraintDesc->cColumns == pConstraintDesc->cForeignKeyColumns);

	m_strName		= pConstraintDesc->pConstraintID->uName.pwszName;
	m_strRefTable	= pConstraintDesc->pReferencedTableID->uName.pwszName;
	m_match			= pConstraintDesc->MatchType;
	m_deleteRule	= pConstraintDesc->DeleteRule;
	m_updateRule	= pConstraintDesc->UpdateRule;
	m_deferrability	= pConstraintDesc->Deferrability;

	for(i = 0; i < pConstraintDesc->cColumns; ++i)
	{
		LPCTSTR				pszRefColumn	= pConstraintDesc->rgColumnList[i].uName.pwszName,
							pszKeyColumn	= pConstraintDesc->rgForeignKeyColumnList[i].uName.pwszName;
		CForeignKeyPair*	pPair			= new CForeignKeyPair(pszRefColumn, pszKeyColumn);

		if(pPair != NULL)
			m_pairs.Add(pPair);
	}
}


CForeignKey::~CForeignKey()
{
	Clear();
}


void CForeignKey::Clear()
{
	size_t	i, n = m_pairs.GetCount();

	for(i = 0; i < n; ++i)
		delete m_pairs[i];
	m_pairs.RemoveAll();
}
<file_sep>/SQLCEHelper/Source/Rowset.cpp

#include "stdafx.h"
#include "Currency.h"

using namespace OLEDBCLI;


CRowset::CRowset()
:	m_pRowset			(NULL),
	m_pRowsetChange		(NULL),
	m_pRowsetUpdate		(NULL),
	m_pRowsetIndex		(NULL),
	m_pColAccessor		(NULL),
	m_pKeyAccessor		(NULL),
	m_hRow				(NULL),
	m_nColumns			(0),
	m_nKeyColumns		(0),
	m_nAccessors		(0),
	m_nRowSize			(0),
	m_nKeySize			(0),
	m_pBoundColumn		(NULL),
	m_pBoundKey			(NULL),
	m_pColumnNames		(NULL),
	m_phAccessor		(NULL),
	m_hKeyAccessor		(NULL),
	m_pBuffer			(NULL),
	m_pKeyBuffer		(NULL),
	m_pBindStatus		(NULL),
	m_bCustomBound		(false),
	m_pValueRef			(NULL),
	m_pKeyRef			(NULL)
{
}


CRowset::~CRowset()
{
	Close();
}


// CRowset::GetBlobCount
//
//		Counts the number of BLOB columns in the rowset.
//		This is required in order to know the number of accessor to allocate.
//
ULONG CRowset::GetBlobCount(DBCOLUMNINFO* pColumnInfo, ULONG nColumns)
{
	ULONG	nBlobs	= 0,
			iCol;

	for(iCol = 0; iCol < nColumns; ++iCol)
	{
		bool bIsBlob = (pColumnInfo[iCol].dwFlags & DBCOLUMNFLAGS_ISLONG) != 0;

		if(bIsBlob)
			++nBlobs;
	}
	return nBlobs;
}

DBCOLUMNINFO* CRowset::GetTableColumnInfo(LPCTSTR pszColumnName, DBCOLUMNINFO* pColumnInfo)
{
	DBCOLUMNINFO* pColInfo = pColumnInfo;

	if(!pColumnInfo)
		return NULL;

	for(ULONG iCol = 0; iCol< m_nColumns; ++iCol, ++pColInfo)
	{
		if(NULL != pColInfo->pwszName)
		{
			if(0 == _wcsicmp(pColInfo->pwszName, pszColumnName))
				return pColInfo;
		}
	}
	return NULL;
}



// CRowset::BindKeyColumns
//
//		Binds the key columns, if any
//
HRESULT CRowset::BindKeyColumns(DBCOLUMNINFO* pColumnInfo)
{
	HRESULT				hr;
	ULONG				nPropSet	= 0;
	DBPROPSET*			pPropSet	= NULL;
	ULONG				i;
	DBINDEXCOLUMNDESC*	pKeyColumnDesc;

	hr = m_pRowsetIndex->GetIndexInfo(&m_nKeyColumns,		// Number of index columns
									  &pKeyColumnDesc,		// Names of columns
									  &nPropSet,			// Don't care
									  &pPropSet);			// Don't care
	if(SUCCEEDED(hr))
	{
		CBindingArray	binding;
		DBBINDING*		pBinding		= NULL;

		m_pBoundKey = new BOUNDCOLUMN[m_nKeyColumns];

		if(binding.Allocate(m_nKeyColumns) && m_pBoundKey != NULL)
		{
			DWORD			dwOffset	= 0;
			BOUNDCOLUMN*	pBoundKey	= m_pBoundKey;

			memset(m_pBoundKey, 0, m_nKeyColumns * sizeof(BOUNDCOLUMN));

			m_nKeySize	= 0;
			pBinding	= binding[0];
			for(i = 0; i < m_nKeyColumns; ++i, ++pBinding, ++pBoundKey)
			{
				DBCOLUMNINFO*	pColInfo;

				pColInfo = GetTableColumnInfo(pKeyColumnDesc[i].pColumnID->uName.pwszName, pColumnInfo);

				pBinding->iOrdinal		= pColInfo->iOrdinal;
				pBinding->dwPart		= DBPART_VALUE | DBPART_STATUS | DBPART_LENGTH;
				pBinding->obLength		= dwOffset;                                     
				pBinding->obStatus		= AddOffset(pBinding->obLength, sizeof(ULONG));
				pBinding->obValue		= AddOffset(pBinding->obStatus, sizeof(DBSTATUS));
				pBinding->pObject		= NULL;
				pBinding->pBindExt		= NULL;
				pBinding->pTypeInfo		= NULL;
				pBinding->dwMemOwner	= DBMEMOWNER_CLIENTOWNED;
				pBinding->dwFlags		= 0;
				pBinding->wType			= pColInfo->wType;
				pBinding->bPrecision	= pColInfo->bPrecision;
				pBinding->bScale		= pColInfo->bScale;

				switch(pBinding->wType)
				{
				case DBTYPE_WSTR:		
					pBinding->cbMaxLen = sizeof(WCHAR)*(pColInfo->ulColumnSize + 1);	// Extra buffer for null terminator 
					break;

				default:
					pBinding->cbMaxLen = pColInfo->ulColumnSize; 
					break;
				}

				dwOffset = AddOffset(pBinding->obValue, pBinding->cbMaxLen);
	
				pBoundKey->bPrecision	= pBinding->bPrecision;
				pBoundKey->bScale		= pBinding->bScale;
				pBoundKey->dwFlags		= pColumnInfo->dwFlags;
				pBoundKey->iAccessor	= 0;
				pBoundKey->iOrdinal		= i + 1;//pBinding->iOrdinal;
				pBoundKey->obLength		= pBinding->obLength;
				pBoundKey->obStatus		= pBinding->obStatus;
				pBoundKey->obValue		= pBinding->obValue;
				pBoundKey->pwszName		= pColumnInfo->pwszName;
				pBoundKey->ulColumnSize	= pBinding->cbMaxLen;
				pBoundKey->wType		= pColInfo->wType;
			}

			// Allocate the key buffer
			m_pKeyBuffer = new BYTE[dwOffset * 2];
			if(m_pKeyBuffer != NULL)
			{
				m_nKeySize = dwOffset;

				// Allocate the CDbValueRef array
				m_pKeyRef = new CDbValueRef[m_nKeyColumns];
				if(m_pKeyRef != NULL)
				{
					ULONG iCol;

					// Assign all value refs
					for(iCol = 0; iCol < m_nKeyColumns; ++iCol)
					{
						pBoundKey = m_pBoundKey + iCol;

						m_pKeyRef[iCol] = CDbValueRef(pBoundKey, m_pKeyBuffer);
					}

					hr = m_pRowsetIndex->QueryInterface(IID_IAccessor, (void**)&m_pKeyAccessor);
					if(SUCCEEDED(hr))
					{
						hr = m_pKeyAccessor->CreateAccessor(DBACCESSOR_ROWDATA, m_nKeyColumns, binding[0], dwOffset * 2, &m_hKeyAccessor, NULL);
					}
				}
				else
					hr = E_OUTOFMEMORY;
			}
			else
				hr = E_OUTOFMEMORY;
		}
		else
			hr = E_OUTOFMEMORY;
	}

	//
	// Free the provider-allocated memory
	//
	if(pPropSet != NULL)
	{
		for(i = 0; i < nPropSet; ++i)
		{
			ULONG	iProp;

			for(iProp = 0; iProp < pPropSet[i].cProperties; ++iProp)
				VariantClear(&pPropSet[i].rgProperties[iProp].vValue);

			CoTaskMemFree(pPropSet[i].rgProperties);
		}
		CoTaskMemFree(pPropSet);
	}

	if(pKeyColumnDesc != NULL)
		CDbMemory::Free(pKeyColumnDesc, m_nKeyColumns);

	return hr;
}



// CRowset::Open
//
//		Opens the rowset using an existing IRowset pointer
//
HRESULT CRowset::Open(IRowset* pRowset)
{
	HRESULT					hr;
	CComPtr<IColumnsInfo>	spColumnsInfo;		// Automatically deleted at the end of the method
	ULONG					iCol,
							iAcc			= 0,
							nBlobs			= 0;
	BOUNDCOLUMN*			pBoundColumn	= NULL;
	DBCOLUMNINFO*			pColumnInfo		= NULL;
	DBBINDING*				pBinding		= NULL;
	DBBINDSTATUS*			pBindStatus		= NULL;
	ULONG					iBinding		= 0;
	CBindingArray			binding;
	CAtlArray<DBCOLUMNINFO>	columnInfo;

	Close();

	m_pRowset = pRowset;

	// Query for additional interfaces
	hr = m_pRowset->QueryInterface(IID_IRowsetChange, (void**)&m_pRowsetChange);
	if(FAILED(hr))
		m_pRowsetChange = NULL;
	hr = m_pRowset->QueryInterface(IID_IRowsetUpdate, (void**)&m_pRowsetUpdate);
	if(FAILED(hr))
		m_pRowsetUpdate = NULL;
	hr = m_pRowset->QueryInterface(IID_IRowsetIndex, (void**)&m_pRowsetIndex);
	if(FAILED(hr))
		m_pRowsetIndex = NULL;

	// Get the associated IColumnsInfo interface
	hr = m_pRowset->QueryInterface(IID_IColumnsInfo, (void**)&spColumnsInfo);
	if(FAILED(hr))
		return hr;

	// Get the the table's column names.
	// Note that the first column (iOrdinal = 0) is the bookmark - it has no name!
	hr = spColumnsInfo->GetColumnInfo(&m_nColumns, &pColumnInfo, &m_pColumnNames);
	if(FAILED(hr))
		return hr;

	// Copy the DBCOLUMNINFO array to our safe array
	if(!columnInfo.SetCount(m_nColumns))
	{
		CoTaskMemFree(pColumnInfo);
		return E_OUTOFMEMORY;
	}
	memcpy(columnInfo.GetData(), pColumnInfo, m_nColumns * sizeof(DBCOLUMNINFO));
	// Get the number of blob columns in the rowset.
	nBlobs = GetBlobCount(pColumnInfo, m_nColumns);
	CoTaskMemFree(pColumnInfo);

	// Allocate the bound columns array
	m_pBoundColumn = new BOUNDCOLUMN[m_nColumns];
	if(m_pBoundColumn == NULL)
		return E_OUTOFMEMORY;
	memset(m_pBoundColumn, 0, m_nColumns * sizeof(BOUNDCOLUMN));

	// Start the binding process by allocating the binding array
	if(!binding.Allocate(m_nColumns))
		return E_OUTOFMEMORY;

	m_nAccessors	= nBlobs + 1;
	m_nRowSize		= 0;		
	pBinding		= binding[0];
	pColumnInfo		= columnInfo.GetData();

	// Fill the binding array for the non-BLOB columns
	// All of these columns will be bound by the accessor handle at index zero
	for(iCol = 0; iCol < m_nColumns; ++iCol, ++pColumnInfo)
	{
		ULONG	nColumnSize = pColumnInfo->ulColumnSize;
		DBTYPE	wType		= pColumnInfo->wType;
		bool	bIsBlob		= (pColumnInfo->dwFlags & DBCOLUMNFLAGS_ISLONG) != 0;

		// Skip this column if it is a BLOB
		if(bIsBlob)
			continue;

		if(wType == DBTYPE_STR)
			++nColumnSize;		// Add the NULL terminator

		// If this is a UNICODE string, correct the size and allow for the NULL terminator
		if(wType == DBTYPE_WSTR)
			nColumnSize = (nColumnSize + 1) * sizeof(wchar_t);

		pBinding->iOrdinal		= pColumnInfo->iOrdinal;
		pBinding->wType			= wType;
		pBinding->bPrecision	= pColumnInfo->bPrecision;
		pBinding->bScale		= pColumnInfo->bScale;
		pBinding->dwPart		= DBPART_VALUE | DBPART_LENGTH | DBPART_STATUS;
		pBinding->dwMemOwner	= DBMEMOWNER_CLIENTOWNED;
		pBinding->cbMaxLen		= nColumnSize;

		pBinding->obLength		= m_nRowSize;
		m_nRowSize				= AddOffset(m_nRowSize, sizeof(ULONG));
		pBinding->obStatus		= m_nRowSize;
		m_nRowSize				= AddOffset(m_nRowSize, sizeof(ULONG));
		pBinding->obValue		= m_nRowSize;
		m_nRowSize				= AddOffset(m_nRowSize, nColumnSize);

		// Set the bound column info
		pBoundColumn = m_pBoundColumn + iCol;

		pBoundColumn->bPrecision	= pBinding->bPrecision;
		pBoundColumn->bScale		= pBinding->bScale;
		pBoundColumn->dwFlags		= pColumnInfo->dwFlags;
		pBoundColumn->iAccessor		= 0;
		pBoundColumn->iOrdinal		= pBinding->iOrdinal;
		pBoundColumn->obLength		= pBinding->obLength;
		pBoundColumn->obStatus		= pBinding->obStatus;
		pBoundColumn->obValue		= pBinding->obValue;
		pBoundColumn->pwszName		= pColumnInfo->pwszName;
		pBoundColumn->ulColumnSize	= nColumnSize;
		pBoundColumn->wType			= wType;

		++pBinding;
	}

	// Fill the binding array for the BLOB columns
	// Each column will be bound using its own accessor handle wich is stored in the accessor handle array.
	int iAccessor = 1;
	pColumnInfo	= columnInfo.GetData();
	for(iCol = 0; (m_nAccessors > 1) && (iCol < m_nColumns); ++iCol, ++pColumnInfo)
	{
		ULONG		nColumnSize = pColumnInfo->ulColumnSize;
		DBTYPE		wType		= pColumnInfo->wType;
		bool		bIsBlob		= (pColumnInfo->dwFlags & DBCOLUMNFLAGS_ISLONG) != 0;
		DBOBJECT*	pDbObject;

		// Skip this column if it is NOT a BLOB
		if(!bIsBlob)
			continue;

		// Allocate the DBOBJECT - this will be released by the Close method
		pDbObject = new DBOBJECT;
		if(pDbObject == NULL)
		{
			Close();
			return E_OUTOFMEMORY;
		}

		pDbObject->dwFlags	= STGM_READ;			// Check if this is enough
		pDbObject->iid		= IID_ISequentialStream;

		nColumnSize			= sizeof(IUnknown*);

		pBinding->iOrdinal		= pColumnInfo->iOrdinal;
		pBinding->wType			= DBTYPE_IUNKNOWN;
		pBinding->bPrecision	= 0;
		pBinding->bScale		= 0;
		pBinding->dwPart		= DBPART_VALUE | DBPART_LENGTH | DBPART_STATUS;
		pBinding->dwMemOwner	= DBMEMOWNER_CLIENTOWNED;
		pBinding->cbMaxLen		= nColumnSize;
		pBinding->pObject		= pDbObject;

		pBinding->obLength		= m_nRowSize;
		m_nRowSize				= AddOffset(m_nRowSize, sizeof(ULONG));
		pBinding->obStatus		= m_nRowSize;
		m_nRowSize				= AddOffset(m_nRowSize, sizeof(ULONG));
		pBinding->obValue		= m_nRowSize;
		m_nRowSize				= AddOffset(m_nRowSize, nColumnSize);

		// Set the bound column info
		pBoundColumn = m_pBoundColumn + iCol;

		pBoundColumn->bPrecision	= pBinding->bPrecision;
		pBoundColumn->bScale		= pBinding->bScale;
		pBoundColumn->dwFlags		= pColumnInfo->dwFlags;
		pBoundColumn->iAccessor		= iAccessor++;
		pBoundColumn->iOrdinal		= pBinding->iOrdinal;
		pBoundColumn->obLength		= pBinding->obLength;
		pBoundColumn->obStatus		= pBinding->obStatus;
		pBoundColumn->obValue		= pBinding->obValue;
		pBoundColumn->pwszName		= pColumnInfo->pwszName;
		pBoundColumn->ulColumnSize	= nColumnSize;
		pBoundColumn->wType			= wType;

		++pBinding;
	}

	// Allocate the data buffer
	m_pBuffer = new BYTE[m_nRowSize];
	if(m_pBuffer == NULL)
		return E_OUTOFMEMORY;
	memset(m_pBuffer, 0, m_nRowSize);

	// Allocate the DBBINDSTATUS array. We own this memory.
	m_pBindStatus = new DBBINDSTATUS[m_nColumns];
	if(m_pBindStatus == NULL)
		return E_OUTOFMEMORY;

	// Allocate the CDbValueRef array
	m_pValueRef = new CDbValueRef[m_nColumns];
	if(m_pValueRef == NULL)
		return E_OUTOFMEMORY;

	// Assign all value refs
	for(iCol = 0; iCol < m_nColumns; ++iCol)
	{
		pBoundColumn = m_pBoundColumn + iCol;

		m_pValueRef[iCol] = CDbValueRef(pBoundColumn, m_pBuffer);
	}

	// Get the IAccessor interface
	hr = m_pRowset->QueryInterface(IID_IAccessor, (void**)&m_pColAccessor);
	if(FAILED(hr))
		return hr;

	// Allocate the accessor handle array
	m_phAccessor = new HACCESSOR[m_nAccessors];
	if(m_phAccessor == NULL)
		return E_OUTOFMEMORY;

	// Bind the non-BLOB data first
	hr = m_pColAccessor->CreateAccessor(DBACCESSOR_ROWDATA, 
										m_nColumns - nBlobs, 
										binding[0], 
										m_nRowSize, 
										&m_phAccessor[0], 
										m_pBindStatus);
	if(FAILED(hr))
		return hr;

	ULONG nBlobBindSize = AddOffset(sizeof(IUnknown*), AddOffset(sizeof(ULONG), sizeof(ULONG)));

	iAccessor	= 1;
	pBinding	= binding[0]	+ m_nColumns - nBlobs;
	pBindStatus	= m_pBindStatus + m_nColumns - nBlobs;

	for(iCol = 0; SUCCEEDED(hr) && (iCol < nBlobs); ++iCol)
	{
		hr = m_pColAccessor->CreateAccessor(DBACCESSOR_ROWDATA, 
											1, 
											pBinding, 
											nBlobBindSize, 
											&m_phAccessor[iAccessor], 
											pBindStatus);

		++pBinding;
		++iAccessor;
		++pBindStatus;
	}

	// Finally, bind the key columns
	if(m_pRowsetIndex != NULL)
		hr = BindKeyColumns(columnInfo.GetData());

	return hr;
}


// CRowset::Close
//
//		Closes a rowset
//
void CRowset::Close()
{
	ULONG	i;

	ReleaseRow();

	if(m_pColAccessor != NULL)
	{
		if(m_phAccessor != NULL)
		{
			for(i = 0; i < m_nAccessors; ++i)
			{
				m_pColAccessor->ReleaseAccessor(m_phAccessor[i], NULL);
				m_phAccessor[i] = NULL;
			}
		}
		delete [] m_phAccessor;
		m_phAccessor = NULL;

		m_pColAccessor->Release();
		m_pColAccessor = NULL;
	}

	if(m_pKeyAccessor != NULL)
	{
		m_pKeyAccessor->ReleaseAccessor(m_hKeyAccessor, NULL);
		m_pKeyAccessor->Release();
		m_pKeyAccessor = NULL;
	}

	// Release the BOUNDCOLUMN arrays
	if(m_pBoundColumn != NULL)
	{
		delete [] m_pBoundColumn;
		m_pBoundColumn = NULL;
	}
	if(m_pBoundKey != NULL)
	{
		delete [] m_pBoundKey;
		m_pBoundKey = NULL;
	}

	if(m_pRowset != NULL)
	{
		m_pRowset->Release();
		m_pRowset = NULL;
	}

	if(m_pRowsetChange != NULL)
	{
		m_pRowsetChange->Release();
		m_pRowsetChange = NULL;
	}

	if(m_pRowsetUpdate != NULL)
	{
		m_pRowsetUpdate->Release();
		m_pRowsetUpdate = NULL;
	}

	if(m_pRowsetIndex != NULL)
	{
		m_pRowsetIndex->Release();
		m_pRowsetIndex = NULL;
	}

	if(m_pColumnNames != NULL)
	{
		CoTaskMemFree(m_pColumnNames);
		m_pColumnNames = NULL;
	}
	m_nColumns = 0;

	// Free the data buffer
	delete [] m_pBuffer;
	delete [] m_pKeyBuffer;
	delete [] m_pBindStatus;
	delete [] m_pValueRef;
	delete [] m_pKeyRef;
	m_pBuffer		= NULL;
	m_pKeyBuffer	= NULL;
	m_pBindStatus	= NULL;
	m_pValueRef		= NULL;
	m_pKeyRef		= NULL;
	m_nRowSize		= 0;
}


// CRowset::ReleaseRow
//
//		Releases the acquired row, if any
//
HRESULT CRowset::ReleaseRow()
{
	HRESULT	hr = S_OK;

	if(m_hRow != NULL && m_pRowset != NULL)
	{
		hr = m_pRowset->ReleaseRows(1, &m_hRow, NULL, NULL, NULL);
		if(SUCCEEDED(hr))
			m_hRow = NULL;
	}

	return hr;
}


// CRowset::MoveFirst
//
//		Moves to the first row in the rowset
//
HRESULT CRowset::MoveFirst()
{
	HRESULT	hr;

	ReleaseRow();
	hr = m_pRowset->RestartPosition(DB_NULL_HCHAPTER);
	if(FAILED(hr))
		return hr;
	return MoveNext();
}


// CRowset::MoveRelative
//
//		Moves the rowset position relative to the current position
//		Reads the next row
//
HRESULT CRowset::MoveRelative(LONG nOffset)
{
	HRESULT	hr;
	ULONG	nRows;
	HROW*	pRow = &m_hRow;

	ReleaseRow();

	hr = m_pRowset->GetNextRows(DB_NULL_HCHAPTER, nOffset - 1, 1, &nRows, &pRow);
	if(FAILED(hr))
		return hr;

	// Fetch the row
	hr = m_pRowset->GetData(m_hRow, m_phAccessor[0], m_pBuffer);
	return hr;
}


// CRowset::MoveToBookmark
//
//		Moves the rowset pointer to the given bookmark
//
HRESULT CRowset::MoveToBookmark(ULONG cbBookmark, const BYTE *pBookmark)
{
	HRESULT						hr;
	CComPtr<IRowsetBookmark>	spRowsetBookmark;

	hr = m_pRowset->QueryInterface(IID_IRowsetBookmark,(void**)&spRowsetBookmark);
	if(FAILED(hr))
		return hr;

	ReleaseRow();
	hr = spRowsetBookmark->PositionOnBookmark(DB_NULL_HCHAPTER, cbBookmark, pBookmark);
	if(FAILED(hr))
		return hr;

	// Move and read the row
	hr = MoveNext();

	return hr;
}


// CRowset::GetRowCount
//
//		Counts all the rows in the rowset by scrolling through all of them.
//
HRESULT CRowset::GetRowCount(ULONG *pcRows)
{
	HRESULT	hr;
	ULONG	nRows,
			nRowCount	= 0;
	HROW*	pRow		= &m_hRow;

	ReleaseRow();
	hr = m_pRowset->RestartPosition(DB_NULL_HCHAPTER);
	while(hr == S_OK)
	{
		hr = m_pRowset->GetNextRows(DB_NULL_HCHAPTER, 0, 1, &nRows, &pRow);
		if(hr == S_OK)
		{
			++nRowCount;
			ReleaseRow();
		}
	}

	if(SUCCEEDED(hr))
		*pcRows = nRowCount;

	return hr;
}


HRESULT CRowset::Update()
{
	DBROWSTATUS*	pRowStatus;
	HRESULT			hr;

	if(m_pRowsetUpdate == NULL)
		return E_NOINTERFACE;

	hr = m_pRowsetUpdate->Update(DB_NULL_HCHAPTER, 1, &m_hRow, NULL, NULL, &pRowStatus);
	if(SUCCEEDED(hr))
		CoTaskMemFree(pRowStatus);
	return hr;
}


HRESULT CRowset::Undo()
{
	DBROWSTATUS*	pRowStatus;
	HRESULT			hr;

	if(m_pRowsetUpdate == NULL)
		return E_NOINTERFACE;

	hr = m_pRowsetUpdate->Undo(DB_NULL_HCHAPTER, 1, &m_hRow, NULL, NULL, &pRowStatus);
	if(SUCCEEDED(hr))
		CoTaskMemFree(pRowStatus);
	return hr;
}


// CRowset::Insert
//
//		Inserts the current row
//
HRESULT CRowset::Insert()
{
	HRESULT	hr;

	if(m_pRowsetChange == NULL)
		return E_NOINTERFACE;

	ReleaseRow();
	hr = m_pRowsetChange->InsertRow(DB_NULL_HCHAPTER, m_phAccessor[0], m_pBuffer, &m_hRow);

	// Check for delayed update mode
	if(m_pRowsetUpdate != NULL && SUCCEEDED(hr))
	{
		ULONG i;

		// Set the data for all accessors (BLOBs)
		for(i = 1; SUCCEEDED(hr) && (i < m_nAccessors); ++i)
			hr = m_pRowsetChange->SetData(m_hRow, m_phAccessor[i], m_pBuffer);

		if(SUCCEEDED(hr))
			hr = Update();
		else
			Undo();
	}

	return hr;
}


// CRowset::Delete
//
//		Deletes the current row
//
HRESULT CRowset::Delete()
{
	HRESULT		hr;
	DBROWSTATUS	rowStatus	= 0;

	if(m_pRowsetChange == NULL)
		return E_NOINTERFACE;

	// Delete the rows
	hr = m_pRowsetChange->DeleteRows(DB_NULL_HCHAPTER, 1, &m_hRow, &rowStatus);

	// Check for delayed update mode
	if(m_pRowsetUpdate != NULL)
	{
		if(SUCCEEDED(hr))
			hr = Update();
		else
			Undo();
	}

	return hr;
}


// CRowset::SetData
//
//		Sets the current row data
//
HRESULT CRowset::SetData()
{
	HRESULT		hr	= S_OK;
	ULONG		i;

	if(m_pRowsetChange == NULL)
		return E_NOINTERFACE;

	for(i = 0; SUCCEEDED(hr) && (i < m_nAccessors); ++i)
		hr = m_pRowsetChange->SetData(m_hRow, m_phAccessor[i], m_pBuffer);

	// Check for delayed update mode
	if(m_pRowsetUpdate != NULL)
	{
		if(SUCCEEDED(hr))
			hr = Update();
		else
			Undo();
	}

	return hr;
}

/*
ULONG CRowset::GetColumnIndex(LPCTSTR pszColumnName)
{
	return 0;
}
*/


// CRowset::GetColumnIndex
//
//		Returns a column index given the column ordinal
//
ULONG CRowset::GetColumnIndex(ULONG iOrdinal)
{
	if(m_bCustomBound)
	{
		BOUNDCOLUMN*	pBoundColumn = m_pBoundColumn;
		ULONG			iCol;

		for(iCol = 0; iCol < m_nColumns; ++iCol, ++pBoundColumn)
		{
			if(pBoundColumn->iOrdinal == iOrdinal)
				return iCol;
		}
	}
	else
	{
		if(HasBookmark())
			return iOrdinal;
		return iOrdinal - 1;
	}
	return (ULONG)-1;
}


// CRowset::SeekRow
//
//		Seeks the previously set key values - does NOT retrieve data from the row.
//
HRESULT CRowset::SeekRow(int cKeyValues, DBSEEK dwSeekOptions)
{
	HRESULT	hr	= E_NOINTERFACE;

	if(m_pRowsetIndex != NULL)
	{
		ReleaseRow();
		hr = m_pRowsetIndex->Seek(m_hKeyAccessor, 
								  m_nKeyColumns, 
								  m_pKeyBuffer,
								  dwSeekOptions);

		if(hr == S_OK)
		{
			ULONG ulRowsFetched = 0;

			// Release a row if one is already around
			//ReleaseRows();

			// Get the row handle
			HROW* phRow = &m_hRow;
			hr = m_pRowset->GetNextRows(NULL, 0, 1, &ulRowsFetched, &phRow);
		}
	}

	return hr;
}


// CRowset::Seek
//
//		Seeks the previously set key values and retrieve data from the row, if found.
//
HRESULT CRowset::Seek(int cKeyValues, DBSEEK dwSeekOptions)
{
	HRESULT hr = SeekRow(cKeyValues, dwSeekOptions);
	if(hr == S_OK)
		hr = m_pRowset->GetData(m_hRow, m_phAccessor[0], m_pBuffer);
	return hr;
}<file_sep>/7-Zip/CPP/7zip/Compress/PpmdEncoder.h
// PpmdEncoder.h
// 2009-05-30 : <NAME> : Public domain

#ifndef __COMPRESS_PPMD_ENCODER_H
#define __COMPRESS_PPMD_ENCODER_H

#include "../../Common/MyCom.h"

#include "../ICoder.h"

#include "../Common/InBuffer.h"

#include "PpmdEncode.h"
#include "RangeCoder.h"

namespace NCompress {
namespace NPpmd {

class CEncoder :
  public ICompressCoder,
  public ICompressSetCoderProperties,
  public ICompressWriteCoderProperties,
  public CMyUnknownImp
{
public:
  CInBuffer _inStream;

  NRangeCoder::CEncoder _rangeEncoder;

  CEncodeInfo _info;
  UInt32 _usedMemorySize;
  Byte _order;

  HRESULT Flush()
  {
    _rangeEncoder.FlushData();
    return _rangeEncoder.FlushStream();
  }

  void ReleaseStreams()
  {
    _inStream.ReleaseStream();
    _rangeEncoder.ReleaseStream();
  }

  HRESULT CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
      const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);

  class CEncoderFlusher
  {
    CEncoder *_encoder;
  public:
    CEncoderFlusher(CEncoder *encoder): _encoder(encoder) {}
    ~CEncoderFlusher()
    {
      _encoder->Flush();
      _encoder->ReleaseStreams();
    }
  };

public:

  MY_UNKNOWN_IMP2(
      ICompressSetCoderProperties,
      ICompressWriteCoderProperties)

  STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
      const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);

  STDMETHOD(SetCoderProperties)(const PROPID *propIDs, const PROPVARIANT *props, UInt32 numProps);

  STDMETHOD(WriteCoderProperties)(ISequentialOutStream *outStream);

  CEncoder();
};

}}

#endif
<file_sep>/7-Zip/CPP/7zip/Archive/Wim/WimRegister.cpp
// WimRegister.cpp

#include "StdAfx.h"

#include "../../Common/RegisterArc.h"

#include "WimHandler.h"
static IInArchive *CreateArc() { return new NArchive::NWim::CHandler; }

static CArcInfo g_ArcInfo =
  { L"Wim", L"wim swm", 0, 0xE6, { 'M', 'S', 'W', 'I', 'M', 0, 0, 0 }, 8, false, CreateArc, 0 };

REGISTER_ARC(Wim)
<file_sep>/SQLCEHelper/Source/Command.cpp

#include "stdafx.h"

using namespace OLEDBCLI;


// CCommand::CCommand
//
//		Constructor - builds the CCommand from the CSession object
//
CCommand::CCommand(OLEDBCLI::CSession &session)
:	m_pCommand		(NULL),
	m_nParams		(0),
	m_pszParamNames	(NULL),
	m_pBoundParam	(NULL),
	m_pBuffer		(NULL),
	m_nRowSize		(0),
	m_pBindStatus	(NULL),
	m_hParamAccessor(NULL),
	m_pParam		(NULL),
	m_pParamInfo	(NULL)
{
	IUnknown*					pUnknown = session;
	CComPtr<IDBCreateCommand>	spCreateCommand;
	HRESULT						hr;

	hr = pUnknown->QueryInterface(IID_IDBCreateCommand, (void**)&spCreateCommand);
	if(SUCCEEDED(hr))
	{
		hr = spCreateCommand->CreateCommand(NULL, IID_ICommandText, (IUnknown**)&m_pCommand);

		if(FAILED(hr))
			m_pCommand = NULL;
	}
}


// CCommand::~CCommand
//
//		Destructor
//
CCommand::~CCommand()
{
	ClearParameters();

	if(m_pCommand != NULL)
	{
		m_pCommand->Release();
		m_pCommand = NULL;
	}
}


void CCommand::ClearBinding()
{
	if(m_pBuffer != NULL)
	{
		delete [] m_pBuffer;
		m_pBuffer	= NULL;
		m_nRowSize	= 0;
	}

	if(m_pBoundParam != NULL)
	{
		delete [] m_pBoundParam;
		m_pBoundParam = NULL;
	}

	if(m_pBindStatus != NULL)
	{
		delete [] m_pBindStatus;
		m_pBindStatus = NULL;
	}

	if(m_hParamAccessor != NULL)
	{
		CComPtr<IAccessor>	spAccessor;
		HRESULT				hr = m_pCommand->QueryInterface(IID_IAccessor, (void**)&spAccessor);

		if(SUCCEEDED(hr))
		{
			spAccessor->ReleaseAccessor(m_hParamAccessor, NULL);
			m_hParamAccessor = NULL;
		}
	}
}


// CCommand::ClearParameters
//
//		Frees all parameter info.
//
void CCommand::ClearParameters()
{
	ClearBinding();

	if(m_pszParamNames != NULL)
	{
		CoTaskMemFree(m_pszParamNames);
		m_pszParamNames = NULL;
	}

	if(m_pParamInfo != NULL)
	{
		CoTaskMemFree(m_pParamInfo);
		m_pParamInfo = NULL;
	}

	if(m_pParam != NULL)
		delete [] m_pParam;
	m_pParam = NULL;

	m_nParams = 0;
}


// CCommand::SetText
//
//		Sets the command text
//
HRESULT CCommand::SetText(LPCTSTR pszText)
{
	HRESULT	hr;

	ATLASSERT(m_pCommand != NULL);
	ATLASSERT(pszText != NULL);

	hr = m_pCommand->SetCommandText(DBGUID_DEFAULT, pszText);
	return hr;
}


// CCommand::RebindParameters
//
//		Checks if the parameter buffer increased since last Bind.
//		Must return true for first execution.
//
bool CCommand::RebindParameters()
{
	ULONG	iParam;
	ULONG	nSize	= 0;

	for(iParam = 0; iParam < m_nParams; ++iParam)
	{
		nSize += sizeof(DBSTATUS) + sizeof(ULONG);

		if(m_pParam[iParam].GetType() == DBTYPE_WSTR)
			nSize += m_pParam[iParam].GetLength() * sizeof(wchar_t);
		else
			nSize += m_pParam[iParam].GetLength();
	}

	return nSize > m_nRowSize;
}


// CCommand::BindParameters
//
//		Binds command parameters
//
HRESULT CCommand::BindParameters()
{
	HRESULT					hr;
	CComPtr<IAccessor>		spAccessor;
	DBBINDING*				pBinding		= NULL;
	BOUNDCOLUMN*			pBoundParam		= NULL;
	ULONG					iParam;
	CBindingArray			binding;
	DBPARAMINFO*			pParamInfo		= m_pParamInfo;

	// Check if we need to bind the parameters
	if(!RebindParameters())
		return S_OK;

	// Start the binding process by allocating the binding array
	if(!binding.Allocate(m_nParams))
		return E_OUTOFMEMORY;

	// Allocate the BOUNDCOLUMN array for parameters
	m_pBoundParam = new BOUNDCOLUMN[m_nParams];
	if(m_pBoundParam == NULL)
		return E_OUTOFMEMORY;

	pBinding	= binding[0];
	pBoundParam	= m_pBoundParam;

	for(iParam = 0; iParam < m_nParams; ++iParam, ++pParamInfo, ++pBinding, ++pBoundParam)
	{
		ULONG		nParamSize	= m_pParam[iParam].GetLength();
		DBTYPE		wType		= pParamInfo->wType;
		DWORD		dwFlags		= pParamInfo->dwFlags;

		if(wType == DBTYPE_STR)
			++nParamSize;		// Add the NULL terminator

		// If this is a UNICODE string, correct the size and allow for the NULL terminator
		if(wType == DBTYPE_WSTR)
			nParamSize = (nParamSize + 1) * sizeof(wchar_t);

		pBinding->iOrdinal		= pParamInfo->iOrdinal;
		pBinding->wType			= wType;
		pBinding->bPrecision	= pParamInfo->bPrecision;
		pBinding->bScale		= pParamInfo->bScale;
		pBinding->dwPart		= DBPART_VALUE | DBPART_LENGTH | DBPART_STATUS;
		pBinding->dwMemOwner	= DBMEMOWNER_CLIENTOWNED;
		pBinding->cbMaxLen		= nParamSize;
		pBinding->pObject		= NULL;

		if(dwFlags & DBPARAMFLAGS_ISINPUT)
			pBinding->eParamIO |= DBPARAMIO_INPUT;
		if(dwFlags & DBPARAMFLAGS_ISOUTPUT)
			pBinding->eParamIO |= DBPARAMIO_OUTPUT;

		pBinding->obLength		= m_nRowSize;
		m_nRowSize				= AddOffset(m_nRowSize, sizeof(ULONG));
		pBinding->obStatus		= m_nRowSize;
		m_nRowSize				= AddOffset(m_nRowSize, sizeof(ULONG));
		pBinding->obValue		= m_nRowSize;
		m_nRowSize				= AddOffset(m_nRowSize, nParamSize);

		pBoundParam->bPrecision		= pBinding->bPrecision;
		pBoundParam->bScale			= pBinding->bScale;
		pBoundParam->dwFlags		= dwFlags;
		pBoundParam->iAccessor		= 0;
		pBoundParam->iOrdinal		= pBinding->iOrdinal;
		pBoundParam->obLength		= pBinding->obLength;
		pBoundParam->obStatus		= pBinding->obStatus;
		pBoundParam->obValue		= pBinding->obValue;
		pBoundParam->pwszName		= pParamInfo->pwszName;
		pBoundParam->ulColumnSize	= nParamSize;
		pBoundParam->wType			= wType;
	}

	// Allocate the data buffer
	m_pBuffer = new BYTE[m_nRowSize];
	if(m_pBuffer == NULL)
		return E_OUTOFMEMORY;

	// Allocate the DBBINDSTATUS array. We own this memory.
	m_pBindStatus = new DBBINDSTATUS[m_nParams];
	if(m_pBindStatus == NULL)
		return E_OUTOFMEMORY;

	hr = m_pCommand->QueryInterface(IID_IAccessor, (void**)&spAccessor);
	if(FAILED(hr))
		return hr;

	hr = spAccessor->CreateAccessor(DBACCESSOR_PARAMETERDATA, m_nParams, binding[0], m_nRowSize, &m_hParamAccessor, m_pBindStatus);

	return hr;
}


// CCommand::SetAllParameters
//
//		Copies all parameter values from the staging array to the parameter buffer
//
void CCommand::SetAllParameters()
{
	ULONG			iParam;
	BOUNDCOLUMN*	pBoundParam	= m_pBoundParam;

	for(iParam = 0; iParam < m_nParams; ++iParam, ++pBoundParam)
	{
		CDbValue&	value	= m_pParam[iParam];
		DBSTATUS*	pStatus	= (DBSTATUS*)	(m_pBuffer + pBoundParam->obStatus);
		ULONG*		pLength	= (ULONG*)		(m_pBuffer + pBoundParam->obLength);
		BYTE*		pValue	= (BYTE*)		(m_pBuffer + pBoundParam->obValue);

		*pStatus	= value.GetStatus();
		*pLength	= value.GetType() == DBTYPE_WSTR ? value.GetLength() * sizeof(wchar_t) : value.GetLength();

		if(*pStatus == DBSTATUS_S_OK && *pLength > 0)
			memcpy(pValue, value.GetDataPtr(), *pLength);
	}
}


// CCommand::CreateParameters
//
//		Creates te parameter value array to buffer data
//
HRESULT CCommand::CreateParameters(DBPARAMINFO* pParamInfo)
{
	ULONG	iParam;

	m_pParam = new CDbValue[m_nParams];
	if(m_pParam == NULL)
		return E_OUTOFMEMORY;

	for(iParam = 0; iParam < m_nParams; ++iParam, ++pParamInfo)
	{
		bool	bIsLong		= pParamInfo->ulParamSize > 8192;
		ULONG	nParamSize	= bIsLong ? 1024 : pParamInfo->ulParamSize;

		m_pParam[iParam].Initialize(pParamInfo->wType, nParamSize, nParamSize, bIsLong); 
	}

	return S_OK;
}


// CCommand::Prepare
//
//		Prepares the command for execution (compiles an execution plan)
//
HRESULT CCommand::Prepare(ULONG cExpectedRuns)
{
	CComPtr<ICommandPrepare>		spCommandPrepare;
	CComPtr<ICommandWithParameters> spCommandParams;
	HRESULT							hr;

	ATLASSERT(m_pCommand != NULL);

	hr = m_pCommand->QueryInterface(IID_ICommandPrepare, (void**)&spCommandPrepare);
	if(FAILED(hr))
		return hr;

	hr = spCommandPrepare->Prepare(cExpectedRuns);
	if(FAILED(hr))
		return hr;

	// Retrieve the command parameters, if any
	hr = m_pCommand->QueryInterface(IID_ICommandWithParameters, (void**)&spCommandParams);
	if(SUCCEEDED(hr))
	{
		ClearParameters();
		hr = spCommandParams->GetParameterInfo(&m_nParams, &m_pParamInfo, &m_pszParamNames);
		if(SUCCEEDED(hr) && m_nParams)
		{
			hr = CreateParameters(m_pParamInfo);
			if(SUCCEEDED(hr))
				hr = BindParameters();
		}
	}

	return hr;
}


// CCommand::Unprepare
//
//		Unprepares the command (releases the compiled execution plan)
//
HRESULT CCommand::Unprepare()
{
	CComPtr<ICommandPrepare>	spCommandPrepare;
	HRESULT						hr;

	ATLASSERT(m_pCommand != NULL);

	hr = m_pCommand->QueryInterface(IID_ICommandPrepare, (void**)&spCommandPrepare);
	if(FAILED(hr))
		return hr;

	hr = spCommandPrepare->Unprepare();
	if(SUCCEEDED(hr))
		ClearParameters();

	return hr;
}


// CCommand::Execute
//
//		Executes the command without returning a rowset.
//		Use for DDL commands.
//
HRESULT CCommand::Execute(LONG *pcRowsAffected)
{
	HRESULT		hr;
	DBPARAMS	dbParams;
	DBPARAMS*	pParams	= NULL;

	ATLASSERT(m_pCommand != NULL);

	hr = BindParameters();
	if(FAILED(hr))
		return hr;

	SetAllParameters();

	if(m_nParams)
	{
		dbParams.cParamSets	= 1;
		dbParams.hAccessor	= m_hParamAccessor;
		dbParams.pData		= m_pBuffer;

		pParams = &dbParams;
	}

	hr = m_pCommand->Execute(NULL, IID_NULL, &dbParams, pcRowsAffected, NULL);

	return hr;
}


// CCommand::Execute
//
//		Executes the command and returns a rowset.
//
HRESULT CCommand::Execute(CRowset &rowset, LONG *pcRowsAffected)
{
	HRESULT		hr;
	IRowset*	pRowset		= NULL;
	DBPARAMS	dbParams;
	DBPARAMS*	pParams		= NULL;

	ATLASSERT(m_pCommand != NULL);

	hr = BindParameters();
	if(FAILED(hr))
		return hr;

	SetAllParameters();

	if(m_nParams)
	{
		dbParams.cParamSets	= 1;
		dbParams.hAccessor	= m_hParamAccessor;
		dbParams.pData		= m_pBuffer;

		pParams = &dbParams;
	}

	hr = m_pCommand->Execute(NULL, IID_IRowset, pParams, pcRowsAffected, (IUnknown**)&pRowset);
	if(FAILED(hr))
		return hr;

	hr = rowset.Open(pRowset);
	return hr;
}


// CCommand::FindParameter
//
//		Returns a parameter entry index from the given ordinal or NULL if not found
//
ULONG CCommand::FindParameter(ULONG iOrdinal)
{
	ULONG			i;
	BOUNDCOLUMN*	p;

	for(i = 0, p = m_pBoundParam; i < m_nParams; ++i, ++p)
	{
		if(p->iOrdinal == iOrdinal)
			return i;
	}
	return (ULONG)-1;
}
<file_sep>/7-Zip/CPP/7zip/Archive/Nsis/NsisIn.h
// NsisIn.h

#ifndef __ARCHIVE_NSIS_IN_H
#define __ARCHIVE_NSIS_IN_H

#include "Common/Buffer.h"
#include "Common/MyCom.h"
#include "Common/StringConvert.h"

#include "NsisDecode.h"

// #define NSIS_SCRIPT

namespace NArchive {
namespace NNsis {

const int kSignatureSize = 16;
#define NSIS_SIGNATURE { 0xEF, 0xBE, 0xAD, 0xDE, 0x4E, 0x75, 0x6C, 0x6C, 0x73, 0x6F, 0x66, 0x74, 0x49, 0x6E, 0x73, 0x74}

extern Byte kSignature[kSignatureSize];

const UInt32 kFlagsMask = 0xF;
namespace NFlags
{
  const UInt32 kUninstall = 1;
  const UInt32 kSilent = 2;
  const UInt32 kNoCrc = 4;
  const UInt32 kForceCrc = 8;
}

struct CFirstHeader
{
  UInt32 Flags;
  UInt32 HeaderLength;
 
  UInt32 ArchiveSize;

  bool ThereIsCrc() const
  {
    if ((Flags & NFlags::kForceCrc ) != 0)
      return true;
    return ((Flags & NFlags::kNoCrc) == 0);
  }

  UInt32 GetDataSize() const { return ArchiveSize - (ThereIsCrc() ? 4 : 0); }
};


struct CBlockHeader
{
  UInt32 Offset;
  UInt32 Num;
};

struct CItem
{
  AString PrefixA;
  UString PrefixU;
  AString NameA;
  UString NameU;
  FILETIME MTime;
  bool IsUnicode;
  bool UseFilter;
  bool IsCompressed;
  bool SizeIsDefined;
  bool CompressedSizeIsDefined;
  bool EstimatedSizeIsDefined;
  UInt32 Pos;
  UInt32 Size;
  UInt32 CompressedSize;
  UInt32 EstimatedSize;
  UInt32 DictionarySize;
  
  CItem(): IsUnicode(false), UseFilter(false), IsCompressed(true), SizeIsDefined(false),
      CompressedSizeIsDefined(false), EstimatedSizeIsDefined(false), Size(0) {}

  bool IsINSTDIR() const
  {
    return (PrefixA.Length() >= 3 || PrefixU.Length() >= 3);
  }

  UString GetReducedName(bool unicode) const
  {
    UString s;
    if (unicode)
      s = PrefixU;
    else
      s = MultiByteToUnicodeString(PrefixA);
    if (s.Length() > 0)
      if (s[s.Length() - 1] != L'\\')
        s += L'\\';
    if (unicode)
      s += NameU;
    else
      s += MultiByteToUnicodeString(NameA);
    const int len = 9;
    if (s.Left(len).CompareNoCase(L"$INSTDIR\\") == 0)
      s = s.Mid(len);
    return s;
  }
};

class CInArchive
{
  UInt64 _archiveSize;
  CMyComPtr<IInStream> _stream;

  Byte ReadByte();
  UInt32 ReadUInt32();
  HRESULT Open2(
      DECL_EXTERNAL_CODECS_LOC_VARS2
      );
  void ReadBlockHeader(CBlockHeader &bh);
  AString ReadStringA(UInt32 pos) const;
  UString ReadStringU(UInt32 pos) const;
  AString ReadString2A(UInt32 pos) const;
  UString ReadString2U(UInt32 pos) const;
  AString ReadString2(UInt32 pos) const;
  AString ReadString2Qw(UInt32 pos) const;
  HRESULT ReadEntries(const CBlockHeader &bh);
  HRESULT Parse();

  CByteBuffer _data;
  UInt64 _size;

  size_t _posInData;

  UInt32 _stringsPos;


  bool _headerIsCompressed;
  UInt32 _nonSolidStartOffset;
public:
  HRESULT Open(
      DECL_EXTERNAL_CODECS_LOC_VARS
      IInStream *inStream, const UInt64 *maxCheckStartPosition);
  void Clear();

  UInt64 StreamOffset;
  CDecoder Decoder;
  CObjectVector<CItem> Items;
  CFirstHeader FirstHeader;
  NMethodType::EEnum Method;
  UInt32 DictionarySize;
  bool IsSolid;
  bool UseFilter;
  bool FilterFlag;
  bool IsUnicode;

  #ifdef NSIS_SCRIPT
  AString Script;
  #endif
  UInt32 GetOffset() const { return IsSolid ? 4 : 0; }
  UInt64 GetDataPos(int index)
  {
    const CItem &item = Items[index];
    return GetOffset() + FirstHeader.HeaderLength + item.Pos;
  }

  UInt64 GetPosOfSolidItem(int index) const
  {
    const CItem &item = Items[index];
    return 4 + FirstHeader.HeaderLength + item.Pos;
  }
  
  UInt64 GetPosOfNonSolidItem(int index) const
  {
    const CItem &item = Items[index];
    return StreamOffset + _nonSolidStartOffset + 4  + item.Pos;
  }

  void Release()
  {
    Decoder.Release();
  }

};

}}
  
#endif
<file_sep>/7-Zip/CPP/7zip/Archive/RpmHandler.cpp
// RpmHandler.cpp

#include "StdAfx.h"

#include "../../../C/CpuArch.h"

#include "Common/ComTry.h"
#include "Common/MyString.h"

#include "Windows/PropVariant.h"

#include "../Common/LimitedStreams.h"
#include "../Common/ProgressUtils.h"
#include "../Common/RegisterArc.h"
#include "../Common/StreamUtils.h"

#include "../Compress/CopyCoder.h"

using namespace NWindows;

#define Get16(p) GetBe16(p)
#define Get32(p) GetBe32(p)

namespace NArchive {
namespace NRpm {

/* Reference: lib/signature.h of rpm package */
#define RPMSIG_NONE         0  /* Do not change! */
/* The following types are no longer generated */
#define RPMSIG_PGP262_1024  1  /* No longer generated */ /* 256 byte */
/* These are the new-style signatures.  They are Header structures.    */
/* Inside them we can put any number of any type of signature we like. */

#define RPMSIG_HEADERSIG    5  /* New Header style signature */

const UInt32 kLeadSize = 96;
struct CLead
{
  unsigned char Magic[4];
  unsigned char Major;  // not supported  ver1, only support 2,3 and lator
  unsigned char Minor;
  UInt16 Type;
  UInt16 ArchNum;
  char Name[66];
  UInt16 OSNum;
  UInt16 SignatureType;
  char Reserved[16];  // pad to 96 bytes -- 8 byte aligned
  bool MagicCheck() const
    { return Magic[0] == 0xed && Magic[1] == 0xab && Magic[2] == 0xee && Magic[3] == 0xdb; };
};
  
const UInt32 kEntryInfoSize = 16;
/*
struct CEntryInfo
{
  int Tag;
  int Type;
  int Offset; // Offset from beginning of data segment, only defined on disk
  int Count;
};
*/

// case: SignatureType == RPMSIG_HEADERSIG
const UInt32 kCSigHeaderSigSize = 16;
struct CSigHeaderSig
{
  unsigned char Magic[4];
  UInt32 Reserved;
  UInt32 IndexLen;  // count of index entries
  UInt32 DataLen;   // number of bytes
  bool MagicCheck()
    { return Magic[0] == 0x8e && Magic[1] == 0xad && Magic[2] == 0xe8 && Magic[3] == 0x01; };
  UInt32 GetLostHeaderLen()
    { return IndexLen * kEntryInfoSize + DataLen; };
};

static HRESULT RedSigHeaderSig(IInStream *inStream, CSigHeaderSig &h)
{
  char dat[kCSigHeaderSigSize];
  char *cur = dat;
  RINOK(ReadStream_FALSE(inStream, dat, kCSigHeaderSigSize));
  memmove(h.Magic, cur, 4);
  cur += 4;
  cur += 4;
  h.IndexLen = Get32(cur);
  cur += 4;
  h.DataLen = Get32(cur);
  return S_OK;
}

HRESULT OpenArchive(IInStream *inStream)
{
  UInt64 pos;
  char leadData[kLeadSize];
  char *cur = leadData;
  CLead lead;
  RINOK(ReadStream_FALSE(inStream, leadData, kLeadSize));
  memmove(lead.Magic, cur, 4);
  cur += 4;
  lead.Major = *cur++;
  lead.Minor = *cur++;
  lead.Type = Get16(cur);
  cur += 2;
  lead.ArchNum = Get16(cur);
  cur += 2;
  memmove(lead.Name, cur, sizeof(lead.Name));
  cur += sizeof(lead.Name);
  lead.OSNum = Get16(cur);
  cur += 2;
  lead.SignatureType = Get16(cur);
  cur += 2;

  if (!lead.MagicCheck() || lead.Major < 3)
    return S_FALSE;

  CSigHeaderSig sigHeader, header;
  if (lead.SignatureType == RPMSIG_NONE)
  {
    ;
  }
  else if (lead.SignatureType == RPMSIG_PGP262_1024)
  {
    UInt64 pos;
    RINOK(inStream->Seek(256, STREAM_SEEK_CUR, &pos));
  }
  else if (lead.SignatureType == RPMSIG_HEADERSIG)
  {
    RINOK(RedSigHeaderSig(inStream, sigHeader));
    if (!sigHeader.MagicCheck())
      return S_FALSE;
    UInt32 len = sigHeader.GetLostHeaderLen();
    RINOK(inStream->Seek(len, STREAM_SEEK_CUR, &pos));
    if ((pos % 8) != 0)
    {
      RINOK(inStream->Seek((pos / 8 + 1) * 8 - pos,
          STREAM_SEEK_CUR, &pos));
    }
  }
  else
    return S_FALSE;

  RINOK(RedSigHeaderSig(inStream, header));
  if (!header.MagicCheck())
    return S_FALSE;
  int headerLen = header.GetLostHeaderLen();
  if (headerLen == -1)
    return S_FALSE;
  RINOK(inStream->Seek(headerLen, STREAM_SEEK_CUR, &pos));
  return S_OK;
}

class CHandler:
  public IInArchive,
  public IInArchiveGetStream,
  public CMyUnknownImp
{
  CMyComPtr<IInStream> _stream;
  UInt64 _pos;
  UInt64 _size;
  Byte _sig[4];
public:
  MY_UNKNOWN_IMP2(IInArchive, IInArchiveGetStream)
  INTERFACE_IInArchive(;)
  STDMETHOD(GetStream)(UInt32 index, ISequentialInStream **stream);
};

STATPROPSTG kProps[] =
{
  { NULL, kpidSize, VT_UI8}
};

IMP_IInArchive_Props
IMP_IInArchive_ArcProps_NO_Table

STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
{
  NCOM::CPropVariant prop;
  switch(propID) { case kpidMainSubfile: prop = (UInt32)0; break; }
  prop.Detach(value);
  return S_OK;
}

STDMETHODIMP CHandler::Open(IInStream *inStream,
    const UInt64 * /* maxCheckStartPosition */,
    IArchiveOpenCallback * /* openArchiveCallback */)
{
  COM_TRY_BEGIN
  try
  {
    Close();
    if (OpenArchive(inStream) != S_OK)
      return S_FALSE;
    RINOK(inStream->Seek(0, STREAM_SEEK_CUR, &_pos));
    RINOK(ReadStream_FALSE(inStream, _sig, sizeof(_sig) / sizeof(_sig[0])));
    UInt64 endPosition;
    RINOK(inStream->Seek(0, STREAM_SEEK_END, &endPosition));
    _size = endPosition - _pos;
    _stream = inStream;
    return S_OK;
  }
  catch(...) { return S_FALSE; }
  COM_TRY_END
}

STDMETHODIMP CHandler::Close()
{
  _stream.Release();
  return S_OK;
}

STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
{
  *numItems = 1;
  return S_OK;
}

STDMETHODIMP CHandler::GetProperty(UInt32 /* index */, PROPID propID, PROPVARIANT *value)
{
  NWindows::NCOM::CPropVariant prop;
  switch(propID)
  {
    case kpidSize:
    case kpidPackSize:
      prop = _size;
      break;
    case kpidExtension:
    {
      char s[32];
      MyStringCopy(s, "cpio.");
      const char *ext;
      if (_sig[0] == 0x1F && _sig[1] == 0x8B)
        ext = "gz";
      else if (_sig[0] == 'B' && _sig[1] == 'Z' && _sig[2] == 'h')
        ext = "bz2";
      else
        ext = "lzma";
      MyStringCopy(s + MyStringLen(s), ext);
      prop = s;
      break;
    }
  }
  prop.Detach(value);
  return S_OK;
}

STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
    Int32 testMode, IArchiveExtractCallback *extractCallback)
{
  COM_TRY_BEGIN
  if (numItems == 0)
    return S_OK;
  if (numItems != (UInt32)-1 && (numItems != 1 || indices[0] != 0))
    return E_INVALIDARG;

  RINOK(extractCallback->SetTotal(_size));
  CMyComPtr<ISequentialOutStream> outStream;
  Int32 askMode = testMode ?
      NExtract::NAskMode::kTest :
      NExtract::NAskMode::kExtract;
  RINOK(extractCallback->GetStream(0, &outStream, askMode));
  if (!testMode && !outStream)
    return S_OK;
  RINOK(extractCallback->PrepareOperation(askMode));

  CMyComPtr<ICompressCoder> copyCoder = new NCompress::CCopyCoder;

  CLocalProgress *lps = new CLocalProgress;
  CMyComPtr<ICompressProgressInfo> progress = lps;
  lps->Init(extractCallback, false);
  
  RINOK(_stream->Seek(_pos, STREAM_SEEK_SET, NULL));
  RINOK(copyCoder->Code(_stream, outStream, NULL, NULL, progress));
  outStream.Release();
  return extractCallback->SetOperationResult(NExtract::NOperationResult::kOK);
  COM_TRY_END
}

STDMETHODIMP CHandler::GetStream(UInt32 /* index */, ISequentialInStream **stream)
{
  COM_TRY_BEGIN
  return CreateLimitedInStream(_stream, _pos, _size, stream);
  COM_TRY_END
}

static IInArchive *CreateArc() { return new NArchive::NRpm::CHandler; }

static CArcInfo g_ArcInfo =
  { L"Rpm", L"rpm", 0, 0xEB, { 0xED, 0xAB, 0xEE, 0xDB}, 4, false, CreateArc, 0 };

REGISTER_ARC(Rpm)

}}
<file_sep>/FingerSuite/FingerMsgBox/MainFrm.h
// MainFrm.h : interface of the CMainFrame class
//
/////////////////////////////////////////////////////////////////////////////

#pragma once

#include "sharedmem.h"
#include "InterceptEngine.h"
#include "..\Common\Utils.h"
#include "..\Common\log\logger.h"
#include "..\Common\AboutView.h"
#include "..\Common\fngrbtn.h"
#include "..\FingerSuiteCPL\Commons.h"
#include "MsgBoxWindow.h"
#include "..\Common\fngrsplash.h"

#define IDT_TMR_DISABLED 10012
#define MASK_EVENTMUTE   0x0004

typedef enum {QVGA = 320, WQVGA = 400, VGA = 640, WVGA = 800} RESOLUTION;

static UINT UWM_INTERCEPT_MSGBOX = ::RegisterWindowMessage(UWM_INTERCEPT_MSGBOX_MSG);

static UINT UWM_UPDATECONFIGURATION = ::RegisterWindowMessage(UWM_UPDATECONFIGURATION_MSG);



class CMainFrame : public CFrameWindowImpl<CMainFrame>, public CUpdateUI<CMainFrame>,
		public CMessageFilter, public CIdleHandler
{
public:
	DECLARE_FRAME_WND_CLASS(L"FINGER_MSGBOX", IDR_MAINFRAME)

	CMsgBoxWindow    m_msgBoxView;
	CAboutView       m_aboutView;


	virtual BOOL PreTranslateMessage(MSG* pMsg)
	{
		if(CFrameWindowImpl<CMainFrame>::PreTranslateMessage(pMsg))
			return TRUE;

		return m_msgBoxView.PreTranslateMessage(pMsg);
	}

	virtual BOOL OnIdle()
	{
		return FALSE;
	}

	void DoPaint(CDCHandle dc)
	{
		RECT rc; GetClientRect(&rc);

		if (m_bDisabledTransp)
		{
			dc.FillSolidRect(&rc, m_clNoTranspBackground);
		}
		else
		{
			if (!(m_imgBkg.IsValid()))
				CaptureScreen(dc);

			m_imgBkg.Draw(dc, rc);
		}
	}

	BEGIN_UPDATE_UI_MAP(CMainFrame)
	END_UPDATE_UI_MAP()

	BEGIN_MSG_MAP(CMainFrame)
		MESSAGE_HANDLER(WM_CREATE, OnCreate)
		MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
		MESSAGE_HANDLER(WM_SIZE, OnSize)
		MESSAGE_HANDLER(WM_CLOSE, OnClose)
		MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBkgnd)
		MESSAGE_HANDLER(WM_PAINT, OnPaint)
		MESSAGE_HANDLER(WM_ACTIVATE, OnActivate)
		MESSAGE_HANDLER(WM_WININICHANGE, OnWininichange)
		MESSAGE_HANDLER(UM_MINIMIZE, OnMinimize)
		MESSAGE_HANDLER(UWM_INTERCEPT_MSGBOX, OnInterceptMsgBox)
		MESSAGE_HANDLER(UWM_UPDATECONFIGURATION, OnUpdateConfiguration)
		COMMAND_ID_HANDLER(ID_MENU_CANCEL, OnCancel)
		COMMAND_ID_HANDLER(ID_MENU_EXIT, OnMenuExit)
		COMMAND_ID_HANDLER(ID_MENU_ABOUT, OnMenuAbout)
		COMMAND_ID_HANDLER(ID_MENU_SHOWORIGINAL, OnMenuShowOriginal)
		COMMAND_ID_HANDLER(ID_MENU_ADDTOEXCLUSIONLIST, OnMenuAddToExclusionList)
		COMMAND_ID_HANDLER(ID_MENU_ADDTOWNDEXCLUSIONLIST, OnMenuAddToWndExclusionList)
		CHAIN_MSG_MAP(CUpdateUI<CMainFrame>)
		CHAIN_MSG_MAP(CFrameWindowImpl<CMainFrame>)
	END_MSG_MAP()


	LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		CreateSimpleCEMenuBar(FM_IDW_MENU_BAR, SHCMBF_HIDESIPBUTTON);

		CSplashWindow* pSplash = new CSplashWindow(m_hWnd, IDR_MAINFRAME, L"FingerMsgbox");

		LoadConfiguration();

		// msgbox
		m_hWndClient = m_msgBoxView.Create(m_hWnd);

		// about
		CString strCredits = "\n\n"
			    "\tFingerMsgBox v1.01\n\n"
				"\rProgrammed by:\n"
				"<NAME>\n"
				"<<EMAIL>>\n"
				"\n\n"
				"http://forum.xda-developers.com/\n"
				"                showthread.php?t=459125\n";

		m_aboutView.SetCredits(strCredits);
		m_aboutView.Create(m_hWnd, rcDefault, NULL, WS_CHILD | WS_VISIBLE |WS_CLIPSIBLINGS | WS_CLIPCHILDREN);  //

		// register object for message filtering and idle updates
		CMessageLoop* pLoop = _Module.GetMessageLoop();
		ATLASSERT(pLoop != NULL);
		pLoop->AddMessageFilter(this);
		pLoop->AddIdleHandler(this);

		SetHWndServerMsgBox(m_hWnd);

		InstallHook();

		SignalWaitEvent(EVT_FNGRMSGBOX);

		ModifyStyle(0, WS_NONAVDONEBUTTON, SWP_NOSIZE);

		m_bDisabled = FALSE;

		pSplash->Dismiss();

		return 0;  
	}

	LRESULT OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		return 0;
	}

	LRESULT OnSize(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled)
	{
		if(wParam != SIZE_MINIMIZED)
		{

		}
			
		return 0;
	}


	LRESULT OnClose(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)
	{
		RemoveHook();

		if (!(m_fText.IsNull()))
		{
			m_fText.DeleteObject();
			m_fText = NULL;
		}

		if (!(m_fCaption.IsNull()))
		{
			m_fCaption.DeleteObject();
			m_fCaption = NULL;
		}

		if (!(m_fBtn.IsNull()))
		{
			m_fBtn.DeleteObject();
			m_fBtn = NULL;
		}

		bHandled = FALSE;
		return 0;
	}

	LRESULT OnEraseBkgnd(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		return 1;
	}

	LRESULT OnPaint(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		if(wParam != NULL)
		{
			DoPaint((HDC)wParam);
		}
		else
		{
			CPaintDC dc(m_hWnd);
			DoPaint(dc.m_hDC);
		}
		return 0;
	}

	LRESULT OnActivate(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		int fActive = LOWORD(wParam); 
		if ((fActive == WA_ACTIVE) || (fActive == WA_CLICKACTIVE))
		{
		}
		else if (fActive == WA_INACTIVE)
		{
			if (IsWindowVisible())
			{
				SetMsgBoxResult(IDCANCEL);
				Minimize();
			}
		}
		return 0;
	}

	LRESULT OnWininichange(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		if (wParam == SETTINGCHANGE_RESET)
		{
			//SetMsgBoxResult(IDCANCEL);
			//Minimize();

			m_msgBoxView.ModifyShape();
			m_msgBoxView.ModifyButtons();
		}
		return 0;
	}

	LRESULT OnMinimize(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		Minimize();
		return 0;
	}

	LRESULT OnCancel(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
	{
		SetMsgBoxResult(IDCANCEL);
		Minimize();

		return 0;
	}

	LRESULT OnInterceptMsgBox(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled)
	{
		LPMSGBOXINFO lpInfo = (LPMSGBOXINFO)lParam;

		HWND hDestWnd = lpInfo->hWnd;
		UINT uType = lpInfo->uType;

		LOG(L"Intercepting MessageBoxW...uType=%08x hWnd=%08X\n", uType, hDestWnd);

		if (m_bDisabled)
			return 1;

		if (IsDeviceLocked())
			return 1;

		m_hForeWnd = ::GetForegroundWindow();

		if (IsExcludedApp(hDestWnd))
			return 1;

		if (IsExcludedWnd(hDestWnd))
			return 1;

		if (!(m_msgBoxView.SetMsgBox(hDestWnd, uType, lpInfo->szCaption, lpInfo->szText)))
			return 1;
		
		Sleep(100);

		SwitchToMsgBoxView();

		SetForegroundWindow((HWND)((ULONG) m_hWnd | 0x00000001));
		ShowWindow(SW_SHOW);		
		
		PlayMessageBoxSound(uType);

		bHandled = TRUE;
		return 0;
	}

	LRESULT OnMenuExit(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
	{
		SetMsgBoxResult(IDCANCEL);
		Minimize();

		PostMessage(WM_CLOSE);
		return 0;
	}


	LRESULT OnMenuAbout(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
	{
		SwitchToAboutView();
		SetForegroundWindow((HWND)((ULONG) m_hWnd | 0x00000001));
		ShowWindow(SW_SHOW);	
		return 0;
	}		

	LRESULT OnMenuShowOriginal(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
	{
		SetMsgBoxResult(-1);
		Minimize();
		
		return 0;
	}

	LRESULT OnMenuAddToExclusionList(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
	{
		HWND hDestWnd = m_msgBoxView.GetOwnerWnd();
		DWORD dwProcessId; GetWindowThreadProcessId(hDestWnd, &dwProcessId);
		HMODULE hProcess = (HMODULE)dwProcessId;
		WCHAR szName[MAX_PATH];
		if (GetModuleFileName(hProcess, szName, MAX_PATH))
		{
			CString szApp = (LPTSTR)szName;
			szApp = szApp.Right(szApp.GetLength() - szApp.ReverseFind('\\') - 1);
			
			if (m_excludedApps.Find(szApp) == -1)
				m_excludedApps.Add(szApp);
			
			SaveExclusionList(m_excludedApps, L"Software\\FingerMsgbox");
		}

		SetMsgBoxResult(-1);
		Minimize();

		return 0;
	}

	LRESULT OnMenuAddToWndExclusionList(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
	{
		HWND hDestWnd = m_msgBoxView.GetOwnerWnd();

		WCHAR szTitle[MAX_PATH];
		::GetWindowText(hDestWnd, szTitle, MAX_PATH); 

		WCHAR szClassName[MAX_PATH];
		::GetClassName(hDestWnd, szClassName, MAX_PATH);

		WCHAR szName[MAX_PATH];
		wsprintf(szName, L"%s - %s", szTitle, szClassName);
		
		CString szWnd = (LPTSTR)szName;
		if (m_excludedWnds.Find(szWnd) == -1)
			m_excludedWnds.Add(szWnd);

		SaveWndExclusionList(m_excludedWnds, L"Software\\FingerMsgbox");

		SetMsgBoxResult(-1);
		Minimize();

		return 0;
	}

	LRESULT OnUpdateConfiguration(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		LoadConfiguration();

		SetMsgBoxResult(FALSE);
		Minimize();
		return 0;
	}


private:

	void Minimize()
	{
		ShowWindow(SW_HIDE);

		SignalWaitEvent(EVT_FNGRMSGBOX);
	}

	HWND ManageDOTNETApp(HWND& hDestWnd)
	{
		HWND hDestCtrl = NULL;
		WCHAR szClass[50];
		::GetClassName(hDestWnd, szClass, 50);
		if (lstrcmpi(szClass, L"MS_SOFTKEY_CE_1.0") == 0)
		{
			DWORD dwProcessId; GetWindowThreadProcessId(hDestWnd, &dwProcessId);

			HWND hDotNETWnd = ::FindWindow(L"#NETCF_AGL_BASE_", NULL);
			if (hDotNETWnd != NULL)
			{
				DWORD dwProcess2Id; GetWindowThreadProcessId(hDotNETWnd, &dwProcess2Id);
				if (dwProcess2Id == dwProcessId)
				{
					hDestCtrl = hDestWnd;
					hDestWnd = hDotNETWnd;
				}
			}
		}
		return hDestCtrl;
	}

	BOOL IsExcludedApp(HWND hWnd)
	{
		DWORD dwProcessId; GetWindowThreadProcessId(hWnd, &dwProcessId);
		HMODULE hProcess = (HMODULE)dwProcessId;
		WCHAR szName[MAX_PATH];
		if (GetModuleFileName(hProcess, szName, MAX_PATH))
		{
			CString szApp = (LPTSTR)szName;
			szApp = szApp.Right(szApp.GetLength() - szApp.ReverseFind('\\') - 1);
			for (int i = 0; i < m_excludedApps.GetSize(); i ++)
			{
				if (m_excludedApps[i].CompareNoCase( szApp ) == 0)
					return TRUE;
			}
		}

		return FALSE;
	}

	BOOL IsExcludedWnd(HWND hWnd)
	{
		WCHAR szTitle[MAX_PATH];
		::GetWindowText(hWnd, szTitle, MAX_PATH); 

		WCHAR szClassName[MAX_PATH];
		::GetClassName(hWnd, szClassName, MAX_PATH);

		WCHAR szName[MAX_PATH];
		wsprintf(szName, L"%s - %s", szTitle, szClassName);


		CString szWnd = (LPTSTR)szName;
		for (int i = 0; i < m_excludedWnds.GetSize(); i ++)
		{
			if (m_excludedWnds[i].CompareNoCase( szWnd ) == 0)
				return TRUE;
		}

		return FALSE;
	}


	void CaptureScreen(CDCHandle dc)
	{
		RECT rc; GetClientRect(&rc);
		CDC dcTemp; dcTemp.CreateCompatibleDC(dc);
		CBitmap bmpBkg; bmpBkg.CreateCompatibleBitmap(dc, rc.right, rc.bottom);
		CBitmap bmpOld = dcTemp.SelectBitmap(bmpBkg);
		dcTemp.FillSolidRect(&rc, RGB(0,0,0));
		dcTemp.SelectBitmap(bmpOld);
		m_imgBkg.CreateFromHBITMAP(bmpBkg);
		m_imgBkg.AlphaCreate();
		m_imgBkg.AlphaSet((BYTE)m_iTransp);
	}

	void LoadConfiguration()
	{
		WCHAR keyName[] = L"Software\\FingerMsgBox";

		// load transparency level
		m_iTransp = 128;
		if (!(RegReadDWORD(HKEY_LOCAL_MACHINE, keyName, L"TransparencyLevel", m_iTransp)))
			wprintf(L"Unable to read TransparencyLevel from registry: %s\n", ErrorString(GetLastError()));
		m_msgBoxView.m_iTransp = m_iTransp;

		m_bDisabledTransp = FALSE;
		if (!(RegReadBOOL(HKEY_LOCAL_MACHINE, keyName, L"DisableTransparency", m_bDisabledTransp)))
			wprintf(L"Unable to read DisableTransparency from registry: %s\n", ErrorString(GetLastError()));
		m_msgBoxView.m_bDisabledTransp = m_bDisabledTransp;

		m_clNoTranspBackground = RGB(0,0,0);
		RegReadColor(HKEY_LOCAL_MACHINE, keyName, L"NoTranspBkgColor", m_clNoTranspBackground);
		m_msgBoxView.m_clNoTranspBackground = m_clNoTranspBackground;

		WCHAR szSkin[60] = L"default";
		RegReadString(HKEY_LOCAL_MACHINE, keyName, L"Skin", szSkin);
		WCHAR szAppPath[MAX_PATH] = L"";
		CString strAppDirectory;
		GetModuleFileName(NULL, szAppPath, MAX_PATH);
		strAppDirectory = szAppPath;
		strAppDirectory = strAppDirectory.Left(strAppDirectory.ReverseFind('\\'));
		CString skinBasePath; skinBasePath.Format(L"%s\\skins\\%s", strAppDirectory, szSkin);
		
		// detect resolution
		RESOLUTION resolution = QVGA;
		DEVMODE dm;
		::ZeroMemory(&dm, sizeof(DEVMODE));
		dm.dmSize = sizeof(DEVMODE);
		if (EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dm))
		{
			resolution = (RESOLUTION)dm.dmPelsHeight;
		}

		// load icon images
		switch (resolution)
		{
		case QVGA:
		case WQVGA:
			m_msgBoxView.SetScaleFactor(1);
			break;
		case VGA:
		case WVGA:
			m_msgBoxView.SetScaleFactor(2);			
			break;
		}		

		if ( (resolution == VGA) || (resolution == WVGA))
		{
			m_msgBoxView.m_imgHeader.Load(skinBasePath + L"\\msgbox_header_vga.png", CXIMAGE_FORMAT_PNG);
			m_msgBoxView.m_icnInfo.Load(skinBasePath + L"\\msgbox_iconinfo_vga.png", CXIMAGE_FORMAT_PNG);
			m_msgBoxView.m_icnQuestion.Load(skinBasePath + L"\\msgbox_iconquestion_vga.png", CXIMAGE_FORMAT_PNG);
			m_msgBoxView.m_icnStop.Load(skinBasePath + L"\\msgbox_iconstop_vga.png", CXIMAGE_FORMAT_PNG);
			m_msgBoxView.m_icnWarning.Load(skinBasePath + L"\\msgbox_iconwarning_vga.png", CXIMAGE_FORMAT_PNG);

			// normal
			AddDynamicSet(m_msgBoxView.m_arrDynamicImages, NORMAL, skinBasePath + L"\\msgbox_button_normal_left_vga.png", 
				           skinBasePath + L"\\msgbox_button_normal_center_vga.png",
						   skinBasePath + L"\\msgbox_button_normal_right_vga.png");

			// pressed
			AddDynamicSet(m_msgBoxView.m_arrDynamicImages, PUSHED, skinBasePath + L"\\msgbox_button_pressed_left_vga.png", 
				           skinBasePath + L"\\msgbox_button_pressed_center_vga.png",
						   skinBasePath + L"\\msgbox_button_pressed_right_vga.png");

		}
		else
		{
			m_msgBoxView.m_imgHeader.Load(skinBasePath + L"\\msgbox_header_qvga.png", CXIMAGE_FORMAT_PNG);
			m_msgBoxView.m_icnInfo.Load(skinBasePath + L"\\msgbox_iconinfo_qvga.png", CXIMAGE_FORMAT_PNG);
			m_msgBoxView.m_icnQuestion.Load(skinBasePath + L"\\msgbox_iconquestion_qvga.png", CXIMAGE_FORMAT_PNG);
			m_msgBoxView.m_icnStop.Load(skinBasePath + L"\\msgbox_iconstop_qvga.png", CXIMAGE_FORMAT_PNG);
			m_msgBoxView.m_icnWarning.Load(skinBasePath + L"\\msgbox_iconwarning_qvga.png", CXIMAGE_FORMAT_PNG);

			// normal
			AddDynamicSet(m_msgBoxView.m_arrDynamicImages, NORMAL, skinBasePath + L"\\msgbox_button_normal_left_qvga.png", 
				           skinBasePath + L"\\msgbox_button_normal_center_qvga.png",
						   skinBasePath + L"\\msgbox_button_normal_right_qvga.png");

			// pressed
			AddDynamicSet(m_msgBoxView.m_arrDynamicImages, PUSHED, skinBasePath + L"\\msgbox_button_pressed_left_qvga.png", 
				           skinBasePath + L"\\msgbox_button_pressed_center_qvga.png",
						   skinBasePath + L"\\msgbox_button_pressed_right_qvga.png");
		}

		// load skin settings
		CSimpleIniW ini(TRUE, TRUE, TRUE);
		SI_Error rc = ini.LoadFile(skinBasePath + L"\\settings_fingermsgbox.ini");

		// load background and selected color
	
		COLORREF clValue = 0;
		m_msgBoxView.m_clBkg         = (StringRGBToColor(ini.GetValue(L"colors", L"BkgColor"), clValue)) ? clValue : RGB(255,255,255);
		m_msgBoxView.m_clCaptionText = (StringRGBToColor(ini.GetValue(L"colors", L"CaptionTextColor"), clValue)) ? clValue : RGB(255,255,255);
		m_msgBoxView.m_clText        = (StringRGBToColor(ini.GetValue(L"colors", L"TextColor"), clValue)) ? clValue : RGB(0,0,0);
		m_msgBoxView.m_clBtnText     = (StringRGBToColor(ini.GetValue(L"colors", L"ButtonTextColor"), clValue)) ? clValue : RGB(0,0,0);
		m_msgBoxView.m_clBtnSelText  = (StringRGBToColor(ini.GetValue(L"colors", L"SelButtonTextColor"), clValue)) ? clValue : RGB(255,255,255);
		m_msgBoxView.m_clLine        = (StringRGBToColor(ini.GetValue(L"colors", L"LineColor"), clValue)) ? clValue : RGB(160,160,160);


		if (!(m_fText.IsNull())) m_fText.DeleteObject();
		if (!(m_fCaption.IsNull())) m_fCaption.DeleteObject();
		if (!(m_fBtn.IsNull())) m_fBtn.DeleteObject();

		LOGFONT lf;
		if (StringToLogFont(ini.GetValue(L"fonts", L"TextFont"), lf))
		{
			m_fText.CreateFontIndirect(&lf);
		}
		if (StringToLogFont(ini.GetValue(L"fonts", L"CaptionFont"), lf))
		{
			m_fCaption.CreateFontIndirect(&lf);
		}
		if (StringToLogFont(ini.GetValue(L"fonts", L"ButtonFont"), lf))
		{
			m_fBtn.CreateFontIndirect(&lf);
		}

		m_msgBoxView.m_fText = m_fText;
		m_msgBoxView.m_fCaption = m_fCaption;
		m_msgBoxView.m_fBtn = m_fBtn;

		//sounds
		m_szDefaultSound   = ini.GetValue(L"sounds", L"DefaultSound"  );
		m_szErrorSound     = ini.GetValue(L"sounds", L"ErrorSound"    );
		m_szWarningSound   = ini.GetValue(L"sounds", L"WarningSound"  );
		m_szInfoSound      = ini.GetValue(L"sounds", L"InfoSound"     );
		m_szQuestionSound  = ini.GetValue(L"sounds", L"QuestionSound" );


		//general options
		LPCWSTR lpwszCenterCaption = ini.GetValue(L"general", L"CenterCaption");
		if (lstrcmpi(lpwszCenterCaption, L"true") == 0)
			m_msgBoxView.m_bCenterCaption = TRUE;
		else
			m_msgBoxView.m_bCenterCaption = FALSE;

		// list of excluded apps
		LoadExclusionList(m_excludedApps, L"Software\\FingerMsgbox");

		LoadWndExclusionList(m_excludedWnds, L"Software\\FingerMsgbox");
	}

public:
	static HRESULT ActivatePreviousInstance(HINSTANCE hInstance)
	{
		const TCHAR* pszMutex = L"FINGERMSGBOXMUTEX";
		const TCHAR* pszClass = L"FINGER_MSGBOX";

		const DWORD dRetryInterval = 100; 

		const int iMaxRetries = 25;

		for(int i = 0; i < iMaxRetries; ++i)
		{
			HANDLE hMutex = CreateMutex(NULL, FALSE, pszMutex);

			DWORD dw = GetLastError();

			if(hMutex == NULL)
			{
				HRESULT hr = (dw == ERROR_INVALID_HANDLE) ? E_INVALIDARG : E_FAIL;
				return hr;
			}

			if(dw == ERROR_ALREADY_EXISTS)
			{
				CloseHandle(hMutex);

				HWND hwnd = FindWindow(pszClass, NULL);

				if(hwnd == NULL)
				{
					Sleep(dRetryInterval);
					continue;
				}
				else
				{
					if(SetForegroundWindow(reinterpret_cast<HWND>(reinterpret_cast<ULONG>(hwnd) | 0x1)) != 0)
					{
						return S_FALSE;
					}
				}
			}
			else
			{
				return S_OK;
			}
		}

		return S_OK;
	}

	void SwitchToMsgBoxView()
	{
		m_hWndClient = m_msgBoxView;

		m_aboutView.ShowWindow(SW_HIDE);
		m_aboutView.SetWindowLongPtr(GWL_ID, 0);

		m_msgBoxView.ShowWindow(SW_SHOW);
		m_msgBoxView.SetWindowLongPtr(GWL_ID, ATL_IDW_PANE_FIRST);
		m_msgBoxView.SetFocus();
	}

	void SwitchToAboutView()
	{
		m_hWndClient = m_aboutView;

		m_msgBoxView.ShowWindow(SW_HIDE);
		m_msgBoxView.SetWindowLongPtr(GWL_ID, 0);

		m_aboutView.ShowWindow(SW_SHOW);
		m_aboutView.SetWindowLongPtr(GWL_ID, ATL_IDW_PANE_FIRST);
		m_aboutView.SetFocus();
		UpdateLayout();
	}

	void PlayMessageBoxSound(int uType)
	{
		if (!(IsEvtSoundActive()))
			return;

		CString fileName;
		if ((uType & MB_ICONEXCLAMATION) || (uType & MB_ICONWARNING))
		{
			fileName = m_szWarningSound;
			goto soundend;
		}

		if ((uType & MB_ICONINFORMATION) || (uType & MB_ICONASTERISK))
		{
			fileName = m_szInfoSound;
			goto soundend;
		}

		if (uType & MB_ICONQUESTION)
		{
			fileName = m_szQuestionSound;
			goto soundend;
		}

		if ((uType & MB_ICONSTOP) || (uType & MB_ICONERROR) || (uType & MB_ICONHAND))
		{
			fileName = m_szErrorSound;
			goto soundend;
		}
soundend:
		if (fileName.IsEmpty())
			fileName = m_szDefaultSound;
		PlaySound(fileName, NULL, SND_ASYNC | SND_FILENAME | SND_NODEFAULT);
	}


protected:
	HWND m_hForeWnd;
	CxImage m_imgBkg;

	BOOL m_bDisabledTransp;
	COLORREF m_clNoTranspBackground;
	DWORD m_iTransp;
	CSimpleArray<CString, CStringEqualHelper<CString>> m_excludedApps;
	CSimpleArray<CString, CStringEqualHelper<CString>> m_excludedWnds;
	BOOL m_bDisabled;
	CMenu m_menuConfig;
	CFontHandle m_fText;
	CFontHandle m_fCaption;
	CFontHandle m_fBtn;

	CString m_szDefaultSound;
	CString m_szErrorSound;
	CString m_szWarningSound;
	CString m_szInfoSound;
	CString m_szQuestionSound;

private:

	BOOL IsEvtSoundActive()
	{
		BOOL bRes = TRUE;
	    DWORD dwMute = 0;
		HRESULT hr = RegistryGetDWORD(HKEY_CURRENT_USER, L"ControlPanel\\Volume", L"Mute", &dwMute);
		if (SUCCEEDED(hr))
		{
			if ( ! (dwMute & MASK_EVENTMUTE) )
				bRes = FALSE;
		}

		return bRes;
	}
};



<file_sep>/7-Zip/CPP/7zip/Compress/PpmdEncoder.cpp
// PpmdEncoder.cpp
// 2009-05-30 : <NAME> : Public domain

#include "StdAfx.h"

// #include <fstream.h>
// #include <iomanip.h>

#include "../Common/StreamUtils.h"

#include "PpmdEncoder.h"

namespace NCompress {
namespace NPpmd {

const UInt32 kMinMemSize = (1 << 11);
const UInt32 kMinOrder = 2;

/*
UInt32 g_NumInner = 0;
UInt32 g_InnerCycles = 0;

UInt32 g_Encode2 = 0;
UInt32 g_Encode2Cycles = 0;
UInt32 g_Encode2Cycles2 = 0;

class CCounter
{
public:
  CCounter() {}
  ~CCounter()
  {
    ofstream ofs("Res.dat");
    ofs << "innerEncode1    = " << setw(10) << g_NumInner << endl;
    ofs << "g_InnerCycles   = " << setw(10) << g_InnerCycles << endl;
    ofs << "g_Encode2       = " << setw(10) << g_Encode2 << endl;
    ofs << "g_Encode2Cycles = " << setw(10) << g_Encode2Cycles << endl;
    ofs << "g_Encode2Cycles2= " << setw(10) << g_Encode2Cycles2 << endl;
    
  }
};
CCounter g_Counter;
*/

STDMETHODIMP CEncoder::SetCoderProperties(const PROPID *propIDs, const PROPVARIANT *props, UInt32 numProps)
{
  for (UInt32 i = 0; i < numProps; i++)
  {
    const PROPVARIANT &prop = props[i];
    switch(propIDs[i])
    {
      case NCoderPropID::kUsedMemorySize:
        if (prop.vt != VT_UI4)
          return E_INVALIDARG;
        if (prop.ulVal < kMinMemSize || prop.ulVal > kMaxMemBlockSize)
          return E_INVALIDARG;
        _usedMemorySize = (UInt32)prop.ulVal;
        break;
      case NCoderPropID::kOrder:
        if (prop.vt != VT_UI4)
          return E_INVALIDARG;
        if (prop.ulVal < kMinOrder || prop.ulVal > kMaxOrderCompress)
          return E_INVALIDARG;
        _order = (Byte)prop.ulVal;
        break;
      default:
        return E_INVALIDARG;
    }
  }
  return S_OK;
}

STDMETHODIMP CEncoder::WriteCoderProperties(ISequentialOutStream *outStream)
{
  const UInt32 kPropSize = 5;
  Byte props[kPropSize];
  props[0] = _order;
  for (int i = 0; i < 4; i++)
    props[1 + i] = Byte(_usedMemorySize >> (8 * i));
  return WriteStream(outStream, props, kPropSize);
}

const UInt32 kUsedMemorySizeDefault = (1 << 24);
const int kOrderDefault = 6;

CEncoder::CEncoder():
  _usedMemorySize(kUsedMemorySizeDefault),
  _order(kOrderDefault)
{
}


HRESULT CEncoder::CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
      const UInt64 * /* inSize */, const UInt64 * /* outSize */, ICompressProgressInfo *progress)
{
  if (!_inStream.Create(1 << 20))
    return E_OUTOFMEMORY;
  if (!_rangeEncoder.Create(1 << 20))
    return E_OUTOFMEMORY;
  if (!_info.SubAllocator.StartSubAllocator(_usedMemorySize))
    return E_OUTOFMEMORY;

  _inStream.SetStream(inStream);
  _inStream.Init();

  _rangeEncoder.SetStream(outStream);
  _rangeEncoder.Init();

  CEncoderFlusher flusher(this);

  _info.MaxOrder = 0;
  _info.StartModelRare(_order);

  for (;;)
  {
    UInt32 size = (1 << 18);
    do
    {
      Byte symbol;
      if (!_inStream.ReadByte(symbol))
      {
        // here we can write End Mark for stream version.
        // In current version this feature is not used.
        // _info.EncodeSymbol(-1, &_rangeEncoder);
        return S_OK;
      }
      _info.EncodeSymbol(symbol, &_rangeEncoder);
    }
    while (--size != 0);
    if (progress != NULL)
    {
      UInt64 inSize = _inStream.GetProcessedSize();
      UInt64 outSize = _rangeEncoder.GetProcessedSize();
      RINOK(progress->SetRatioInfo(&inSize, &outSize));
    }
  }
}

STDMETHODIMP CEncoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
    const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress)
{
  try { return CodeReal(inStream, outStream, inSize, outSize, progress); }
  catch(const COutBufferException &e) { return e.ErrorCode; }
  catch(const CInBufferException &e) { return e.ErrorCode; }
  catch(...) { return E_FAIL; }
}

}}
<file_sep>/FingerSuite/Common/utils.h
#ifndef UTILS_H
#define UTILS_H

#pragma once

//#include "resource.h"
#include <snapi.h>
#include <regext.h>

#include "log\logger.h"

#ifndef __ATLMISC_H__
	#error utils.h requires atlmisc.h to be included first
#endif

template <class T>
class CStringEqualHelper
{
public:
	static bool IsEqual(const T& t1, const T& t2)
	{
		if (t1.Compare(t2) == 0)
			return true;
		else
			return false;
	}
};

//#ifdef __cplusplus
//extern "C" {
//#endif

inline CString ErrorString(DWORD err)
{
	CString Error;
	LPTSTR s;
	if(::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
		FORMAT_MESSAGE_FROM_SYSTEM,
		NULL,
		err,
		0,
		(LPTSTR)&s,
		0,
		NULL) == 0)
	{ /* failed */
		// Unknown error code %08x (%d)
		CString fmt = L"Unknown error 0x%08x (%d)\n";
		CString t;
		t.Format(fmt, err, LOWORD(err));
		Error = t;
	} /* failed */
	else
	{ /* success */
		LPTSTR p = _tcschr(s, _T('\r'));
		if(p != NULL)
		{ /* lose CRLF */
			*p = _T('\0');
		} /* lose CRLF */
		Error = s;
		::LocalFree(s);
	} /* success */
	return Error;
} // ErrorString


inline HBITMAP LoadImageFile( LPCTSTR szFileName )
{
	CString szImage = szFileName;
	CBitmapHandle hBmp = szImage.Find( L".bmp") != -1 ? 
		::SHLoadDIBitmap( szFileName) : ::SHLoadImageFile( szFileName);

	if( hBmp.IsNull())
	{
		wprintf(L"Cannot load image from: %s\n", szFileName);
	}
	return hBmp;
}	


inline int ParseTokens( CSimpleArray<CString>& result, CString szString, CString szTokens = ",;" )
{
	int iNum = 0;

	int iCurrPos= 0;
	CString subString;

	while( -1 != ( iCurrPos = szString.FindOneOf( szTokens ) ) )
	{
		iNum++;
		result.Add( szString.Left( iCurrPos ) );
		szString = szString.Right( szString.GetLength() - iCurrPos - 1 );
	}

	if ( szString.GetLength() > 0 )
	{
		// the last one...
		iNum++;
		result.Add( szString );
	}

	return iNum;
}



inline void DrawTransparent(HDC hdc, int x, int y, HBITMAP

					 hBitmap, COLORREF crColour)

{

	COLORREF crOldBack = SetBkColor(hdc, RGB(255, 255, 255));

	COLORREF crOldText = SetTextColor(hdc, RGB(0, 0, 0));

	HDC dcImage, dcTrans;


	// Create two memory dcs for the image and the mask

	dcImage=CreateCompatibleDC(hdc);

	dcTrans=CreateCompatibleDC(hdc);


	// Select the image into the appropriate dc

	HBITMAP pOldBitmapImage = (HBITMAP)SelectObject(dcImage, hBitmap);


	// Create the mask bitmap

	BITMAP bitmap;

	GetObject(hBitmap, sizeof(BITMAP), &bitmap);

	HBITMAP bitmapTrans=CreateBitmap(bitmap.bmWidth, bitmap.bmHeight, 1, 1, NULL);


	// Select the mask bitmap into the appropriate dc

	HBITMAP pOldBitmapTrans = (HBITMAP)SelectObject(dcTrans, bitmapTrans);


	// Build mask based on transparent colour

	SetBkColor(dcImage, crColour);

	BitBlt(dcTrans, 0, 0, bitmap.bmWidth, bitmap.bmHeight, dcImage, 0, 0, SRCCOPY);


	// Do the work - True Mask method - cool if not actual display

	BitBlt(hdc, x, y, bitmap.bmWidth, bitmap.bmHeight, dcImage, 0, 0, SRCINVERT);

	BitBlt(hdc, x, y, bitmap.bmWidth, bitmap.bmHeight, dcTrans, 0, 0, SRCAND);

	BitBlt(hdc, x, y, bitmap.bmWidth, bitmap.bmHeight, dcImage, 0, 0, SRCINVERT);


	// Restore settings

	SelectObject(dcImage, pOldBitmapImage);

	SelectObject(dcTrans, pOldBitmapTrans);

	SetBkColor(hdc, crOldBack);

	SetTextColor(hdc, crOldText);

}

/*
void FlipBitmap(CBitmap src)
{
	CDC dc; dc.CreateCompatibleDC(NULL);
	SIZE sz; src.GetSize(sz);
	CBitmap oldBmp = dc.SelectBitmap(src);
	dc.StretchBlt(0, 0, sz.cx, sz.cy, dc,  0,  sz.cy-1, sz.cx, -sz.cy, SRCCOPY );
	dc.SelectBitmap(oldBmp);
}
*/

inline BOOL RegReadDWORD(HKEY hKey, LPCTSTR lpszSubkey, LPCTSTR lpszName, DWORD& dwValue)
{
	BOOL bRet = TRUE;
	HKEY hConf;
	if (ERROR_SUCCESS == RegOpenKeyEx(hKey, 
								  lpszSubkey,
								  0,
								  0,
								  &hConf))
	{
		DWORD dwSize = sizeof(DWORD);
		DWORD dwType = REG_DWORD;
		DWORD dwNewValue;
		if (ERROR_SUCCESS == RegQueryValueEx(hConf, 
										lpszName,
										NULL,
										&dwType, 
										(LPBYTE)&dwNewValue,
										&dwSize))
		{
			// read dword 
			dwValue = dwNewValue;
		}
		else
			bRet = FALSE;
		RegCloseKey(hConf);
	}		
	else
		bRet = FALSE;
	return bRet;
}


inline BOOL RegReadBOOL(HKEY hKey, LPCTSTR lpszSubkey, LPCTSTR lpszName, BOOL& bValue)
{
	BOOL bRet = TRUE;
	HKEY hConf;
	if (ERROR_SUCCESS == RegOpenKeyEx(hKey, 
								  lpszSubkey,
								  0,
								  0,
								  &hConf))
	{
		DWORD dwSize = sizeof(DWORD);
		DWORD dwType = REG_DWORD;
		DWORD dwNewValue;
		if (ERROR_SUCCESS == RegQueryValueEx(hConf, 
										lpszName,
										NULL,
										&dwType, 
										(LPBYTE)&dwNewValue,
										&dwSize))
		{
			// read dword 
			bValue = (BOOL)dwNewValue;
		}
		else
			bRet = FALSE;
		RegCloseKey(hConf);
	}		
	else
		bRet = FALSE;
	return bRet;
}

inline BOOL RegReadColor(HKEY hKey, LPCTSTR lpszSubkey, LPCTSTR lpszName, COLORREF& clValue)
{
	BOOL bRet = TRUE;
	HKEY hConf;
	if (ERROR_SUCCESS == RegOpenKeyEx(hKey, 
								  lpszSubkey,
								  0,
								  0,
								  &hConf))
	{
		DWORD dwSize = 50;
		DWORD dwType = REG_SZ;
		BYTE data[50];
		ZeroMemory(data, 50);
		if (ERROR_SUCCESS == RegQueryValueEx(hConf, 
										lpszName,
										NULL,
										&dwType, 
										data,
										&dwSize))
		{
			// read sz 
			CString value = (WCHAR *)data;
			CSimpleArray<CString> colors;
			int n = ParseTokens(colors, value, " ");
			if (n == 3)
			{
				int r = _wtoi(  colors[0] );
				int g = _wtoi(  colors[1] );
				int b = _wtoi(  colors[2] );

				clValue = RGB(r,g,b);
			}
		}
		else
			bRet = FALSE;
		RegCloseKey(hConf);
	}		
	else
		bRet = FALSE;
	return bRet;
}


inline BOOL RegReadString(HKEY hKey, LPCTSTR lpszSubkey, LPCTSTR lpszName, LPWSTR szValue)
{
	BOOL bRet = TRUE;
	HKEY hConf;
	if (ERROR_SUCCESS == RegOpenKeyEx(hKey, 
								  lpszSubkey,
								  0,
								  0,
								  &hConf))
	{
		DWORD dwSize = MAX_PATH * 2;
		DWORD dwType = REG_SZ;
		BYTE data[MAX_PATH * 2];
		ZeroMemory(data, MAX_PATH * 2);
		if (ERROR_SUCCESS == RegQueryValueEx(hConf, 
										lpszName,
										NULL,
										&dwType, 
										data,
										&dwSize))
		{
			// read sz 
			lstrcpy(szValue, (WCHAR *)data);
		}
		else
			bRet = FALSE;
		RegCloseKey(hConf);
	}		
	else
		bRet = FALSE;
	return bRet;
}


inline void RegWriteColor(HKEY hKey, LPCTSTR lpszSubkey, LPCTSTR lpszName, COLORREF clValue)
{
	HKEY hConf;
	DWORD dwOptions = REG_OPTION_NON_VOLATILE;
	DWORD dwDisposition;
	if (ERROR_SUCCESS == RegCreateKeyEx(hKey, lpszSubkey, 0, NULL, dwOptions, 0, NULL, &hConf, &dwDisposition))
	{
		WCHAR buf[30];
		DWORD dwWrittenChar = wsprintf(buf, L"%d %d %d", GetRValue(clValue), GetGValue(clValue), GetBValue(clValue)) + 1;
		DWORD dwType = REG_SZ;
		RegSetValueEx(hConf, lpszName, 0, dwType, (BYTE*)buf, dwWrittenChar * sizeof(WCHAR));
		RegCloseKey(hConf);
	}
}

inline void RegWriteBOOL(HKEY hKey, LPCTSTR lpszSubkey, LPCTSTR lpszName, BOOL bValue)
{
	HKEY hConf;
	DWORD dwOptions = REG_OPTION_NON_VOLATILE;
	DWORD dwDisposition;
	if (ERROR_SUCCESS == RegCreateKeyEx(hKey, lpszSubkey, 0, NULL, dwOptions, 0, NULL, &hConf, &dwDisposition))
	{
		DWORD dwType = REG_DWORD;
		DWORD dwVal = (DWORD)bValue;
		RegSetValueEx(hConf, lpszName, 0, dwType, (CONST BYTE*)&dwVal, sizeof(DWORD));
		RegCloseKey(hConf);
	}
}

inline void RegWriteDWORD(HKEY hKey, LPCTSTR lpszSubkey, LPCTSTR lpszName, DWORD dwVal)
{
	HKEY hConf;
	DWORD dwOptions = REG_OPTION_NON_VOLATILE;
	DWORD dwDisposition;
	if (ERROR_SUCCESS == RegCreateKeyEx(hKey, lpszSubkey, 0, NULL, dwOptions, 0, NULL, &hConf, &dwDisposition))
	{
		DWORD dwType = REG_DWORD;
		RegSetValueEx(hConf, lpszName, 0, dwType, (CONST BYTE*)&dwVal, sizeof(DWORD));
		RegCloseKey(hConf);
	}
}

inline void RegWriteString(HKEY hKey, LPCTSTR lpszSubkey, LPCTSTR lpszName, LPCTSTR lpszValue, DWORD dwLength)
{
	HKEY hConf;
	DWORD dwOptions = REG_OPTION_NON_VOLATILE;
	DWORD dwDisposition;
	if (ERROR_SUCCESS == RegCreateKeyEx(hKey, lpszSubkey, 0, NULL, dwOptions, 0, NULL, &hConf, &dwDisposition))
	{
		DWORD dwType = REG_SZ;
		RegSetValueEx(hConf, lpszName, 0, dwType, (BYTE*)lpszValue, (dwLength + 1) * sizeof(WCHAR));
		RegCloseKey(hConf);
	}
}

inline void LoadExclusionList(CSimpleArray<CString, CStringEqualHelper<CString>> &list, LPTSTR pszKey)
{
	list.RemoveAll();

	HKEY hConf;
	if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, 
		                              pszKey, // L"Software\\FingerMenu",
									  0,
									  0,
									  &hConf))
	{
		long lRes;
		DWORD dwIndex = -1;
		CString szProcessName;
		CString szValueName;
		do
		{
			WCHAR valueName[1024];
			DWORD cchValueName = 1024;
			BYTE data[1024];
			DWORD dwSize = 1024;
			DWORD dwType = REG_SZ;		
			ZeroMemory(data, sizeof(data));
			ZeroMemory(valueName, sizeof(valueName));
			dwIndex ++;
			if (ERROR_SUCCESS == (lRes = RegEnumValue(hConf,
				                                      dwIndex,
													  valueName,
													  &cchValueName,
													  NULL,
													  &dwType,
													  data,
													  &dwSize) ))
			{
				szValueName = valueName;
				szProcessName = (PWCHAR)data;
				
				if ((dwType == REG_SZ) && (szValueName.Find(L"ExcludedApp", 0) == 0))
				{
					list.Add(szProcessName);
				}
			}
		} while (lRes == ERROR_SUCCESS);
	}
}

inline void SaveExclusionList(CSimpleArray<CString, CStringEqualHelper<CString>> &list, LPTSTR pszKey)
{
	//WCHAR szKeyName[] = L"Software\\FingerMenu";
	// delete all registry key
	HKEY hConf;
	if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, 
								  pszKey,
								  0,
								  0,
								  &hConf))
	{

		for (int i = 0; i < 200; i++)
		{
			CString name; name.Format(L"ExcludedApp%02d", i);
			RegDeleteValue(hConf, name);
		}
		RegCloseKey(hConf);
	}

	for (int i = 0; i < list.GetSize(); i++)
	{
		CString name; name.Format(L"ExcludedApp%02d", i);
		RegWriteString(HKEY_LOCAL_MACHINE, pszKey, name, list[i], list[i].GetLength());
	}
}


inline void LoadWndExclusionList(CSimpleArray<CString, CStringEqualHelper<CString>> &list, LPTSTR pszKey)
{
	list.RemoveAll();

	HKEY hConf;
	if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, 
		                              pszKey, // L"Software\\FingerMenu",
									  0,
									  0,
									  &hConf))
	{
		long lRes;
		DWORD dwIndex = -1;
		CString szProcessName;
		CString szValueName;
		do
		{
			WCHAR valueName[1024];
			DWORD cchValueName = 1024;
			BYTE data[1024];
			DWORD dwSize = 1024;
			DWORD dwType = REG_SZ;		
			ZeroMemory(data, sizeof(data));
			ZeroMemory(valueName, sizeof(valueName));
			dwIndex ++;
			if (ERROR_SUCCESS == (lRes = RegEnumValue(hConf,
				                                      dwIndex,
													  valueName,
													  &cchValueName,
													  NULL,
													  &dwType,
													  data,
													  &dwSize) ))
			{
				szValueName = valueName;
				szProcessName = (PWCHAR)data;
				
				if ((dwType == REG_SZ) && (szValueName.Find(L"ExcludedWnd", 0) == 0))
				{
					list.Add(szProcessName);
				}
			}
		} while (lRes == ERROR_SUCCESS);
	}
}

inline void SaveWndExclusionList(CSimpleArray<CString, CStringEqualHelper<CString>> &list, LPTSTR pszKey)
{
	//WCHAR szKeyName[] = L"Software\\FingerMenu";
	// delete all registry key
	HKEY hConf;
	if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, 
								  pszKey,
								  0,
								  0,
								  &hConf))
	{

		for (int i = 0; i < 200; i++)
		{
			CString name; name.Format(L"ExcludedWnd%02d", i);
			RegDeleteValue(hConf, name);
		}
		RegCloseKey(hConf);
	}

	for (int i = 0; i < list.GetSize(); i++)
	{
		CString name; name.Format(L"ExcludedWnd%02d", i);
		RegWriteString(HKEY_LOCAL_MACHINE, pszKey, name, list[i], list[i].GetLength());
	}
}


inline void SplitString(CString Source, CString Deliminator, CSimpleArray<CString>& AddIt, BOOL bAddEmpty)
{
	// initialize the variables
	CString		 newCString = Source;
	CString		 tmpCString = "";
	CString		 AddCString = "";

	int pos1 = 0;
	int pos = 0;

	if (Deliminator.IsEmpty()) {
		// Add default [comma] if empty!
		// acknowledgement: <NAME> [<EMAIL>]
		Deliminator = ","; 
	}

	// do this loop as long as you have a deliminator
	do {
		// set to zero
		pos1 = 0;
		// position of deliminator starting at pos1 (0)
		pos = newCString.Find(Deliminator, pos1);
		// if the deliminator is found...
		if ( pos != -1 ) {
			// load a new var with the info left
			// of the position
			CString AddCString = newCString.Left(pos);
			if (!AddCString.IsEmpty()) {
				// if there is a string to add, then
				// add it to the Array
				AddIt.Add(AddCString);
			}
			else if (bAddEmpty) {
				// if empty strings are ok, then add them
				AddIt.Add(AddCString);
			}

			// make a copy of the of this var. with the info
			// right of the deliminator
			tmpCString = newCString.Mid(pos + Deliminator.GetLength());
			
			// reset this var with new info
			newCString = tmpCString;
		}
	} while ( pos != -1 );
	
	if (!newCString.IsEmpty()) {
		// as long as the variable is not emty, add it
		AddIt.Add(newCString);
	}

}

inline BOOL StringRGBToColor(LPCTSTR lpszColor, COLORREF &clValue)
{
	BOOL bRet = FALSE;

	if (lpszColor == NULL)
		return FALSE;

	CString value = lpszColor;
	CSimpleArray<CString> colors;
	int n = ParseTokens(colors, value, " ");
	if (n == 3)
	{
		int r = _wtoi(  colors[0] );
		int g = _wtoi(  colors[1] );
		int b = _wtoi(  colors[2] );

		bRet = TRUE;
		clValue = RGB(r,g,b);
	}
	return bRet;
}

inline BOOL StringToLogFont(LPCTSTR lpszFont, LOGFONT &lf)
{
	//HDC hDC = ::GetDC(0);
	BOOL bRet = TRUE;
	CDCHandle dc(::GetDC(0));

	CFont font = dc.GetCurrentFont();
	font.GetLogFont(lf);

	if (lpszFont == NULL)
	{
		return bRet;
	}
	
	CString value = lpszFont;
	CSimpleArray<CString> values;
	int n = ParseTokens(values, value, ",");

	//ZeroMemory(&lf, sizeof(LOGFONT));
	if (n >= 1)
	{

		// weight
		if (lstrcmpi(values[0], L"regular") == 0)
			lf.lfWeight = FW_NORMAL;
		if (lstrcmpi(values[0], L"italic") == 0)
		{
			lf.lfWeight = FW_NORMAL;
			lf.lfItalic = TRUE;
		}
		if (lstrcmpi(values[0], L"bold") == 0)
			lf.lfWeight = FW_BOLD;
		if (lstrcmpi(values[0], L"bold italic") == 0)
		{
			lf.lfWeight = FW_BOLD;
			lf.lfItalic = TRUE;
		}
	}

	if (n >= 2)
	{
		// height
		values[1].Replace(L"p", L" ");
		int l = _wtoi(values[1]);
		if (l > 0)
		{
			lf.lfHeight = -::MulDiv(l, dc.GetDeviceCaps(LOGPIXELSY), 72);
		}
	}


	// face
	if (n >= 3)
	{
		ZeroMemory(lf.lfFaceName, LF_FACESIZE);
		lstrcpy(lf.lfFaceName, values[2]);	
	}

	// charset
	/*
	if (lstrcmpi(values[3], L"ansi"        ) == 0) lf.lfCharSet = ANSI_CHARSET;
	if (lstrcmpi(values[3], L"baltic"      ) == 0) lf.lfCharSet = BALTIC_CHARSET;
	if (lstrcmpi(values[3], L"chinesebig5" ) == 0) lf.lfCharSet = CHINESEBIG5_CHARSET;
	if (lstrcmpi(values[3], L"default"     ) == 0) lf.lfCharSet = DEFAULT_CHARSET;
	if (lstrcmpi(values[3], L"easteurope"  ) == 0) lf.lfCharSet = EASTEUROPE_CHARSET;
	if (lstrcmpi(values[3], L"gb2312"      ) == 0) lf.lfCharSet = GB2312_CHARSET;
	if (lstrcmpi(values[3], L"greek"       ) == 0) lf.lfCharSet = GREEK_CHARSET;
	if (lstrcmpi(values[3], L"hangul"      ) == 0) lf.lfCharSet = HANGUL_CHARSET;
	if (lstrcmpi(values[3], L"mac"         ) == 0) lf.lfCharSet = MAC_CHARSET;
	if (lstrcmpi(values[3], L"oem"         ) == 0) lf.lfCharSet = OEM_CHARSET;
	if (lstrcmpi(values[3], L"russian"     ) == 0) lf.lfCharSet = RUSSIAN_CHARSET;
	if (lstrcmpi(values[3], L"shiftjis"    ) == 0) lf.lfCharSet = SHIFTJIS_CHARSET;
	if (lstrcmpi(values[3], L"symbol"      ) == 0) lf.lfCharSet = SYMBOL_CHARSET;
	if (lstrcmpi(values[3], L"turkish"     ) == 0) lf.lfCharSet = TURKISH_CHARSET;
	if (lstrcmpi(values[3], L"johab"       ) == 0) lf.lfCharSet = JOHAB_CHARSET;
	if (lstrcmpi(values[3], L"hebrew"      ) == 0) lf.lfCharSet = HEBREW_CHARSET;
	if (lstrcmpi(values[3], L"arabic"      ) == 0) lf.lfCharSet = ARABIC_CHARSET;
	if (lstrcmpi(values[3], L"thai"        ) == 0) lf.lfCharSet = THAI_CHARSET;
	*/
	return bRet;
}



inline LPWSTR LoadResourceString(UINT uID)
{

	LPWSTR lpOutput = new WCHAR[50];
	ZeroMemory(lpOutput, 50);
	int nCharCopied = ::LoadString(ModuleHelper::GetResourceInstance(), uID, lpOutput, 50);

	if (nCharCopied == 0)
		return NULL;

	return lpOutput;
}


inline BOOL IsDeviceLocked()
{
	BOOL bRes = FALSE;
	DWORD dwLockState = 0;
	RegistryGetDWORD(SN_LOCK_ROOT, SN_LOCK_PATH, SN_LOCK_VALUE, &dwLockState);
	if (dwLockState & SN_LOCK_BITMASK_KEYLOCKED)
		bRes = TRUE;

	return bRes;
}


// remote message
inline LPVOID PrepareRemoteMessage(LPHANDLE lphFile, DWORD dwBufferSize)
{
	LPVOID pViewMMFFile = NULL;

	*lphFile = ::CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, dwBufferSize + 1, L"SENDMESSAGEFILEMAP");              
	if ( *lphFile )
	{
		pViewMMFFile = MapViewOfFile(*lphFile, FILE_MAP_ALL_ACCESS, 0, 0, 0);                         
	}

	return pViewMMFFile;
}

inline void CloseRemoteMessage(HANDLE hFile, LPVOID pView)
{
	UnmapViewOfFile(pView);
	CloseHandle(hFile);
}


inline LRESULT SendMessageRemote(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, DWORD dwLParamSize = 0, UINT uTimeout = 0)
{
	LRESULT lResult = 0;
	DWORD dwResult;
	if (dwLParamSize == 0)
	{
		if (uTimeout == 0)
			lResult = ::SendMessage(hWnd, msg, wParam, lParam);
		else
			// TODO
			lResult = ::SendMessageTimeout(hWnd, msg, wParam, lParam, SMTO_NORMAL, uTimeout, &dwResult);
	}
	else
	{
		HANDLE hFileMMF = NULL;
		HANDLE pViewMMFFile = NULL;
		

		hFileMMF = ::CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, dwLParamSize + 1, L"SENDMESSAGEFILEMAP");              
		if ( hFileMMF )
		{
			pViewMMFFile = MapViewOfFile(hFileMMF, FILE_MAP_ALL_ACCESS, 0, 0, 0);                         
		}

		memcpy(pViewMMFFile, (LPVOID)lParam, dwLParamSize);

		if (uTimeout == 0)
			lResult = ::SendMessage(hWnd, msg, wParam, (LPARAM)pViewMMFFile);
		else
			// TODO
			lResult = ::SendMessageTimeout(hWnd, msg, wParam, (LPARAM)pViewMMFFile, SMTO_NORMAL, uTimeout, &dwResult); 

		UnmapViewOfFile(pViewMMFFile);
		CloseHandle(hFileMMF);

		hFileMMF = NULL;
		pViewMMFFile = NULL;
	}

	return lResult;
}

inline LRESULT CallRemoteWindowProc2(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, DWORD dwLParamSize = 0)
{
	LONG wndProc = ::GetWindowLong(hWnd, GWL_WNDPROC);
	LRESULT lResult = 0;

	if (dwLParamSize == 0)
	{
		lResult = ::CallWindowProc((WNDPROC)wndProc, hWnd, msg, wParam, lParam);
	}
	else
	{
		HANDLE hFileMMF = NULL;
		HANDLE pViewMMFFile = NULL;
		


		hFileMMF = ::CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, dwLParamSize + 1, L"SENDMESSAGEFILEMAP");              
		if ( hFileMMF )
		{
			pViewMMFFile = MapViewOfFile(hFileMMF, FILE_MAP_ALL_ACCESS, 0, 0, 0);                         
		}

		memcpy(pViewMMFFile, (LPVOID)lParam, dwLParamSize);

		lResult = ::CallWindowProc((WNDPROC)wndProc, hWnd, msg, wParam, (LPARAM)pViewMMFFile); 

		UnmapViewOfFile(pViewMMFFile);
		CloseHandle(hFileMMF);
	}
	return lResult;
}

//#ifdef __cplusplus
//}
//#endif

#endif //UTILS_H
<file_sep>/7-Zip/CPP/7zip/MyVersion.h
#define MY_VER_MAJOR 9
#define MY_VER_MINOR 10
#define MY_VER_BUILD 0
#define MY_VERSION "9.10 beta"
#define MY_7ZIP_VERSION "7-Zip 9.10 beta"
#define MY_DATE "2009-12-22"
#define MY_COPYRIGHT "Copyright (c) 1999-2009 <NAME>"
#define MY_VERSION_COPYRIGHT_DATE MY_VERSION "  " MY_COPYRIGHT "  " MY_DATE
<file_sep>/7-Zip/C/7zVersion.h
#define MY_VER_MAJOR 9
#define MY_VER_MINOR 10
#define MY_VER_BUILD 0
#define MY_VERSION "9.10 beta"
#define MY_DATE "2009-12-22"
#define MY_COPYRIGHT ": <NAME> : Public domain"
#define MY_VERSION_COPYRIGHT_DATE MY_VERSION " " MY_COPYRIGHT " : " MY_DATE
<file_sep>/SQLCEHelper/Source/Column.cpp

#include "stdafx.h"

using namespace OLEDBCLI;


//-------------------------------------------------------------------------
//
//	CColumn class
//
//-------------------------------------------------------------------------


CColumn::CColumn()
:	m_wType		(DBTYPE_EMPTY),
	m_ulOrdinal	(0),
	m_ulSize	(0),
	m_dwFlags	(0),
	m_bPrecision(0),
	m_bScale	(0),
	m_bRowGuid	(false),
	m_bIdentity	(false)
{
}


CColumn::CColumn(DBCOLUMNDESC* pColumnDesc, ULONG iOrdinal)
:	m_wType		(DBTYPE_EMPTY),
	m_ulOrdinal	(0),
	m_ulSize	(0),
	m_dwFlags	(0),
	m_bPrecision(0),
	m_bScale	(0),
	m_bRowGuid	(false),
	m_bIdentity	(false)
{
	ATLASSERT(pColumnDesc != NULL);

	m_strName		= pColumnDesc->dbcid.uName.pwszName;
	m_wType			= pColumnDesc->wType;
	m_ulSize		= pColumnDesc->ulColumnSize;
	m_bPrecision	= pColumnDesc->bPrecision;
	m_bScale		= pColumnDesc->bScale;
	m_dwFlags		= 0;
	m_ulOrdinal		= iOrdinal;
	m_bRowGuid		= false;
	m_bIdentity		= false;
	m_nSeed			= 0;
	m_nIncrement	= 0;

	ParseProperties(pColumnDesc);
}


CColumn::~CColumn()
{
}


// CColumn::ParseProperties
//
//		Parses the column description properties
//
void CColumn::ParseProperties(DBCOLUMNDESC* pColumnDesc)
{
	ULONG		cs,
				cp;
	DBPROPSET*	pPropSet = pColumnDesc->rgPropertySets;

	for(cs = 0; cs < pColumnDesc->cPropertySets; ++cs, ++pPropSet)
	{
		if(pPropSet->guidPropertySet == DBPROPSET_SSCE_COLUMN)
		{
			DBPROP*	pProp = pPropSet->rgProperties;

			for(cp = 0; cp < pPropSet->cProperties; ++cp, ++pProp)
			{
				if(pProp->dwPropertyID == DBPROP_SSCE2_COL_ROWGUID ||
				   pProp->dwPropertyID == DBPROP_SSCE3_COL_ROWGUID)
					m_bRowGuid = (pProp->vValue.boolVal == VARIANT_TRUE);
			}
		}

		if(pPropSet->guidPropertySet == DBPROPSET_COLUMN)
		{
			DBPROP*	pProp = pPropSet->rgProperties;
			
			for(cp = 0; cp < pPropSet->cProperties; ++cp, ++pProp)
			{
				switch(pProp->dwPropertyID)
				{
				case DBPROP_COL_DEFAULT:
					{
						VARIANT	varStr;
						HRESULT	hr;

						VariantInit(&varStr);
						hr = VariantChangeType(&varStr, &pProp->vValue, 0, VT_BSTR);
						if(SUCCEEDED(hr))
							m_strDefault = (LPCTSTR)varStr.bstrVal;
						else
							m_strDefault = _T("VariantChangeType failed.");
						VariantClear(&varStr);
					}
					break;

				case DBPROP_COL_AUTOINCREMENT:
					m_bIdentity = (pProp->vValue.boolVal == VARIANT_TRUE);
					break;

				case DBPROP_COL_SEED:
					m_nSeed = pProp->vValue.intVal;
					break;

				case DBPROP_COL_INCREMENT:
					m_nIncrement = pProp->vValue.intVal;
					break;

				case DBPROP_COL_NULLABLE:
					if(pProp->vValue.boolVal == VARIANT_TRUE)
						m_dwFlags |= DBCOLUMNFLAGS_ISNULLABLE;
					break;

				case DBPROP_COL_ISLONG:
					if(pProp->vValue.boolVal == VARIANT_TRUE)
						m_dwFlags |= DBCOLUMNFLAGS_ISLONG;
					break;

				case DBPROP_COL_FIXEDLENGTH:
					if(pProp->vValue.boolVal == VARIANT_TRUE)
						m_dwFlags |= DBCOLUMNFLAGS_ISFIXEDLENGTH;
					break;

				default:
					break;
				}
			}
		}

	}
}
<file_sep>/7-Zip/CPP/7zip/Archive/PeHandler.cpp
// PeHandler.cpp

#include "StdAfx.h"

#include "../../../C/CpuArch.h"

#include "Common/DynamicBuffer.h"
#include "Common/ComTry.h"
#include "Common/IntToString.h"
#include "Common/StringConvert.h"

#include "Windows/PropVariantUtils.h"
#include "Windows/Time.h"

#include "../Common/LimitedStreams.h"
#include "../Common/ProgressUtils.h"
#include "../Common/RegisterArc.h"
#include "../Common/StreamObjects.h"
#include "../Common/StreamUtils.h"

#include "../Compress/CopyCoder.h"

#define Get16(p) GetUi16(p)
#define Get32(p) GetUi32(p)
#define Get64(p) GetUi64(p)

using namespace NWindows;

namespace NArchive {
namespace NPe {

#define NUM_SCAN_SECTIONS_MAX (1 << 6)

#define PE_SIG 0x00004550
#define PE_OptHeader_Magic_32 0x10B
#define PE_OptHeader_Magic_64 0x20B

static AString GetDecString(UInt32 v)
{
  char sz[32];
  ConvertUInt64ToString(v, sz);
  return sz;
}

struct CVersion
{
  UInt16 Major;
  UInt16 Minor;

  void Parse(const Byte *buf);
  AString GetString() const { return GetDecString(Major) + '.' + GetDecString(Minor); }
};

void CVersion::Parse(const Byte *p)
{
  Major = Get16(p);
  Minor = Get16(p + 2);
}

static const UInt32 kHeaderSize =  4 + 20;

struct CHeader
{
  UInt16 NumSections;
  UInt32 Time;
  UInt32 PointerToSymbolTable;
  UInt32 NumSymbols;
  UInt16 OptHeaderSize;
  UInt16 Flags;
  UInt16 Machine;

  bool Parse(const Byte *buf);
};

bool CHeader::Parse(const Byte *p)
{
  if (Get32(p) != PE_SIG)
    return false;
  p += 4;
  Machine = Get16(p + 0);
  NumSections = Get16(p + 2);
  Time = Get32(p + 4);
  PointerToSymbolTable = Get32(p + 8);
  NumSymbols = Get32(p + 12);
  OptHeaderSize = Get16(p + 16);
  Flags = Get16(p + 18);
  return true;
}

struct CDirLink
{
  UInt32 Va;
  UInt32 Size;
  void Parse(const Byte *p);
};

void CDirLink::Parse(const Byte *p)
{
  Va = Get32(p);
  Size = Get32(p + 4);
};

enum
{
  kDirLink_Certificate = 4,
  kDirLink_Debug = 6
};

struct CDebugEntry
{
  UInt32 Flags;
  UInt32 Time;
  CVersion Ver;
  UInt32 Type;
  UInt32 Size;
  UInt32 Va;
  UInt32 Pa;
  
  void Parse(const Byte *p);
};

void CDebugEntry::Parse(const Byte *p)
{
  Flags = Get32(p);
  Time = Get32(p + 4);
  Ver.Parse(p + 8);
  Type = Get32(p + 12);
  Size = Get32(p + 16);
  Va = Get32(p + 20);
  Pa = Get32(p + 24);
}

static const UInt32 kNumDirItemsMax = 16;

struct COptHeader
{
  UInt16 Magic;
  Byte LinkerVerMajor;
  Byte LinkerVerMinor;

  UInt32 CodeSize;
  UInt32 InitDataSize;
  UInt32 UninitDataSize;
  
  // UInt32 AddressOfEntryPoint;
  // UInt32 BaseOfCode;
  // UInt32 BaseOfData32;
  // UInt64 ImageBase;

  UInt32 SectAlign;
  UInt32 FileAlign;

  CVersion OsVer;
  CVersion ImageVer;
  CVersion SubsysVer;
  
  UInt32 ImageSize;
  UInt32 HeadersSize;
  UInt32 CheckSum;
  UInt16 SubSystem;
  UInt16 DllCharacts;

  UInt64 StackReserve;
  UInt64 StackCommit;
  UInt64 HeapReserve;
  UInt64 HeapCommit;

  UInt32 NumDirItems;
  CDirLink DirItems[kNumDirItemsMax];

  bool Is64Bit() const { return Magic == PE_OptHeader_Magic_64; }
  bool Parse(const Byte *p, UInt32 size);

  int GetNumFileAlignBits() const
  {
    for (int i = 9; i <= 16; i++)
      if (((UInt32)1 << i) == FileAlign)
        return i;
    return -1;
  }
};

bool COptHeader::Parse(const Byte *p, UInt32 size)
{
  Magic = Get16(p);
  switch (Magic)
  {
    case PE_OptHeader_Magic_32:
    case PE_OptHeader_Magic_64:
      break;
    default:
      return false;
  }
  LinkerVerMajor = p[2];
  LinkerVerMinor = p[3];
  
  bool hdr64 = Is64Bit();
  
  CodeSize = Get32(p + 4);
  InitDataSize = Get32(p + 8);
  UninitDataSize = Get32(p + 12);

  // AddressOfEntryPoint = Get32(p + 16);
  // BaseOfCode = Get32(p + 20);
  // BaseOfData32 = Get32(p + 24);
  // ImageBase = hdr64 ? GetUi64(p + 24) :Get32(p + 28);

  SectAlign = Get32(p + 32);
  FileAlign = Get32(p + 36);

  OsVer.Parse(p + 40);
  ImageVer.Parse(p + 44);
  SubsysVer.Parse(p + 48);

  // reserved = Get32(p + 52);

  ImageSize = Get32(p + 56);
  HeadersSize = Get32(p + 60);
  CheckSum = Get32(p + 64);
  SubSystem = Get16(p + 68);
  DllCharacts = Get16(p + 70);

  if (hdr64)
  {
    StackReserve = Get64(p + 72);
    StackCommit = Get64(p + 80);
    HeapReserve = Get64(p + 88);
    HeapCommit = Get64(p + 96);
  }
  else
  {
    StackReserve = Get32(p + 72);
    StackCommit = Get32(p + 76);
    HeapReserve = Get32(p + 80);
    HeapCommit = Get32(p + 84);
  }
  UInt32 pos = (hdr64 ? 108 : 92);
  NumDirItems = Get32(p + pos);
  pos += 4;
  if (pos + 8 * NumDirItems != size)
    return false;
  for (UInt32 i = 0; i < NumDirItems && i < kNumDirItemsMax; i++)
    DirItems[i].Parse(p + pos + i * 8);
  return true;
}

static const UInt32 kSectionSize = 40;

struct CSection
{
  AString Name;

  UInt32 VSize;
  UInt32 Va;
  UInt32 PSize;
  UInt32 Pa;
  UInt32 Flags;
  UInt32 Time;
  // UInt16 NumRelocs;
  bool IsDebug;
  bool IsRealSect;

  CSection(): IsRealSect(false), IsDebug(false) {}
  UInt64 GetPackSize() const { return PSize; }

  void UpdateTotalSize(UInt32 &totalSize)
  {
    UInt32 t = Pa + PSize;
    if (t > totalSize)
      totalSize = t;
  }
  void Parse(const Byte *p);
};

static bool operator <(const CSection &a1, const CSection &a2) { return (a1.Pa < a2.Pa) || ((a1.Pa == a2.Pa) && (a1.PSize < a2.PSize)) ; }
static bool operator ==(const CSection &a1, const CSection &a2) { return (a1.Pa == a2.Pa) && (a1.PSize == a2.PSize); }

static AString GetName(const Byte *name)
{
  const int kNameSize = 8;
  AString res;
  char *p = res.GetBuffer(kNameSize);
  memcpy(p, name, kNameSize);
  p[kNameSize] = 0;
  res.ReleaseBuffer();
  return res;
}

void CSection::Parse(const Byte *p)
{
  Name = GetName(p);
  VSize = Get32(p + 8);
  Va = Get32(p + 12);
  PSize = Get32(p + 16);
  Pa = Get32(p + 20);
  // NumRelocs = Get16(p + 32);
  Flags = Get32(p + 36);
}

static const CUInt32PCharPair g_HeaderCharacts[] =
{
  { 1 << 1, "Executable" },
  { 1 << 13, "DLL" },
  { 1 << 8, "32-bit" },
  { 1 << 5, "LargeAddress" },
  { 1 << 0, "NoRelocs" },
  { 1 << 2, "NoLineNums" },
  { 1 << 3, "NoLocalSyms" },
  { 1 << 4, "AggressiveWsTrim" },
  { 1 << 9, "NoDebugInfo" },
  { 1 << 10, "RemovableRun" },
  { 1 << 11, "NetRun" },
  { 1 << 12, "System" },
  { 1 << 14, "UniCPU" },
  { 1 << 7, "Little-Endian" },
  { 1 << 15, "Big-Endian" }
};

static const CUInt32PCharPair g_DllCharacts[] =
{
  { 1 << 6, "Relocated" },
  { 1 << 7, "Integrity" },
  { 1 << 8, "NX-Compatible" },
  { 1 << 9, "NoIsolation" },
  { 1 << 10, "NoSEH" },
  { 1 << 11, "NoBind" },
  { 1 << 13, "WDM" },
  { 1 << 15, "TerminalServerAware" }
};

static const CUInt32PCharPair g_SectFlags[] =
{
  { 1 << 3, "NoPad" },
  { 1 << 5, "Code" },
  { 1 << 6, "InitializedData" },
  { 1 << 7, "UninitializedData" },
  { 1 << 9, "Comments" },
  { 1 << 11, "Remove" },
  { 1 << 12, "COMDAT" },
  { 1 << 15, "GP" },
  { 1 << 24, "ExtendedRelocations" },
  { 1 << 25, "Discardable" },
  { 1 << 26, "NotCached" },
  { 1 << 27, "NotPaged" },
  { 1 << 28, "Shared" },
  { 1 << 29, "Execute" },
  { 1 << 30, "Read" },
  { (UInt32)1 << 31, "Write" }
};

static const CUInt32PCharPair g_MachinePairs[] =
{
  { 0x014C, "x86" },
  { 0x0162, "MIPS-R3000" },
  { 0x0166, "MIPS-R4000" },
  { 0x0168, "MIPS-R10000" },
  { 0x0169, "MIPS-V2" },
  { 0x0184, "Alpha" },
  { 0x01A2, "SH3" },
  { 0x01A3, "SH3-DSP" },
  { 0x01A4, "SH3E" },
  { 0x01A6, "SH4" },
  { 0x01A8, "SH5" },
  { 0x01C0, "ARM" },
  { 0x01C2, "ARM-Thumb" },
  { 0x01F0, "PPC" },
  { 0x01F1, "PPC-FP" },
  { 0x0200, "IA-64" },
  { 0x0284, "Alpha-64" },
  { 0x0200, "IA-64" },
  { 0x0366, "MIPSFPU" },
  { 0x8664, "x64" },
  { 0x0EBC, "EFI" }
};

static const CUInt32PCharPair g_SubSystems[] =
{
  { 0, "Unknown" },
  { 1, "Native" },
  { 2, "Windows GUI" },
  { 3, "Windows CUI" },
  { 7, "Posix" },
  { 9, "Windows CE" },
  { 10, "EFI" },
  { 11, "EFI Boot" },
  { 12, "EFI Runtime" },
  { 13, "EFI ROM" },
  { 14, "XBOX" }
};

static const wchar_t *g_ResTypes[] =
{
  NULL,
  L"CURSOR",
  L"BITMAP",
  L"ICON",
  L"MENU",
  L"DIALOG",
  L"STRING",
  L"FONTDIR",
  L"FONT",
  L"ACCELERATOR",
  L"RCDATA",
  L"MESSAGETABLE",
  L"GROUP_CURSOR",
  NULL,
  L"GROUP_ICON",
  NULL,
  L"VERSION",
  L"DLGINCLUDE",
  NULL,
  L"PLUGPLAY",
  L"VXD",
  L"ANICURSOR",
  L"ANIICON",
  L"HTML",
  L"MANIFEST"
};

const UInt32 kFlag = (UInt32)1 << 31;
const UInt32 kMask = ~kFlag;

struct CTableItem
{
  UInt32 Offset;
  UInt32 ID;
};


const UInt32 kBmpHeaderSize = 14;
const UInt32 kIconHeaderSize = 22;

struct CResItem
{
  UInt32 Type;
  UInt32 ID;
  UInt32 Lang;

  UInt32 Size;
  UInt32 Offset;

  UInt32 HeaderSize;
  Byte Header[kIconHeaderSize]; // it must be enough for max size header.
  bool Enabled;

  bool IsNameEqual(const CResItem &item) const { return Lang == item.Lang; }
  UInt32 GetSize() const { return Size + HeaderSize; }
  bool IsBmp() const { return Type == 2; }
  bool IsIcon() const { return Type == 3; }
  bool IsString() const { return Type == 6; }
};

struct CStringItem
{
  UInt32 Lang;
  UInt32 Size;
  CByteDynamicBuffer Buf;

  void AddChar(Byte c);
  void AddWChar(UInt16 c);
};

void CStringItem::AddChar(Byte c)
{
  Buf.EnsureCapacity(Size + 2);
  Buf[Size++] = c;
  Buf[Size++] = 0;
}

void CStringItem::AddWChar(UInt16 c)
{
  if (c == '\n')
  {
    AddChar('\\');
    c = 'n';
  }
  Buf.EnsureCapacity(Size + 2);
  SetUi16(Buf + Size, c);
  Size += 2;
}

struct CMixItem
{
  int SectionIndex;
  int ResourceIndex;
  int StringIndex;

  bool IsSectionItem() const { return ResourceIndex < 0 && StringIndex < 0; };
};

struct CUsedBitmap
{
  CByteBuffer Buf;
public:
  void Alloc(size_t size)
  {
    size = (size + 7) / 8;
    Buf.SetCapacity(size);
    memset(Buf, 0, size);
  }
  void Free()
  {
    Buf.SetCapacity(0);
  }
  bool SetRange(size_t from, int size)
  {
    for (int i = 0; i < size; i++)
    {
      size_t pos = (from + i) >> 3;
      Byte mask = (Byte)(1 << ((from + i) & 7));
      Byte b = Buf[pos];
      if ((b & mask) != 0)
        return false;
      Buf[pos] = b | mask;
    }
    return true;
  }
};
 

class CHandler:
  public IInArchive,
  public IInArchiveGetStream,
  public CMyUnknownImp
{
  CMyComPtr<IInStream> _stream;
  CObjectVector<CSection> _sections;
  UInt32 _peOffset;
  CHeader _header;
  COptHeader _optHeader;
  UInt32 _totalSize;
  UInt32 _totalSizeLimited;

  CRecordVector<CResItem> _items;
  CObjectVector<CStringItem> _strings;

  CByteBuffer _buf;
  bool _oneLang;
  UString _resourceFileName;
  CUsedBitmap _usedRes;
  bool _parseResources;

  CRecordVector<CMixItem> _mixItems;

  HRESULT LoadDebugSections(IInStream *stream, bool &thereIsSection);
  HRESULT Open2(IInStream *stream, IArchiveOpenCallback *callback);
  bool Parse(const Byte *buf, UInt32 size);

  void AddResNameToString(UString &s, UInt32 id) const;
  UString GetLangPrefix(UInt32 lang);
  HRESULT ReadString(UInt32 offset, UString &dest) const;
  HRESULT ReadTable(UInt32 offset, CRecordVector<CTableItem> &items);
  bool ParseStringRes(UInt32 id, UInt32 lang, const Byte *src, UInt32 size);
  HRESULT OpenResources(int sectIndex, IInStream *stream, IArchiveOpenCallback *callback);
  void CloseResources();


  bool CheckItem(const CSection &sect, const CResItem &item, size_t offset) const
  {
    return item.Offset >= sect.Va && offset <= _buf.GetCapacity() && _buf.GetCapacity() - offset >= item.Size;
  }

public:
  MY_UNKNOWN_IMP2(IInArchive, IInArchiveGetStream)
  INTERFACE_IInArchive(;)
  STDMETHOD(GetStream)(UInt32 index, ISequentialInStream **stream);
};

bool CHandler::Parse(const Byte *buf, UInt32 size)
{
  UInt32 i;
  if (size < 512)
    return false;
  _peOffset = Get32(buf + 0x3C);
  if (_peOffset >= 0x1000 || _peOffset + 512 > size || (_peOffset & 7) != 0)
    return false;

  UInt32 pos = _peOffset;
  if (!_header.Parse(buf + pos))
    return false;
  if (_header.OptHeaderSize > 512 || _header.NumSections > NUM_SCAN_SECTIONS_MAX)
    return false;
  pos += kHeaderSize;

  if (!_optHeader.Parse(buf + pos, _header.OptHeaderSize))
    return false;

  pos += _header.OptHeaderSize;
  _totalSize = pos;

  for (i = 0; i < _header.NumSections; i++, pos += kSectionSize)
  {
    CSection sect;
    if (pos + kSectionSize > size)
      return false;
    sect.Parse(buf + pos);
    sect.IsRealSect = true;
    sect.UpdateTotalSize(_totalSize);
    _sections.Add(sect);
  }

  return true;
}

enum
{
  kpidSectAlign = kpidUserDefined,
  kpidFileAlign,
  kpidLinkerVer,
  kpidOsVer,
  kpidImageVer,
  kpidSubsysVer,
  kpidCodeSize,
  kpidImageSize,
  kpidInitDataSize,
  kpidUnInitDataSize,
  kpidHeadersSizeUnInitDataSize,
  kpidSubSystem,
  kpidDllCharacts,
  kpidStackReserve,
  kpidStackCommit,
  kpidHeapReserve,
  kpidHeapCommit,
};

STATPROPSTG kArcProps[] =
{
  { NULL, kpidCpu, VT_BSTR},
  { NULL, kpidBit64, VT_BOOL},
  { NULL, kpidCharacts, VT_BSTR},
  { NULL, kpidCTime, VT_FILETIME},
  { NULL, kpidPhySize, VT_UI4},
  { NULL, kpidHeadersSize, VT_UI4},
  { NULL, kpidChecksum, VT_UI4},
  { L"Image Size", kpidImageSize, VT_UI4},
  { L"Section Alignment", kpidSectAlign, VT_UI4},
  { L"File Alignment", kpidFileAlign, VT_UI4},
  { L"Code Size", kpidCodeSize, VT_UI4},
  { L"Initialized Data Size", kpidInitDataSize, VT_UI4},
  { L"Uninitialized Data Size", kpidUnInitDataSize, VT_UI4},
  { L"Linker Version", kpidLinkerVer, VT_BSTR},
  { L"OS Version", kpidOsVer, VT_BSTR},
  { L"Image Version", kpidImageVer, VT_BSTR},
  { L"Subsystem Version", kpidSubsysVer, VT_BSTR},
  { L"Subsystem", kpidSubSystem, VT_BSTR},
  { L"DLL Characteristics", kpidDllCharacts, VT_BSTR},
  { L"Stack Reserve", kpidStackReserve, VT_UI8},
  { L"Stack Commit", kpidStackCommit, VT_UI8},
  { L"Heap Reserve", kpidHeapReserve, VT_UI8},
  { L"Heap Commit", kpidHeapCommit, VT_UI8},
 };

STATPROPSTG kProps[] =
{
  { NULL, kpidPath, VT_BSTR},
  { NULL, kpidSize, VT_UI8},
  { NULL, kpidPackSize, VT_UI8},
  { NULL, kpidCharacts, VT_BSTR},
  { NULL, kpidOffset, VT_UI8},
  { NULL, kpidVa, VT_UI8}
};

IMP_IInArchive_Props
IMP_IInArchive_ArcProps_WITH_NAME

static void VerToProp(const CVersion &v, NCOM::CPropVariant &prop)
{
  StringToProp(v.GetString(), prop);
}

void TimeToProp(UInt32 unixTime, NCOM::CPropVariant &prop)
{
  if (unixTime != 0)
  {
    FILETIME ft;
    NTime::UnixTimeToFileTime(unixTime, ft);
    prop = ft;
  }
}

STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
{
  COM_TRY_BEGIN
  NCOM::CPropVariant prop;
  switch(propID)
  {
    case kpidSectAlign: prop = _optHeader.SectAlign; break;
    case kpidFileAlign: prop = _optHeader.FileAlign; break;
    case kpidLinkerVer:
    {
      CVersion v = { _optHeader.LinkerVerMajor, _optHeader.LinkerVerMinor };
      VerToProp(v, prop); break;
      break;
    }
  
    case kpidOsVer: VerToProp(_optHeader.OsVer, prop); break;
    case kpidImageVer: VerToProp(_optHeader.ImageVer, prop); break;
    case kpidSubsysVer: VerToProp(_optHeader.SubsysVer, prop); break;
    case kpidCodeSize: prop = _optHeader.CodeSize; break;
    case kpidInitDataSize: prop = _optHeader.InitDataSize; break;
    case kpidUnInitDataSize: prop = _optHeader.UninitDataSize; break;
    case kpidImageSize: prop = _optHeader.ImageSize; break;
    case kpidPhySize: prop = _totalSize; break;
    case kpidHeadersSize: prop = _optHeader.HeadersSize; break;
    case kpidChecksum: prop = _optHeader.CheckSum; break;
      
    case kpidCpu: PAIR_TO_PROP(g_MachinePairs, _header.Machine, prop); break;
    case kpidBit64: if (_optHeader.Is64Bit()) prop = true; break;
    case kpidSubSystem: PAIR_TO_PROP(g_SubSystems, _optHeader.SubSystem, prop); break;

    case kpidMTime:
    case kpidCTime: TimeToProp(_header.Time, prop); break;
    case kpidCharacts: FLAGS_TO_PROP(g_HeaderCharacts, _header.Flags, prop); break;
    case kpidDllCharacts: FLAGS_TO_PROP(g_DllCharacts, _optHeader.DllCharacts, prop); break;
    case kpidStackReserve: prop = _optHeader.StackReserve; break;
    case kpidStackCommit: prop = _optHeader.StackCommit; break;
    case kpidHeapReserve: prop = _optHeader.HeapReserve; break;
    case kpidHeapCommit: prop = _optHeader.HeapCommit; break;
  }
  prop.Detach(value);
  return S_OK;
  COM_TRY_END
}

void CHandler::AddResNameToString(UString &s, UInt32 id) const
{
  if ((id & kFlag) != 0)
  {
    UString name;
    if (ReadString(id & kMask, name) == S_OK)
    {
      if (name.IsEmpty())
        s += L"[]";
      else
      {
        if (name.Length() > 1 && name[0] == '"' && name.Back() == '"')
          name = name.Mid(1, name.Length() - 2);
        s += name;
      }
      return;
    }
  }
  wchar_t sz[32];
  ConvertUInt32ToString(id, sz);
  s += sz;
}

UString CHandler::GetLangPrefix(UInt32 lang)
{
  UString s = _resourceFileName;
  s += WCHAR_PATH_SEPARATOR;
  if (!_oneLang)
  {
    AddResNameToString(s, lang);
    s += WCHAR_PATH_SEPARATOR;
  }
  return s;
}

STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
{
  COM_TRY_BEGIN
  NCOM::CPropVariant prop;
  const CMixItem &mixItem = _mixItems[index];
  if (mixItem.StringIndex >= 0)
  {
    const CStringItem &item = _strings[mixItem.StringIndex];
    switch(propID)
    {
      case kpidPath: prop = GetLangPrefix(item.Lang) + L"string.txt"; break;
      case kpidSize:
      case kpidPackSize:
        prop = (UInt64)item.Size; break;
    }
  }
  else if (mixItem.ResourceIndex < 0)
  {
    const CSection &item = _sections[mixItem.SectionIndex];
    switch(propID)
    {
      case kpidPath: StringToProp(item.Name, prop); break;
      case kpidSize: prop = (UInt64)item.VSize; break;
      case kpidPackSize: prop = (UInt64)item.GetPackSize(); break;
      case kpidOffset: prop = item.Pa; break;
      case kpidVa: if (item.IsRealSect) prop = item.Va; break;
      case kpidMTime:
      case kpidCTime:
        TimeToProp(item.IsDebug ? item.Time : _header.Time, prop); break;
      case kpidCharacts: if (item.IsRealSect) FLAGS_TO_PROP(g_SectFlags, item.Flags, prop); break;
    }
  }
  else
  {
    const CResItem &item = _items[mixItem.ResourceIndex];
    switch(propID)
    {
      case kpidPath:
      {
        UString s = GetLangPrefix(item.Lang);
        {
          const wchar_t *p = NULL;
          if (item.Type < sizeof(g_ResTypes) / sizeof(g_ResTypes[0]))
            p = g_ResTypes[item.Type];
          if (p != 0)
            s += p;
          else
            AddResNameToString(s, item.Type);
        }
        s += WCHAR_PATH_SEPARATOR;
        AddResNameToString(s, item.ID);
        if (item.HeaderSize != 0)
        {
          if (item.IsBmp())
            s += L".bmp";
          else if (item.IsIcon())
            s += L".ico";
        }
        prop = s;
        break;
      }
      case kpidSize: prop = (UInt64)item.GetSize(); break;
      case kpidPackSize: prop = (UInt64)item.Size; break;
    }
  }
  prop.Detach(value);
  return S_OK;
  COM_TRY_END
}

HRESULT CHandler::LoadDebugSections(IInStream *stream, bool &thereIsSection)
{
  thereIsSection = false;
  const CDirLink &debugLink = _optHeader.DirItems[kDirLink_Debug];
  if (debugLink.Size == 0)
    return S_OK;
  const unsigned kEntrySize = 28;
  UInt32 numItems = debugLink.Size / kEntrySize;
  if (numItems * kEntrySize != debugLink.Size || numItems > 16)
    return S_FALSE;
  
  UInt64 pa = 0;
  int i;
  for (i = 0; i < _sections.Size(); i++)
  {
    const CSection &sect = _sections[i];
    if (sect.Va < debugLink.Va && debugLink.Va + debugLink.Size <= sect.Va + sect.PSize)
    {
      pa = sect.Pa + (debugLink.Va - sect.Va);
      break;
    }
  }
  if (i == _sections.Size())
  {
    return S_OK;
    // Exe for ARM requires S_OK
    // return S_FALSE;
  }
  
  CByteBuffer buffer;
  buffer.SetCapacity(debugLink.Size);
  Byte *buf = buffer;
  
  RINOK(stream->Seek(pa, STREAM_SEEK_SET, NULL));
  RINOK(ReadStream_FALSE(stream, buf, debugLink.Size));

  for (i = 0; i < (int)numItems; i++)
  {
    CDebugEntry de;
    de.Parse(buf);

    if (de.Size == 0)
      continue;
    
    CSection sect;
    sect.Name = ".debug" + GetDecString(i);
    
    sect.IsDebug = true;
    sect.Time = de.Time;
    sect.Va = de.Va;
    sect.Pa = de.Pa;
    sect.PSize = sect.VSize = de.Size;
    UInt32 totalSize = sect.Pa + sect.PSize;
    if (totalSize > _totalSize)
    {
      _totalSize = totalSize;
      _sections.Add(sect);
      thereIsSection = true;
    }
    buf += kEntrySize;
  }

  return S_OK;
}

HRESULT CHandler::ReadString(UInt32 offset, UString &dest) const
{
  if ((offset & 1) != 0 || offset >= _buf.GetCapacity())
    return S_FALSE;
  size_t rem = _buf.GetCapacity() - offset;
  if (rem < 2)
    return S_FALSE;
  unsigned length = Get16(_buf + offset);
  if ((rem - 2) / 2 < length)
    return S_FALSE;
  dest.Empty();
  offset += 2;
  for (unsigned i = 0; i < length; i++)
    dest += (wchar_t)Get16(_buf + offset + i * 2);
  return S_OK;
}

HRESULT CHandler::ReadTable(UInt32 offset, CRecordVector<CTableItem> &items)
{
  if ((offset & 3) != 0 || offset >= _buf.GetCapacity())
    return S_FALSE;
  size_t rem = _buf.GetCapacity() - offset;
  if (rem < 16)
    return S_FALSE;
  items.Clear();
  unsigned numNameItems = Get16(_buf + offset + 12);
  unsigned numIdItems = Get16(_buf + offset + 14);
  unsigned numItems = numNameItems + numIdItems;
  if ((rem - 16) / 8 < numItems)
    return S_FALSE;
  if (!_usedRes.SetRange(offset, 16 + numItems * 8))
    return S_FALSE;
  offset += 16;
  _oneLang = true;
  unsigned i;
  for (i = 0; i < numItems; i++)
  {
    CTableItem item;
    const Byte *buf = _buf + offset;
    offset += 8;
    item.ID = Get32(buf + 0);
    if (((item.ID & kFlag) != 0) != (i < numNameItems))
      return S_FALSE;
    item.Offset = Get32(buf + 4);
    items.Add(item);
  }
  return S_OK;
}

static const UInt32 kFileSizeMax = (UInt32)1 << 30;
static const int kNumResItemsMax = (UInt32)1 << 23;
static const int kNumStringLangsMax = 128;

// BITMAPINFOHEADER
struct CBitmapInfoHeader
{
  // UInt32 HeaderSize;
  UInt32 XSize;
  Int32 YSize;
  UInt16 Planes;
  UInt16 BitCount;
  UInt32 Compression;
  UInt32 SizeImage;

  bool Parse(const Byte *p, size_t size);
};

static const UInt32 kBitmapInfoHeader_Size = 0x28;

bool CBitmapInfoHeader::Parse(const Byte *p, size_t size)
{
  if (size < kBitmapInfoHeader_Size || Get32(p) != kBitmapInfoHeader_Size)
    return false;
  XSize = Get32(p + 4);
  YSize = (Int32)Get32(p + 8);
  Planes = Get16(p + 12);
  BitCount = Get16(p + 14);
  Compression = Get32(p + 16);
  SizeImage = Get32(p + 20);
  return true;
};

static UInt32 GetImageSize(UInt32 xSize, UInt32 ySize, UInt32 bitCount)
{
  return ((xSize * bitCount + 7) / 8 + 3) / 4 * 4 * ySize;
}
  
static UInt32 SetBitmapHeader(Byte *dest, const Byte *src, UInt32 size)
{
  CBitmapInfoHeader h;
  if (!h.Parse(src, size))
    return 0;
  if (h.YSize < 0)
    h.YSize = -h.YSize;
  if (h.XSize > (1 << 26) || h.YSize > (1 << 26) || h.Planes != 1 || h.BitCount > 32 ||
      h.Compression != 0) // BI_RGB
    return 0;
  if (h.SizeImage == 0)
    h.SizeImage = GetImageSize(h.XSize, h.YSize, h.BitCount);
  UInt32 totalSize = kBmpHeaderSize + size;
  UInt32 offBits = totalSize - h.SizeImage;
  // BITMAPFILEHEADER
  SetUi16(dest, 0x4D42);
  SetUi32(dest + 2, totalSize);
  SetUi32(dest + 6, 0);
  SetUi32(dest + 10, offBits);
  return kBmpHeaderSize;
}

static UInt32 SetIconHeader(Byte *dest, const Byte *src, UInt32 size)
{
  CBitmapInfoHeader h;
  if (!h.Parse(src, size))
    return 0;
  if (h.YSize < 0)
    h.YSize = -h.YSize;
  if (h.XSize > (1 << 26) || h.YSize > (1 << 26) || h.Planes != 1 ||
      h.Compression != 0) // BI_RGB
    return 0;

  UInt32 numBitCount = h.BitCount;
  if (numBitCount != 1 &&
      numBitCount != 4 &&
      numBitCount != 8 &&
      numBitCount != 24 &&
      numBitCount != 32)
    return 0;

  if ((h.YSize & 1) != 0)
    return 0;
  h.YSize /= 2;
  if (h.XSize > 0x100 || h.YSize > 0x100)
    return 0;

  UInt32 imageSize;
  // imageSize is not correct if AND mask array contains zeros
  // in this case it is equal image1Size

  // UInt32 imageSize = h.SizeImage;
  // if (imageSize == 0)
  // {
    UInt32 image1Size = GetImageSize(h.XSize, h.YSize, h.BitCount);
    UInt32 image2Size = GetImageSize(h.XSize, h.YSize, 1);
    imageSize = image1Size + image2Size;
  // }
  UInt32 numColors = 0;
  if (numBitCount < 16)
    numColors = 1 << numBitCount;

  SetUi16(dest, 0); // Reserved
  SetUi16(dest + 2, 1); // RES_ICON
  SetUi16(dest + 4, 1); // ResCount

  dest[6] = (Byte)h.XSize; // Width
  dest[7] = (Byte)h.YSize; // Height
  dest[8] = (Byte)numColors; // ColorCount
  dest[9] = 0; // Reserved
  
  SetUi32(dest + 10, 0); // Reserved1 / Reserved2

  UInt32 numQuadsBytes = numColors * 4;
  UInt32 BytesInRes = kBitmapInfoHeader_Size + numQuadsBytes + imageSize;
  SetUi32(dest + 14, BytesInRes);
  SetUi32(dest + 18, kIconHeaderSize);

  /*
  Description = DWORDToString(xSize) +
      kDelimiterChar + DWORDToString(ySize) +
      kDelimiterChar + DWORDToString(numBitCount);
  */
  return kIconHeaderSize;
}

bool CHandler::ParseStringRes(UInt32 id, UInt32 lang, const Byte *src, UInt32 size)
{
  if ((size & 1) != 0)
    return false;

  int i;
  for (i = 0; i < _strings.Size(); i++)
    if (_strings[i].Lang == lang)
      break;
  if (i == _strings.Size())
  {
    if (_strings.Size() >= kNumStringLangsMax)
      return false;
    CStringItem item;
    item.Size = 0;
    item.Lang = lang;
    i = _strings.Add(item);
  }
  
  CStringItem &item = _strings[i];
  id = (id - 1) << 4;
  UInt32 pos = 0;
  for (i = 0; i < 16; i++)
  {
    if (size - pos < 2)
      return false;
    UInt32 len = Get16(src + pos);
    pos += 2;
    if (len != 0)
    {
      if (size - pos < len * 2)
        return false;
      char temp[32];
      ConvertUInt32ToString(id  + i, temp);
      size_t tempLen = strlen(temp);
      size_t j;
      for (j = 0; j < tempLen; j++)
        item.AddChar(temp[j]);
      item.AddChar('\t');
      for (j = 0; j < len; j++, pos += 2)
        item.AddWChar(Get16(src + pos));
      item.AddChar(0x0D);
      item.AddChar(0x0A);
    }
  }
  return (size == pos);
}

HRESULT CHandler::OpenResources(int sectionIndex, IInStream *stream, IArchiveOpenCallback *callback)
{
  const CSection &sect = _sections[sectionIndex];
  size_t fileSize = sect.PSize; // Maybe we need sect.VSize here !!!
  if (fileSize > kFileSizeMax)
    return S_FALSE;
  {
    UInt64 fileSize64 = fileSize;
    if (callback)
      RINOK(callback->SetTotal(NULL, &fileSize64));
    RINOK(stream->Seek(sect.Pa, STREAM_SEEK_SET, NULL));
    _buf.SetCapacity(fileSize);
    for (size_t pos = 0; pos < fileSize;)
    {
      UInt64 offset64 = pos;
      if (callback)
        RINOK(callback->SetCompleted(NULL, &offset64))
      size_t rem = MyMin(fileSize - pos, (size_t)(1 << 20));
      RINOK(ReadStream_FALSE(stream, _buf + pos, rem));
      pos += rem;
    }
  }
  
  _usedRes.Alloc(fileSize);
  CRecordVector<CTableItem> specItems;
  RINOK(ReadTable(0, specItems));

  _oneLang = true;
  bool stringsOk = true;
  size_t maxOffset = 0;
  for (int i = 0; i < specItems.Size(); i++)
  {
    const CTableItem &item1 = specItems[i];
    if ((item1.Offset & kFlag) == 0)
      return S_FALSE;

    CRecordVector<CTableItem> specItems2;
    RINOK(ReadTable(item1.Offset & kMask, specItems2));

    for (int j = 0; j < specItems2.Size(); j++)
    {
      const CTableItem &item2 = specItems2[j];
      if ((item2.Offset & kFlag) == 0)
        return S_FALSE;
      
      CRecordVector<CTableItem> specItems3;
      RINOK(ReadTable(item2.Offset & kMask, specItems3));
      
      CResItem item;
      item.Type = item1.ID;
      item.ID = item2.ID;
      
      for (int k = 0; k < specItems3.Size(); k++)
      {
        if (_items.Size() >= kNumResItemsMax)
          return S_FALSE;
        const CTableItem &item3 = specItems3[k];
        if ((item3.Offset & kFlag) != 0)
          return S_FALSE;
        if (item3.Offset >= _buf.GetCapacity() || _buf.GetCapacity() - item3.Offset < 16)
          return S_FALSE;
        const Byte *buf = _buf + item3.Offset;
        item.Lang = item3.ID;
        item.Offset = Get32(buf + 0);
        item.Size = Get32(buf + 4);
        // UInt32 codePage = Get32(buf + 8);
        if (Get32(buf + 12) != 0)
          return S_FALSE;
        if (!_items.IsEmpty() && _oneLang && !item.IsNameEqual(_items.Back()))
          _oneLang = false;

        item.HeaderSize = 0;
      
        size_t offset = item.Offset - sect.Va;
        if (offset > maxOffset)
          maxOffset = offset;
        if (offset + item.Size > maxOffset)
          maxOffset = offset + item.Size;

        if (CheckItem(sect, item, offset))
        {
          const Byte *data = _buf + offset;
          if (item.IsBmp())
            item.HeaderSize = SetBitmapHeader(item.Header, data, item.Size);
          else if (item.IsIcon())
            item.HeaderSize = SetIconHeader(item.Header, data, item.Size);
          else if (item.IsString())
          {
            if (stringsOk)
              stringsOk = ParseStringRes(item.ID, item.Lang, data, item.Size);
          }
        }

        item.Enabled = true;
        _items.Add(item);
      }
    }
  }
  
  if (stringsOk && !_strings.IsEmpty())
  {
    int i;
    for (i = 0; i < _items.Size(); i++)
    {
      CResItem &item = _items[i];
      if (item.IsString())
        item.Enabled = false;
    }
    for (i = 0; i < _strings.Size(); i++)
    {
      if (_strings[i].Size == 0)
        continue;
      CMixItem mixItem;
      mixItem.ResourceIndex = -1;
      mixItem.StringIndex = i;
      mixItem.SectionIndex = sectionIndex;
      _mixItems.Add(mixItem);
    }
  }

  _usedRes.Free();

  int numBits = _optHeader.GetNumFileAlignBits();
  if (numBits >= 0)
  {
    UInt32 mask = (1 << numBits) - 1;
    size_t end = ((maxOffset + mask) & ~mask);
    if (end < sect.VSize)
    {
      CSection sect2;
      sect2.Flags = 0;
      sect2.Pa = sect.Pa + (UInt32)maxOffset;
      sect2.Va = sect.Va + (UInt32)maxOffset;
      sect2.PSize = sect.VSize - (UInt32)maxOffset;
      sect2.VSize = sect2.PSize;
      sect2.Name = ".rsrc_1";
      sect2.Time = 0;
      _sections.Add(sect2);
    }
  }

  return S_OK;
}

HRESULT CHandler::Open2(IInStream *stream, IArchiveOpenCallback *callback)
{
  const UInt32 kBufSize = 1 << 18;
  const UInt32 kSigSize = 2;

  CByteBuffer buffer;
  buffer.SetCapacity(kBufSize);
  Byte *buf = buffer;

  size_t processed = kSigSize;
  RINOK(ReadStream_FALSE(stream, buf, processed));
  if (buf[0] != 'M' || buf[1] != 'Z')
    return S_FALSE;
  processed = kBufSize - kSigSize;
  RINOK(ReadStream(stream, buf + kSigSize, &processed));
  processed += kSigSize;
  if (!Parse(buf, (UInt32)processed))
    return S_FALSE;
  bool thereISDebug;
  RINOK(LoadDebugSections(stream, thereISDebug));

  const CDirLink &certLink = _optHeader.DirItems[kDirLink_Certificate];
  if (certLink.Size != 0)
  {
    CSection sect;
    sect.Name = "CERTIFICATE";
    sect.Va = 0;
    sect.Pa = certLink.Va;
    sect.PSize = sect.VSize = certLink.Size;
    sect.UpdateTotalSize(_totalSize);
    _sections.Add(sect);
  }

  if (thereISDebug)
  {
    const UInt32 kAlign = 1 << 12;
    UInt32 alignPos = _totalSize & (kAlign - 1);
    if (alignPos != 0)
    {
      UInt32 size = kAlign - alignPos;
      RINOK(stream->Seek(_totalSize, STREAM_SEEK_SET, NULL));
      buffer.Free();
      buffer.SetCapacity(kAlign);
      Byte *buf = buffer;
      size_t processed = size;
      RINOK(ReadStream(stream, buf, &processed));
      size_t i;
      for (i = 0; i < processed; i++)
      {
        if (buf[i] != 0)
          break;
      }
      if (processed < size && processed < 100)
        _totalSize += (UInt32)processed;
      else if (((_totalSize + i) & 0x1FF) == 0 || processed < size)
        _totalSize += (UInt32)i;
    }
  }

  if (_header.NumSymbols > 0 && _header.PointerToSymbolTable >= 512)
  {
    if (_header.NumSymbols >= (1 << 24))
      return S_FALSE;
    CSection sect;
    sect.Name = "COFF_SYMBOLS";
    UInt32 size = _header.NumSymbols * 18;
    RINOK(stream->Seek((UInt64)_header.PointerToSymbolTable + size, STREAM_SEEK_SET, NULL));
    Byte buf[4];
    RINOK(ReadStream_FALSE(stream, buf, 4));
    UInt32 size2 = Get32(buf);
    if (size2 >= (1 << 28))
      return S_FALSE;
    size += size2;

    sect.Va = 0;
    sect.Pa = _header.PointerToSymbolTable;
    sect.PSize = sect.VSize = size;
    sect.UpdateTotalSize(_totalSize);
    _sections.Add(sect);
  }

  UInt64 fileSize;
  RINOK(stream->Seek(0, STREAM_SEEK_END, &fileSize));
  if (fileSize > _totalSize)
    return S_FALSE;
  _totalSizeLimited = (_totalSize < fileSize) ? _totalSize : (UInt32)fileSize;

  {
    CObjectVector<CSection> sections = _sections;
    sections.Sort();
    UInt32 limit = (1 << 12);
    int num = 0;
    int numSections = sections.Size();
    for (int i = 0; i < numSections; i++)
    {
      const CSection &s = sections[i];
      if (s.Pa > limit)
      {
        CSection s2;
        s2.Pa = s2.Va = limit;
        s2.PSize = s2.VSize = s.Pa - limit;
        s2.Name = '[';
        s2.Name += GetDecString(num++);
        s2.Name += ']';
        _sections.Add(s2);
        limit = s.Pa;
      }
      UInt32 next = s.Pa + s.PSize;
      if (next < s.Pa)
        break;
      if (next >= limit)
        limit = next;
    }
  }

  _parseResources = true;

  for (int i = 0; i < _sections.Size(); i++)
  {
    const CSection &sect = _sections[i];
    CMixItem mixItem;
    mixItem.SectionIndex = i;
    if (_parseResources && sect.Name == ".rsrc" && _items.IsEmpty())
    {
      HRESULT res = OpenResources(i, stream, callback);
      if (res == S_OK)
      {
        _resourceFileName = GetUnicodeString(sect.Name);
        for (int j = 0; j < _items.Size(); j++)
          if (_items[j].Enabled)
          {
            mixItem.ResourceIndex = j;
            mixItem.StringIndex = -1;
            _mixItems.Add(mixItem);
          }
        if (sect.PSize > sect.VSize)
        {
          int numBits = _optHeader.GetNumFileAlignBits();
          if (numBits >= 0)
          {
            UInt32 mask = (1 << numBits) - 1;
            UInt32 end = ((sect.VSize + mask) & ~mask);

            if (sect.PSize > end)
            {
              CSection sect2;
              sect2.Flags = 0;
              sect2.Pa = sect.Pa + end;
              sect2.Va = sect.Va + end;
              sect2.PSize = sect.PSize - end;
              sect2.VSize = sect2.PSize;
              sect2.Name = ".rsrc_2";
              sect2.Time = 0;
              _sections.Add(sect2);
            }
          }
        }
        continue;
      }
      if (res != S_FALSE)
        return res;
      CloseResources();
    }
    mixItem.StringIndex = -1;
    mixItem.ResourceIndex = -1;
    _mixItems.Add(mixItem);
  }
  return S_OK;
}

HRESULT CalcCheckSum(ISequentialInStream *stream, UInt32 size, UInt32 excludePos, UInt32 &res)
{
  // size &= ~1;
  const UInt32 kBufSize = 1 << 23;
  CByteBuffer buffer;
  buffer.SetCapacity(kBufSize);
  Byte *buf = buffer;

  UInt32 sum = 0;
  UInt32 pos = 0;
  for (;;)
  {
    UInt32 rem = size - pos;
    if (rem > kBufSize)
      rem = kBufSize;
    if (rem == 0)
      break;
    size_t processed = rem;
    RINOK(ReadStream(stream, buf, &processed));
    
    /*
    for (; processed < rem; processed++)
      buf[processed] = 0;
    */

    if ((processed & 1) != 0)
      buf[processed] = 0;

    for (int j = 0; j < 4; j++)
    {
      UInt32 p = excludePos + j;
      if (pos <= p && p < pos + processed)
        buf[p - pos] = 0;
    }

    for (size_t i = 0; i < processed; i += 2)
    {
      sum += Get16(buf + i);
      sum = (sum + (sum >> 16)) & 0xFFFF;
    }
    pos += (UInt32)processed;
    if (rem != processed)
      break;
  }
  sum += pos;
  res = sum;
  return S_OK;
}

STDMETHODIMP CHandler::Open(IInStream *inStream, const UInt64 *, IArchiveOpenCallback *callback)
{
  COM_TRY_BEGIN
  Close();
  RINOK(Open2(inStream, callback));
  _stream = inStream;
  return S_OK;
  COM_TRY_END
}

void CHandler::CloseResources()
{
  _usedRes.Free();
  _items.Clear();
  _strings.Clear();
  _buf.SetCapacity(0);
}

STDMETHODIMP CHandler::Close()
{
  _stream.Release();
  _sections.Clear();
  _mixItems.Clear();
  CloseResources();
  return S_OK;
}

STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
{
  *numItems = _mixItems.Size();
  return S_OK;
}

STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
    Int32 testMode, IArchiveExtractCallback *extractCallback)
{
  COM_TRY_BEGIN
  bool allFilesMode = (numItems == (UInt32)-1);
  if (allFilesMode)
    numItems = _mixItems.Size();
  if (numItems == 0)
    return S_OK;
  UInt64 totalSize = 0;
  UInt32 i;
  for (i = 0; i < numItems; i++)
  {
    const CMixItem &mixItem = _mixItems[allFilesMode ? i : indices[i]];
    if (mixItem.StringIndex >= 0)
      totalSize += _strings[mixItem.StringIndex].Size;
    else if (mixItem.ResourceIndex < 0)
      totalSize += _sections[mixItem.SectionIndex].GetPackSize();
    else
      totalSize += _items[mixItem.ResourceIndex].GetSize();
  }
  extractCallback->SetTotal(totalSize);

  UInt64 currentTotalSize = 0;
  UInt64 currentItemSize;
  
  NCompress::CCopyCoder *copyCoderSpec = new NCompress::CCopyCoder();
  CMyComPtr<ICompressCoder> copyCoder = copyCoderSpec;

  CLocalProgress *lps = new CLocalProgress;
  CMyComPtr<ICompressProgressInfo> progress = lps;
  lps->Init(extractCallback, false);

  bool checkSumOK = true;
  if (_optHeader.CheckSum != 0 && (int)numItems == _mixItems.Size())
  {
    UInt32 checkSum = 0;
    RINOK(_stream->Seek(0, STREAM_SEEK_SET, NULL));
    CalcCheckSum(_stream, _totalSizeLimited, _peOffset + kHeaderSize + 64, checkSum);
    checkSumOK = (checkSum == _optHeader.CheckSum);
  }

  CLimitedSequentialInStream *streamSpec = new CLimitedSequentialInStream;
  CMyComPtr<ISequentialInStream> inStream(streamSpec);
  streamSpec->SetStream(_stream);

  for (i = 0; i < numItems; i++, currentTotalSize += currentItemSize)
  {
    lps->InSize = lps->OutSize = currentTotalSize;
    RINOK(lps->SetCur());
    Int32 askMode = testMode ?
        NExtract::NAskMode::kTest :
        NExtract::NAskMode::kExtract;
    UInt32 index = allFilesMode ? i : indices[i];

    CMyComPtr<ISequentialOutStream> outStream;
    RINOK(extractCallback->GetStream(index, &outStream, askMode));
    const CMixItem &mixItem = _mixItems[index];

    const CSection &sect = _sections[mixItem.SectionIndex];
    bool isOk = true;
    if (mixItem.StringIndex >= 0)
    {
      const CStringItem &item = _strings[mixItem.StringIndex];
      currentItemSize = item.Size;
      if (!testMode && !outStream)
        continue;

      RINOK(extractCallback->PrepareOperation(askMode));
      if (outStream)
        RINOK(WriteStream(outStream, item.Buf, item.Size));
    }
    else if (mixItem.ResourceIndex < 0)
    {
      currentItemSize = sect.GetPackSize();
      if (!testMode && !outStream)
        continue;
      
      RINOK(extractCallback->PrepareOperation(askMode));
      RINOK(_stream->Seek(sect.Pa, STREAM_SEEK_SET, NULL));
      streamSpec->Init(currentItemSize);
      RINOK(copyCoder->Code(inStream, outStream, NULL, NULL, progress));
      isOk = (copyCoderSpec->TotalSize == currentItemSize);
    }
    else
    {
      const CResItem &item = _items[mixItem.ResourceIndex];
      currentItemSize = item.GetSize();
      if (!testMode && !outStream)
        continue;

      RINOK(extractCallback->PrepareOperation(askMode));
      size_t offset = item.Offset - sect.Va;
      if (!CheckItem(sect, item, offset))
        isOk = false;
      else if (outStream)
      {
        if (item.HeaderSize != 0)
          RINOK(WriteStream(outStream, item.Header, item.HeaderSize));
        RINOK(WriteStream(outStream, _buf + offset, item.Size));
      }
    }
    
    outStream.Release();
    RINOK(extractCallback->SetOperationResult(isOk ?
      checkSumOK ?
        NExtract::NOperationResult::kOK:
        NExtract::NOperationResult::kCRCError:
        NExtract::NOperationResult::kDataError));
  }
  return S_OK;
  COM_TRY_END
}

STDMETHODIMP CHandler::GetStream(UInt32 index, ISequentialInStream **stream)
{
  COM_TRY_BEGIN
  *stream = 0;

  const CMixItem &mixItem = _mixItems[index];
  const CSection &sect = _sections[mixItem.SectionIndex];
  if (mixItem.IsSectionItem())
    return CreateLimitedInStream(_stream, sect.Pa, sect.PSize, stream);

  CBufInStream *inStreamSpec = new CBufInStream;
  CMyComPtr<ISequentialInStream> streamTemp = inStreamSpec;
  CReferenceBuf *referenceBuf = new CReferenceBuf;
  CMyComPtr<IUnknown> ref = referenceBuf;
  if (mixItem.StringIndex >= 0)
  {
    const CStringItem &item = _strings[mixItem.StringIndex];
    referenceBuf->Buf.SetCapacity(item.Size);
    memcpy(referenceBuf->Buf, item.Buf, item.Size);
  }
  else
  {
    const CResItem &item = _items[mixItem.ResourceIndex];
    size_t offset = item.Offset - sect.Va;
    if (!CheckItem(sect, item, offset))
      return S_FALSE;
    referenceBuf->Buf.SetCapacity(item.HeaderSize + item.Size);
    memcpy(referenceBuf->Buf, item.Header, item.HeaderSize);
    memcpy(referenceBuf->Buf + item.HeaderSize, _buf + offset, item.Size);
  }
  inStreamSpec->Init(referenceBuf);

  *stream = streamTemp.Detach();
  return S_OK;
  COM_TRY_END
}

static IInArchive *CreateArc() { return new CHandler; }

static CArcInfo g_ArcInfo =
  { L"PE", L"exe dll sys", 0, 0xDD, { 'P', 'E', 0, 0 }, 4, false, CreateArc, 0 };

REGISTER_ARC(Pe)

}}
<file_sep>/SQLCEHelper/Source/AddOffset.h
#ifndef __ADDOFFSET_H__
#define __ADDOFFSET_H__

ULONG AddOffset(ULONG nCurrent, ULONG nAdd);

#endif
<file_sep>/7-Zip/CPP/7zip/Archive/Wim/WimHandler.cpp
// WimHandler.cpp

#include "StdAfx.h"

#include "Common/IntToString.h"
#include "Common/Defs.h"
#include "Common/ComTry.h"
#include "Common/StringToInt.h"
#include "Common/UTFConvert.h"

#include "Windows/PropVariant.h"

#include "../../Common/StreamUtils.h"
#include "../../Common/ProgressUtils.h"

#include "../../../../C/CpuArch.h"

#include "WimHandler.h"

#define Get16(p) GetUi16(p)
#define Get32(p) GetUi32(p)
#define Get64(p) GetUi64(p)

using namespace NWindows;

namespace NArchive {
namespace NWim {

#define WIM_DETAILS

STATPROPSTG kProps[] =
{
  { NULL, kpidPath, VT_BSTR},
  { NULL, kpidIsDir, VT_BOOL},
  { NULL, kpidSize, VT_UI8},
  { NULL, kpidPackSize, VT_UI8},
  { NULL, kpidAttrib, VT_UI4},
  { NULL, kpidMethod, VT_BSTR},
  { NULL, kpidMTime, VT_FILETIME},
  { NULL, kpidCTime, VT_FILETIME},
  { NULL, kpidATime, VT_FILETIME}
  
  #ifdef WIM_DETAILS
  , { NULL, kpidVolume, VT_UI4}
  , { NULL, kpidOffset, VT_UI8}
  , { NULL, kpidLinks, VT_UI4}
  #endif
};

STATPROPSTG kArcProps[] =
{
  { NULL, kpidSize, VT_UI8},
  { NULL, kpidPackSize, VT_UI8},
  { NULL, kpidMethod, VT_BSTR},
  { NULL, kpidCTime, VT_FILETIME},
  { NULL, kpidMTime, VT_FILETIME},
  { NULL, kpidComment, VT_FILETIME},
  { NULL, kpidIsVolume, VT_BOOL},
  { NULL, kpidVolume, VT_UI4},
  { NULL, kpidNumVolumes, VT_UI4}
};

static bool ParseNumber64(const AString &s, UInt64 &res)
{
  const char *end;
  if (s.Left(2) == "0x")
  {
    if (s.Length() == 2)
      return false;
    res = ConvertHexStringToUInt64((const char *)s + 2, &end);
  }
  else
  {
    if (s.IsEmpty())
      return false;
    res = ConvertStringToUInt64(s, &end);
  }
  return *end == 0;
}

static bool ParseNumber32(const AString &s, UInt32 &res)
{
  UInt64 res64;
  if (!ParseNumber64(s, res64) || res64 >= ((UInt64)1 << 32))
    return false;
  res = (UInt32)res64;
  return true;
}

void ParseTime(const CXmlItem &item, bool &defined, FILETIME &ft, const AString &s)
{
  defined = false;
  int cTimeIndex = item.FindSubTag(s);
  if (cTimeIndex >= 0)
  {
    const CXmlItem &timeItem = item.SubItems[cTimeIndex];
    UInt32 high = 0, low = 0;
    if (ParseNumber32(timeItem.GetSubStringForTag("HIGHPART"), high) &&
      ParseNumber32(timeItem.GetSubStringForTag("LOWPART"), low))
    {
      defined = true;
      ft.dwHighDateTime = high;
      ft.dwLowDateTime = low;
    }
  }
}

void CImageInfo::Parse(const CXmlItem &item)
{
  ParseTime(item, CTimeDefined, CTime, "CREATIONTIME");
  ParseTime(item, MTimeDefined, MTime, "LASTMODIFICATIONTIME");
  NameDefined = ConvertUTF8ToUnicode(item.GetSubStringForTag("NAME"), Name);
  // IndexDefined = ParseNumber32(item.GetPropertyValue("INDEX"), Index);
}

void CXml::Parse()
{
  size_t size = Data.GetCapacity();
  if (size < 2 || (size & 1) != 0 || (size > 1 << 24))
    return;
  const Byte *p = Data;
  if (Get16(p) != 0xFEFF)
    return;
  UString s;
  {
    wchar_t *chars = s.GetBuffer((int)size / 2 + 1);
    for (size_t i = 2; i < size; i += 2)
      *chars++ = (wchar_t)Get16(p + i);
    *chars = 0;
    s.ReleaseBuffer();
  }

  AString utf;
  if (!ConvertUnicodeToUTF8(s, utf))
    return;
  ::CXml xml;
  if (!xml.Parse(utf))
    return;
  if (xml.Root.Name != "WIM")
    return;

  for (int i = 0; i < xml.Root.SubItems.Size(); i++)
  {
    const CXmlItem &item = xml.Root.SubItems[i];
    if (item.IsTagged("IMAGE"))
    {
      CImageInfo imageInfo;
      imageInfo.Parse(item);
      Images.Add(imageInfo);
    }
  }
}

static const wchar_t *kStreamsNamePrefix = L"Files" WSTRING_PATH_SEPARATOR;
static const wchar_t *kMethodLZX = L"LZX";
static const wchar_t *kMethodXpress = L"XPress";
static const wchar_t *kMethodCopy = L"Copy";

IMP_IInArchive_Props
IMP_IInArchive_ArcProps

STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
{
  COM_TRY_BEGIN
  NWindows::NCOM::CPropVariant prop;

  const CImageInfo *image = NULL;
  if (m_Xmls.Size() == 1)
  {
    const CXml &xml = m_Xmls[0];
    if (xml.Images.Size() == 1)
      image = &xml.Images[0];
  }

  switch(propID)
  {
    case kpidSize: prop = m_Database.GetUnpackSize(); break;
    case kpidPackSize: prop = m_Database.GetPackSize(); break;
    
    case kpidCTime:
      if (m_Xmls.Size() == 1)
      {
        const CXml &xml = m_Xmls[0];
        int index = -1;
        for (int i = 0; i < xml.Images.Size(); i++)
        {
          const CImageInfo &image = xml.Images[i];
          if (image.CTimeDefined)
            if (index < 0 || ::CompareFileTime(&image.CTime, &xml.Images[index].CTime) < 0)
              index = i;
        }
        if (index >= 0)
          prop = xml.Images[index].CTime;
      }
      break;

    case kpidMTime:
      if (m_Xmls.Size() == 1)
      {
        const CXml &xml = m_Xmls[0];
        int index = -1;
        for (int i = 0; i < xml.Images.Size(); i++)
        {
          const CImageInfo &image = xml.Images[i];
          if (image.MTimeDefined)
            if (index < 0 || ::CompareFileTime(&image.MTime, &xml.Images[index].MTime) > 0)
              index = i;
        }
        if (index >= 0)
          prop = xml.Images[index].MTime;
      }
      break;

    case kpidComment: if (image != NULL && image->NameDefined) prop = image->Name; break;

    case kpidIsVolume:
      if (m_Xmls.Size() > 0)
      {
        UInt16 volIndex = m_Xmls[0].VolIndex;
        if (volIndex < m_Volumes.Size())
          prop = (m_Volumes[volIndex].Header.NumParts > 1);
      }
      break;
    case kpidVolume:
      if (m_Xmls.Size() > 0)
      {
        UInt16 volIndex = m_Xmls[0].VolIndex;
        if (volIndex < m_Volumes.Size())
          prop = (UInt32)m_Volumes[volIndex].Header.PartNumber;
      }
      break;
    case kpidNumVolumes: if (m_Volumes.Size() > 0) prop = (UInt32)(m_Volumes.Size() - 1); break;
    case kpidMethod:
    {
      bool lzx = false, xpress = false, copy = false;
      for (int i = 0; i < m_Xmls.Size(); i++)
      {
        const CVolume &vol = m_Volumes[m_Xmls[i].VolIndex];
        const CHeader &header = vol.Header;
        if (header.IsCompressed())
          if (header.IsLzxMode())
            lzx = true;
          else
            xpress = true;
        else
          copy = true;
      }
      UString res;
      if (lzx)
        res = kMethodLZX;
      if (xpress)
      {
        if (!res.IsEmpty())
          res += L' ';
        res += kMethodXpress;
      }
      if (copy)
      {
        if (!res.IsEmpty())
          res += L' ';
        res += kMethodCopy;
      }
      prop = res;
    }
  }
  prop.Detach(value);
  return S_OK;
  COM_TRY_END
}

STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
{
  COM_TRY_BEGIN
  NWindows::NCOM::CPropVariant prop;
  if (index < (UInt32)m_Database.Items.Size())
  {
    const CItem &item = m_Database.Items[index];
    const CStreamInfo *si = NULL;
    const CVolume *vol = NULL;
    if (item.StreamIndex >= 0)
    {
      si = &m_Database.Streams[item.StreamIndex];
      vol = &m_Volumes[si->PartNumber];
    }

    switch(propID)
    {
      case kpidPath:
        if (item.HasMetadata)
          prop = item.Name;
        else
        {
          wchar_t sz[32];
          ConvertUInt64ToString(item.StreamIndex, sz);
          UString s = sz;
          while (s.Length() < m_NameLenForStreams)
            s = L'0' + s;
          s = UString(kStreamsNamePrefix) + s;
          prop = s;
          break;
        }
        break;
      case kpidIsDir: prop = item.isDir(); break;
      case kpidAttrib: if (item.HasMetadata) prop = item.Attrib; break;
      case kpidCTime: if (item.HasMetadata) prop = item.CTime; break;
      case kpidATime: if (item.HasMetadata) prop = item.ATime; break;
      case kpidMTime: if (item.HasMetadata) prop = item.MTime; break;
      case kpidPackSize: prop = si ? si->Resource.PackSize : (UInt64)0; break;
      case kpidSize: prop = si ? si->Resource.UnpackSize : (UInt64)0; break;
      case kpidMethod: if (si) prop = si->Resource.IsCompressed() ?
          (vol->Header.IsLzxMode() ? kMethodLZX : kMethodXpress) : kMethodCopy; break;
      #ifdef WIM_DETAILS
      case kpidVolume: if (si) prop = (UInt32)si->PartNumber; break;
      case kpidOffset: if (si)  prop = (UInt64)si->Resource.Offset; break;
      case kpidLinks: prop = si ? (UInt32)si->RefCount : (UInt32)0; break;
      #endif
    }
  }
  else
  {
    index -= m_Database.Items.Size();
    {
      switch(propID)
      {
        case kpidPath:
        {
          wchar_t sz[32];
          ConvertUInt64ToString(m_Xmls[index].VolIndex, sz);
          UString s = (UString)sz + L".xml";
          prop = s;
          break;
        }
        case kpidIsDir: prop = false; break;
        case kpidPackSize:
        case kpidSize: prop = (UInt64)m_Xmls[index].Data.GetCapacity(); break;
        case kpidMethod: prop = L"Copy"; break;
      }
    }
  }
  prop.Detach(value);
  return S_OK;
  COM_TRY_END
}

class CVolumeName
{
  // UInt32 _volIndex;
  UString _before;
  UString _after;
public:
  CVolumeName() {};

  void InitName(const UString &name)
  {
    // _volIndex = 1;
    int dotPos = name.ReverseFind('.');
    if (dotPos < 0)
      dotPos = name.Length();
    _before = name.Left(dotPos);
    _after = name.Mid(dotPos);
  }

  UString GetNextName(UInt32 index)
  {
    wchar_t s[32];
    ConvertUInt64ToString((index), s);
    return _before + (UString)s + _after;
  }
};

STDMETHODIMP CHandler::Open(IInStream *inStream,
    const UInt64 * /* maxCheckStartPosition */,
    IArchiveOpenCallback *openArchiveCallback)
{
  COM_TRY_BEGIN
  Close();
  try
  {
    CMyComPtr<IArchiveOpenVolumeCallback> openVolumeCallback;
    
    CVolumeName seqName;
    if (openArchiveCallback != NULL)
      openArchiveCallback->QueryInterface(IID_IArchiveOpenVolumeCallback, (void **)&openVolumeCallback);

    UInt32 numVolumes = 1;
    int firstVolumeIndex = -1;
    for (UInt32 i = 1; i <= numVolumes; i++)
    {
      CMyComPtr<IInStream> curStream;
      if (i != 1)
      {
        UString fullName = seqName.GetNextName(i);
        HRESULT result = openVolumeCallback->GetStream(fullName, &curStream);
        if (result == S_FALSE)
          continue;
        if (result != S_OK)
          return result;
        if (!curStream)
          break;
      }
      else
        curStream = inStream;
      CHeader header;
      HRESULT res = NWim::ReadHeader(curStream, header);
      if (res != S_OK)
      {
        if (i == 1)
          return res;
        if (res == S_FALSE)
          continue;
        return res;
      }
      if (firstVolumeIndex >= 0)
        if (!header.AreFromOnArchive(m_Volumes[firstVolumeIndex].Header))
          break;
      if (m_Volumes.Size() > header.PartNumber && m_Volumes[header.PartNumber].Stream)
        break;
      CXml xml;
      xml.VolIndex = header.PartNumber;
      res = OpenArchive(curStream, header, xml.Data, m_Database);
      if (res != S_OK)
      {
        if (i == 1)
          return res;
        if (res == S_FALSE)
          continue;
        return res;
      }
      
      while (m_Volumes.Size() <= header.PartNumber)
        m_Volumes.Add(CVolume());
      CVolume &volume = m_Volumes[header.PartNumber];
      volume.Header = header;
      volume.Stream = curStream;
      
      firstVolumeIndex = header.PartNumber;
      
      bool needAddXml = true;
      if (m_Xmls.Size() != 0)
        if (xml.Data == m_Xmls[0].Data)
          needAddXml = false;
      if (needAddXml)
      {
        xml.Parse();
        m_Xmls.Add(xml);
      }
      
      if (i == 1)
      {
        if (header.PartNumber != 1)
          break;
        if (!openVolumeCallback)
          break;
        numVolumes = header.NumParts;
        {
          NCOM::CPropVariant prop;
          RINOK(openVolumeCallback->GetProperty(kpidName, &prop));
          if (prop.vt != VT_BSTR)
            break;
          seqName.InitName(prop.bstrVal);
        }
      }
    }

    RINOK(SortDatabase(m_Database));

    wchar_t sz[32];
    ConvertUInt64ToString(m_Database.Streams.Size(), sz);
    m_NameLenForStreams = MyStringLen(sz);
  }
  catch(...)
  {
    return S_FALSE;
  }
  return S_OK;
  COM_TRY_END
}

STDMETHODIMP CHandler::Close()
{
  m_Database.Clear();
  m_Volumes.Clear();
  m_Xmls.Clear();
  m_NameLenForStreams = 0;
  return S_OK;
}

STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
    Int32 testMode, IArchiveExtractCallback *extractCallback)
{
  COM_TRY_BEGIN
  bool allFilesMode = (numItems == (UInt32)-1);

  if (allFilesMode)
    numItems = m_Database.Items.Size() + m_Xmls.Size();
  if (numItems == 0)
    return S_OK;

  UInt32 i;
  UInt64 totalSize = 0;
  for (i = 0; i < numItems; i++)
  {
    UInt32 index = allFilesMode ? i : indices[i];
    if (index < (UInt32)m_Database.Items.Size())
    {
      int streamIndex = m_Database.Items[index].StreamIndex;
      if (streamIndex >= 0)
      {
        const CStreamInfo &si = m_Database.Streams[streamIndex];
        totalSize += si.Resource.UnpackSize;
      }
    }
    else
      totalSize += m_Xmls[index - (UInt32)m_Database.Items.Size()].Data.GetCapacity();
  }

  RINOK(extractCallback->SetTotal(totalSize));

  UInt64 currentTotalPacked = 0;
  UInt64 currentTotalUnPacked = 0;
  UInt64 currentItemUnPacked, currentItemPacked;
  
  int prevSuccessStreamIndex = -1;

  CUnpacker unpacker;

  CLocalProgress *lps = new CLocalProgress;
  CMyComPtr<ICompressProgressInfo> progress = lps;
  lps->Init(extractCallback, false);

  for (i = 0; i < numItems; currentTotalUnPacked += currentItemUnPacked,
      currentTotalPacked += currentItemPacked)
  {
    currentItemUnPacked = 0;
    currentItemPacked = 0;

    lps->InSize = currentTotalPacked;
    lps->OutSize = currentTotalUnPacked;

    RINOK(lps->SetCur());
    UInt32 index = allFilesMode ? i : indices[i];
    i++;
    Int32 askMode = testMode ?
        NExtract::NAskMode::kTest :
        NExtract::NAskMode::kExtract;

    CMyComPtr<ISequentialOutStream> realOutStream;
    RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
    if (index >= (UInt32)m_Database.Items.Size())
    {
      if (!testMode && !realOutStream)
        continue;
      RINOK(extractCallback->PrepareOperation(askMode));
      const CByteBuffer &data = m_Xmls[index - (UInt32)m_Database.Items.Size()].Data;
      currentItemUnPacked = data.GetCapacity();
      if (realOutStream)
      {
        RINOK(WriteStream(realOutStream, (const Byte *)data, data.GetCapacity()));
        realOutStream.Release();
      }
      RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kOK));
      continue;
    }

    const CItem &item = m_Database.Items[index];
    int streamIndex = item.StreamIndex;
    if (streamIndex < 0)
    {
      if (!testMode && !realOutStream)
        continue;
      RINOK(extractCallback->PrepareOperation(askMode));
      realOutStream.Release();
      RINOK(extractCallback->SetOperationResult(item.HasStream() ?
            NExtract::NOperationResult::kDataError :
            NExtract::NOperationResult::kOK));
      continue;
    }

    const CStreamInfo &si = m_Database.Streams[streamIndex];
    currentItemUnPacked = si.Resource.UnpackSize;
    currentItemPacked = si.Resource.PackSize;

    if (!testMode && !realOutStream)
      continue;
    RINOK(extractCallback->PrepareOperation(askMode));
    Int32 opRes = NExtract::NOperationResult::kOK;
    if (streamIndex != prevSuccessStreamIndex || realOutStream)
    {
      Byte digest[20];
      const CVolume &vol = m_Volumes[si.PartNumber];
      HRESULT res = unpacker.Unpack(vol.Stream, si.Resource, vol.Header.IsLzxMode(),
          realOutStream, progress, digest);
      if (res == S_OK)
      {
        if (memcmp(digest, si.Hash, kHashSize) == 0)
          prevSuccessStreamIndex = streamIndex;
        else
          opRes = NExtract::NOperationResult::kCRCError;
      }
      else if (res == S_FALSE)
        opRes = NExtract::NOperationResult::kDataError;
      else
        return res;
    }
    realOutStream.Release();
    RINOK(extractCallback->SetOperationResult(opRes));
  }
  return S_OK;
  COM_TRY_END
}

STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
{
  *numItems = m_Database.Items.Size() + m_Xmls.Size();
  return S_OK;
}

}}
<file_sep>/FingerSuite/SetupDLL/setup.cpp
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this sample source code is subject to the terms of the Microsoft
// license agreement under which you licensed this sample source code. If
// you did not accept the terms of the license agreement, you are not
// authorized to use this sample source code. For the terms of the license,
// please see the license agreement between you and Microsoft or, if applicable,
// see the LICENSE.RTF on your install media or the root of your tools installation.
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES OR INDEMNITIES.
//
// ************************************************************
// setup.cpp
// 
// Implementation of DllMain and setup functions
//
//
// ************************************************************

#include "stdafx.h"

#define ARRAYSIZE(x) (sizeof(x)/sizeof((x)[0]))

HINSTANCE g_hinstModule;

// dbg
HWND g_hwndParent;
WCHAR g_szDbg[MAX_PATH];
// fine dbg

DWORD CheckRealDPI(HWND hwndParent)
{
    DWORD nSystemDPI = 0;
    {
        TCHAR szGetRealDPI[MAX_PATH + 40];
        PROCESS_INFORMATION pi;
        
        ::StringCchCat(szGetRealDPI, ARRAYSIZE(szGetRealDPI), _T("\\Application Data\\FingerSuite\\GetRealDPI.EXE")); 
        ::CreateProcess(szGetRealDPI, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL, &pi);
        ::WaitForSingleObject(pi.hProcess, 10000);
        ::GetExitCodeProcess(pi.hProcess, &nSystemDPI);
        ::CloseHandle(pi.hProcess);
    }

	return nSystemDPI;
}

void DeletePngs(DWORD nSystemDPI, LPCTSTR pszInstallDir, LPCTSTR pszAppName)
{
	WCHAR szSearch[MAX_PATH + 40];
	if (nSystemDPI == 96)
	{
		wsprintf(szSearch, L"%s\\%s\\skins\\default\\*_vga.png", pszInstallDir, pszAppName);
	}
	else if (nSystemDPI == 192)
	{
		wsprintf(szSearch, L"%s\\%s\\skins\\default\\*_qvga.png", pszInstallDir, pszAppName);
	}
	else
		return;

	WIN32_FIND_DATA fd;
	WCHAR szFileName[MAX_PATH + 40];
	HANDLE hFind = FindFirstFile(szSearch, &fd);
	if (hFind != INVALID_HANDLE_VALUE)
	{
		do
		{
			wsprintf(szFileName, L"%s\\%s\\skins\\default\\%s", pszInstallDir, pszAppName, fd.cFileName);
			DeleteFile(szFileName);
		} while (FindNextFile(hFind, &fd));
	}
}

void DeleteMUIs(DWORD nLangID, LPCTSTR pszInstallDir, LPCTSTR pszAppName)
{
	WCHAR szSearch[MAX_PATH + 40];
	wsprintf(szSearch, L"%s\\%s\\%s.exe.%04x.mui", pszInstallDir, pszAppName, pszAppName, nLangID);

	//wsprintf(g_szDbg, L"mui=%s", szSearch);
	//MessageBox(g_hwndParent, g_szDbg, L"", MB_ICONINFORMATION);

	WIN32_FIND_DATA fd;
	HANDLE hFind = FindFirstFile(szSearch, &fd);
	if (hFind == INVALID_HANDLE_VALUE)
	{
		// default to english
		WCHAR szEnglishMUI[MAX_PATH + 40];
		wsprintf(szEnglishMUI, L"%s\\%s\\%s.exe.0409.mui", pszInstallDir, pszAppName, pszAppName);

		CopyFile(szEnglishMUI, szSearch, FALSE);
	}
}


BOOL APIENTRY DllMain(
    HANDLE hModule, 
    DWORD  ul_reason_for_call, 
    LPVOID lpReserved
    )
{
    switch (ul_reason_for_call)
    {
        case DLL_PROCESS_ATTACH:
        case DLL_THREAD_ATTACH:
        case DLL_THREAD_DETACH:
        case DLL_PROCESS_DETACH:
            g_hinstModule = (HINSTANCE)hModule;
            break;
    }
    return TRUE;
}


// **************************************************************************
// Function Name: Install_Init
// 
// Purpose: processes the push message.
//
// Arguments:
//    IN HWND hwndParent  handle to the parent window
//    IN BOOL fFirstCall  indicates that this is the first time this function is being called
//    IN BOOL fPreviouslyInstalled  indicates that the current application is already installed
//    IN LPCTSTR pszInstallDir  name of the user-selected install directory of the application
//
// Return Values:
//    codeINSTALL_INIT
//    returns install status
//
// Description:  
//    The Install_Init function is called before installation begins.
//    User will be prompted to confirm installation.
// **************************************************************************
SETUP_API codeINSTALL_INIT Install_Init(
    HWND        hwndParent,
    BOOL        fFirstCall,     // is this the first time this function is being called?
    BOOL        fPreviouslyInstalled,
    LPCTSTR     pszInstallDir
    )
{
	//WCHAR szKeyName[] = L"Software\\FingerMenu";
	//RegDeleteKey(HKEY_LOCAL_MACHINE, szKeyName);
	return codeINSTALL_INIT_CONTINUE;
}


// **************************************************************************
// Function Name: Install_Exit
// 
// Purpose: processes the push message.
//
// Arguments:
//    IN HWND hwndParent  handle to the parent window
//    IN LPCTSTR pszInstallDir  name of the user-selected install directory of the application
//
// Return Values:
//    codeINSTALL_EXIT
//    returns install status
//
// Description:  
//    Register query client with the PushRouter as part of installation.
//    Only the first two parameters really count.
// **************************************************************************
SETUP_API codeINSTALL_EXIT Install_Exit(
    HWND    hwndParent,
    LPCTSTR pszInstallDir,      // final install directory
    WORD    cFailedDirs,
    WORD    cFailedFiles,
    WORD    cFailedRegKeys,
    WORD    cFailedRegVals,
    WORD    cFailedShortcuts
    )
{
	//WCHAR szStartupFile[] = L"\\Windows\\Startup\\FingerMenu.lnk";
	//if (MessageBox(hwndParent, L"Autostart FingerMenu on boot?", L"Autostart", MB_ICONINFORMATION | MB_YESNO) == IDNO)
	//{
	//	DeleteFile(szStartupFile);
	//}
	g_hwndParent = hwndParent;


	DWORD nSystemDPI = CheckRealDPI(hwndParent);
	
	// delete useless pngs
	WCHAR szProgramFiles[MAX_PATH];
	SHGetSpecialFolderPath(hwndParent, szProgramFiles, CSIDL_PROGRAM_FILES, FALSE);
	DeletePngs(nSystemDPI, szProgramFiles, L"FingerMenu");
	DeletePngs(nSystemDPI, szProgramFiles, L"FingerMsgbox");

	// delete useless languages
	LANGID lLang = GetSystemDefaultUILanguage();
	DeleteMUIs(lLang, szProgramFiles, L"FingerMenu");
	DeleteMUIs(lLang, szProgramFiles, L"FingerMsgbox");

	// TODO set locales
    return codeINSTALL_EXIT_DONE;
}


// **************************************************************************
// Function Name: Uninstall_Init
// 
// Purpose: processes the push message.
//
// Arguments:
//    IN HWND hwndParent  handle to the parent window
//    IN LPCTSTR pszInstallDir  name of the user-selected install directory of the application
//
// Return Values:
//    codeUNINSTALL_INIT
//    returns uninstall status
//
// Description:  
//    Query the device data using the query xml in the push message,
//    and send the query results back to the server.
// **************************************************************************
SETUP_API codeUNINSTALL_INIT Uninstall_Init(
    HWND        hwndParent,
    LPCTSTR     pszInstallDir
    )
{
	// close programs
	HWND hWndDest = ::FindWindow(L"FINGER_MENU", NULL);
	if (hWndDest != NULL)
	{
		::PostMessage(hWndDest, WM_CLOSE, 0, 0);
	}

	hWndDest = ::FindWindow(L"FINGER_MSGBOX", NULL);
	if (hWndDest != NULL)
	{
		::PostMessage(hWndDest, WM_CLOSE, 0, 0);
	}

	return codeUNINSTALL_INIT_CONTINUE;
}


// **************************************************************************
// Function Name: Uninstall_Exit
// 
// Purpose: processes the push message.
//
// Arguments:
//    IN HWND hwndParent  handle to the parent window
//
// Return Values:
//    codeUNINSTALL_EXIT
//    returns uninstall status
//
// Description:  
//    Query the device data using the query xml in the push message,
//    and send the query results back to the server.
// **************************************************************************
SETUP_API codeUNINSTALL_EXIT Uninstall_Exit(
    HWND    hwndParent
    )
{
	WCHAR szStartup[MAX_PATH];
	SHGetSpecialFolderPath(hwndParent, szStartup, CSIDL_STARTUP, FALSE);

	WCHAR szLnk[MAX_PATH + 40];

	wsprintf(szLnk, L"%s\\FingerMenu.lnk", szStartup);
	DeleteFile(szLnk);

	wsprintf(szLnk, L"%s\\FingerMsgbox.lnk", szStartup);
	DeleteFile(szLnk);

    return codeUNINSTALL_EXIT_DONE;
}



<file_sep>/7-Zip/CPP/7zip/Archive/NtfsHandler.cpp
// NtfsHandler.cpp

#include "StdAfx.h"

// #define SHOW_DEBUG_INFO
// #define SHOW_DEBUG_INFO2

#if defined(SHOW_DEBUG_INFO) || defined(SHOW_DEBUG_INFO2)
#include <stdio.h>
#endif

#include "../../../C/CpuArch.h"

#include "Common/Buffer.h"
#include "Common/ComTry.h"
#include "Common/IntToString.h"
#include "Common/MyCom.h"
#include "Common/StringConvert.h"

#include "Windows/PropVariant.h"
#include "Windows/Time.h"

#include "../Common/ProgressUtils.h"
#include "../Common/RegisterArc.h"
#include "../Common/StreamUtils.h"

#include "../Compress/CopyCoder.h"

#include "Common/DummyOutStream.h"

#ifdef SHOW_DEBUG_INFO
#define PRF(x) x
#else
#define PRF(x)
#endif

#ifdef SHOW_DEBUG_INFO2
#define PRF2(x) x
#else
#define PRF2(x)
#endif

#define Get16(p) GetUi16(p)
#define Get32(p) GetUi32(p)
#define Get64(p) GetUi64(p)

#define G16(p, dest) dest = Get16(p);
#define G32(p, dest) dest = Get32(p);
#define G64(p, dest) dest = Get64(p);

namespace NArchive {
namespace Ntfs {

static const UInt32 kNumSysRecs = 16;
static const UInt32 kRecIndex_Volume = 3;
static const UInt32 kRecIndex_BadClus = 8;

struct CHeader
{
  Byte SectorSizeLog;
  Byte ClusterSizeLog;
  // Byte MediaType;
  UInt32 NumHiddenSectors;
  UInt64 NumClusters;
  UInt64 MftCluster;
  UInt64 SerialNumber;
  UInt16 SectorsPerTrack;
  UInt16 NumHeads;

  UInt64 GetPhySize() const { return NumClusters << ClusterSizeLog; }
  UInt32 ClusterSize() const { return (UInt32)1 << ClusterSizeLog; }
  bool Parse(const Byte *p);
};

static int GetLog(UInt32 num)
{
  for (int i = 0; i < 31; i++)
    if (((UInt32)1 << i) == num)
      return i;
  return -1;
}

bool CHeader::Parse(const Byte *p)
{
  if (p[0x1FE] != 0x55 || p[0x1FF] != 0xAA)
    return false;

  int codeOffset = 0;
  switch (p[0])
  {
    case 0xE9: codeOffset = 3 + (Int16)Get16(p + 1); break;
    case 0xEB: if (p[2] != 0x90) return false; codeOffset = 2 + (signed char)p[1]; break;
    default: return false;
  }
  Byte sectorsPerClusterLog;

  if (memcmp(p + 3, "NTFS    ", 8) != 0)
    return false;
  {
    int s = GetLog(Get16(p + 11));
    if (s < 9 || s > 12)
      return false;
    SectorSizeLog = (Byte)s;
    s = GetLog(p[13]);
    if (s < 0)
      return false;
    sectorsPerClusterLog = (Byte)s;
    ClusterSizeLog = SectorSizeLog + sectorsPerClusterLog;
  }

  for (int i = 14; i < 21; i++)
    if (p[i] != 0)
      return false;

  // MediaType = p[21];
  if (Get16(p + 22) != 0) // NumFatSectors
    return false;
  G16(p + 24, SectorsPerTrack);
  G16(p + 26, NumHeads);
  G32(p + 28, NumHiddenSectors);
  if (Get32(p + 32) != 0) // NumSectors32
    return false;

  // DriveNumber = p[0x24];
  if (p[0x25] != 0) // CurrentHead
    return false;
  /*
  NTFS-HDD:   p[0x26] = 0x80
  NTFS-FLASH: p[0x26] = 0
  */
  if (p[0x26] != 0x80 && p[0x26] != 0) // ExtendedBootSig
    return false;
  if (p[0x27] != 0) // reserved
    return false;
  UInt64 numSectors = Get64(p + 0x28);
  NumClusters = numSectors >> sectorsPerClusterLog;

  G64(p + 0x30, MftCluster);
  // G64(p + 0x38, Mft2Cluster);
  G64(p + 0x48, SerialNumber);
  UInt32 numClustersInMftRec;
  UInt32 numClustersInIndexBlock;
  G32(p + 0x40, numClustersInMftRec);
  G32(p + 0x44, numClustersInIndexBlock);
  return (numClustersInMftRec < 256 && numClustersInIndexBlock < 256);
}

struct CMftRef
{
  UInt64 Val;
  UInt64 GetIndex() const { return Val & (((UInt64)1 << 48) - 1); }
  UInt16 GetNumber() const { return (UInt16)(Val >> 48); }
  bool IsBaseItself() const { return Val == 0; }
};

#define ATNAME(n) ATTR_TYPE_ ## n
#define DEF_ATTR_TYPE(v, n) ATNAME(n) = v

typedef enum
{
  DEF_ATTR_TYPE(0x00, UNUSED),
  DEF_ATTR_TYPE(0x10, STANDARD_INFO),
  DEF_ATTR_TYPE(0x20, ATTRIBUTE_LIST),
  DEF_ATTR_TYPE(0x30, FILE_NAME),
  DEF_ATTR_TYPE(0x40, OBJECT_ID),
  DEF_ATTR_TYPE(0x50, SECURITY_DESCRIPTOR),
  DEF_ATTR_TYPE(0x60, VOLUME_NAME),
  DEF_ATTR_TYPE(0x70, VOLUME_INFO),
  DEF_ATTR_TYPE(0x80, DATA),
  DEF_ATTR_TYPE(0x90, INDEX_ROOT),
  DEF_ATTR_TYPE(0xA0, INDEX_ALLOCATION),
  DEF_ATTR_TYPE(0xB0, BITMAP),
  DEF_ATTR_TYPE(0xC0, REPARSE_POINT),
  DEF_ATTR_TYPE(0xD0, EA_INFO),
  DEF_ATTR_TYPE(0xE0, EA),
  DEF_ATTR_TYPE(0xF0, PROPERTY_SET),
  DEF_ATTR_TYPE(0x100, LOGGED_UTILITY_STREAM),
  DEF_ATTR_TYPE(0x1000, FIRST_USER_DEFINED_ATTRIBUTE)
};

static const Byte kFileNameType_Posix = 0;
static const Byte kFileNameType_Win32 = 1;
static const Byte kFileNameType_Dos = 2;
static const Byte kFileNameType_Win32Dos = 3;

struct CFileNameAttr
{
  CMftRef ParentDirRef;
  // UInt64 CTime;
  // UInt64 MTime;
  // UInt64 ThisRecMTime;
  // UInt64 ATime;
  // UInt64 AllocatedSize;
  // UInt64 DataSize;
  // UInt16 PackedEaSize;
  UString Name;
  UInt32 Attrib;
  Byte NameType;
  
  bool IsDos() const { return NameType == kFileNameType_Dos; }
  bool Parse(const Byte *p, unsigned size);
};

static void GetString(const Byte *p, unsigned length, UString &res)
{
  wchar_t *s = res.GetBuffer(length);
  for (unsigned i = 0; i < length; i++)
    s[i] = Get16(p + i * 2);
  s[length] = 0;
  res.ReleaseBuffer();
}

bool CFileNameAttr::Parse(const Byte *p, unsigned size)
{
  if (size < 0x42)
    return false;
  G64(p + 0x00, ParentDirRef.Val);
  // G64(p + 0x08, CTime);
  // G64(p + 0x10, MTime);
  // G64(p + 0x18, ThisRecMTime);
  // G64(p + 0x20, ATime);
  // G64(p + 0x28, AllocatedSize);
  // G64(p + 0x30, DataSize);
  G32(p + 0x38, Attrib);
  // G16(p + 0x3C, PackedEaSize);
  NameType = p[0x41];
  unsigned length = p[0x40];
  if (0x42 + length > size)
    return false;
  GetString(p + 0x42, length, Name);
  return true;
}

struct CSiAttr
{
  UInt64 CTime;
  UInt64 MTime;
  // UInt64 ThisRecMTime;
  UInt64 ATime;
  UInt32 Attrib;

  /*
  UInt32 MaxVersions;
  UInt32 Version;
  UInt32 ClassId;
  UInt32 OwnerId;
  UInt32 SecurityId;
  UInt64 QuotaCharged;
  */

  bool Parse(const Byte *p, unsigned size);
};

bool CSiAttr::Parse(const Byte *p, unsigned size)
{
  if (size < 0x24)
    return false;
  G64(p + 0x00, CTime);
  G64(p + 0x08, MTime);
  // G64(p + 0x10, ThisRecMTime);
  G64(p + 0x18, ATime);
  G32(p + 0x20, Attrib);
  return true;
}

static const UInt64 kEmptyExtent = (UInt64)(Int64)-1;

struct CExtent
{
  UInt64 Virt;
  UInt64 Phy;

  bool IsEmpty() const { return Phy == kEmptyExtent; }
};

struct CVolInfo
{
  Byte MajorVer;
  Byte MinorVer;
  // UInt16 Flags;

  bool Parse(const Byte *p, unsigned size);
};

bool CVolInfo::Parse(const Byte *p, unsigned size)
{
  if (size < 12)
    return false;
  MajorVer = p[8];
  MinorVer = p[9];
  // Flags = Get16(p + 10);
  return true;
}

struct CAttr
{
  UInt32 Type;
  // UInt32 Length;
  UString Name;
  // UInt16 Flags;
  // UInt16 Instance;
  CByteBuffer Data;
  Byte NonResident;

  // Non-Resident
  Byte CompressionUnit;
  UInt64 LowVcn;
  UInt64 HighVcn;
  UInt64 AllocatedSize;
  UInt64 Size;
  UInt64 PackSize;
  UInt64 InitializedSize;

  // Resident
  // UInt16 ResidentFlags;

  bool IsCompressionUnitSupported() const { return CompressionUnit == 0 || CompressionUnit == 4; }

  UInt32 Parse(const Byte *p, unsigned size);
  bool ParseFileName(CFileNameAttr &a) const { return a.Parse(Data, (unsigned)Data.GetCapacity()); }
  bool ParseSi(CSiAttr &a) const { return a.Parse(Data, (unsigned)Data.GetCapacity()); }
  bool ParseVolInfo(CVolInfo &a) const { return a.Parse(Data, (unsigned)Data.GetCapacity()); }
  bool ParseExtents(CRecordVector<CExtent> &extents, UInt64 numClustersMax, int compressionUnit) const;
  UInt64 GetSize() const { return NonResident ? Size : Data.GetCapacity(); }
  UInt64 GetPackSize() const
  {
    if (!NonResident)
      return Data.GetCapacity();
    if (CompressionUnit != 0)
      return PackSize;
    return AllocatedSize;
  }
};

#define RINOZ(x) { int __tt = (x); if (__tt != 0) return __tt; }

static int CompareAttr(void *const *elem1, void *const *elem2, void *)
{
  const CAttr &a1 = *(*((const CAttr **)elem1));
  const CAttr &a2 = *(*((const CAttr **)elem2));
  RINOZ(MyCompare(a1.Type, a2.Type));
  RINOZ(MyCompare(a1.Name, a2.Name));
  return MyCompare(a1.LowVcn, a2.LowVcn);
}

UInt32 CAttr::Parse(const Byte *p, unsigned size)
{
  if (size < 4)
    return 0;
  G32(p, Type);
  if (Type == 0xFFFFFFFF)
    return 4;
  if (size < 0x18)
    return 0;
  PRF(printf(" T=%2X", Type));
  
  UInt32 length = Get32(p + 0x04);
  PRF(printf(" L=%3d", length));
  if (length > size)
    return 0;
  NonResident = p[0x08];
  {
    int nameLength = p[9];
    UInt32 nameOffset = Get16(p + 0x0A);
    if (nameLength != 0)
    {
      if (nameOffset + nameLength * 2 > length)
        return 0;
      GetString(p + nameOffset, nameLength, Name);
      PRF(printf(" N=%S", Name));
    }
  }

  // G16(p + 0x0C, Flags);
  // G16(p + 0x0E, Instance);
  // PRF(printf(" F=%4X", Flags));
  // PRF(printf(" Inst=%d", Instance));

  UInt32 dataSize;
  UInt32 offs;
  if (NonResident)
  {
    if (length < 0x40)
      return 0;
    PRF(printf(" NR"));
    G64(p + 0x10, LowVcn);
    G64(p + 0x18, HighVcn);
    G64(p + 0x28, AllocatedSize);
    G64(p + 0x30, Size);
    G64(p + 0x38, InitializedSize);
    G16(p + 0x20, offs);
    CompressionUnit = p[0x22];

    PackSize = Size;
    if (CompressionUnit != 0)
    {
      if (length < 0x48)
        return 0;
      G64(p + 0x40, PackSize);
      PRF(printf(" PS=%I64x", PackSize));
    }

    // PRF(printf("\n"));
    PRF(printf(" ASize=%4I64d", AllocatedSize));
    PRF(printf(" Size=%I64d", Size));
    PRF(printf(" IS=%I64d", InitializedSize));
    PRF(printf(" Low=%I64d", LowVcn));
    PRF(printf(" High=%I64d", HighVcn));
    PRF(printf(" CU=%d", (int)CompressionUnit));
    dataSize = length - offs;
  }
  else
  {
    if (length < 0x18)
      return 0;
    PRF(printf(" RES"));
    dataSize = Get32(p + 0x10);
    PRF(printf(" dataSize=%3d", dataSize));
    offs = Get16(p + 0x14);
    // G16(p + 0x16, ResidentFlags);
    // PRF(printf(" ResFlags=%4X", ResidentFlags));
  }
  if (offs > length || dataSize > length || length - dataSize < offs)
    return 0;
  Data.SetCapacity(dataSize);
  memcpy(Data, p + offs, dataSize);
  #ifdef SHOW_DEBUG_INFO
  PRF(printf("  : "));
  for (unsigned i = 0; i < Data.GetCapacity(); i++)
  {
    PRF(printf(" %02X", (int)Data[i]));
  }
  #endif
  return length;
}

bool CAttr::ParseExtents(CRecordVector<CExtent> &extents, UInt64 numClustersMax, int compressionUnit) const
{
  const Byte *p = Data;
  unsigned size = (unsigned)Data.GetCapacity();
  UInt64 vcn = LowVcn;
  UInt64 lcn = 0;
  UInt64 highVcn1 = HighVcn + 1;
  if (LowVcn != extents.Back().Virt || highVcn1 > (UInt64)1 << 63)
    return false;

  extents.DeleteBack();

  PRF2(printf("\n# ParseExtents # LowVcn = %4I64X # HighVcn = %4I64X", LowVcn, HighVcn));

  while (size > 0)
  {
    Byte b = *p++;
    size--;
    if (b == 0)
      break;
    UInt32 num = b & 0xF;
    if (num == 0 || num > 8 || num > size)
      return false;

    int i;
    UInt64 vSize = p[num - 1];
    for (i = (int)num - 2; i >= 0; i--)
      vSize = (vSize << 8) | p[i];
    if (vSize == 0)
      return false;
    p += num;
    size -= num;
    if ((highVcn1 - vcn) < vSize)
      return false;

    num = (b >> 4) & 0xF;
    if (num > 8 || num > size)
      return false;
    CExtent e;
    e.Virt = vcn;
    if (num == 0)
    {
      if (compressionUnit == 0)
        return false;
      e.Phy = kEmptyExtent;
    }
    else
    {
      Int64 v = (signed char)p[num - 1];
      for (i = (int)num - 2; i >= 0; i--)
        v = (v << 8) | p[i];
      p += num;
      size -= num;
      lcn += v;
      if (lcn > numClustersMax)
        return false;
      e.Phy = lcn;
    }
    extents.Add(e);
    vcn += vSize;
  }
  CExtent e;
  e.Phy = kEmptyExtent;
  e.Virt = vcn;
  extents.Add(e);
  return (highVcn1 == vcn);
}

static const UInt64 kEmptyTag = (UInt64)(Int64)-1;

static const int kNumCacheChunksLog = 1;
static const UInt32 kNumCacheChunks = (1 << kNumCacheChunksLog);

class CInStream:
  public IInStream,
  public CMyUnknownImp
{
  UInt64 _virtPos;
  UInt64 _physPos;
  UInt64 _curRem;
  bool _sparseMode;
  size_t _compressedPos;
  
  UInt64 _tags[kNumCacheChunks];
  int _chunkSizeLog;
  CByteBuffer _inBuf;
  CByteBuffer _outBuf;
public:
  CMyComPtr<IInStream> Stream;
  UInt64 Size;
  UInt64 InitializedSize;
  int BlockSizeLog;
  int CompressionUnit;
  bool InUse;
  CRecordVector<CExtent> Extents;

  HRESULT SeekToPhys() { return Stream->Seek(_physPos, STREAM_SEEK_SET, NULL); }

  UInt32 GetCuSize() const { return (UInt32)1 << (BlockSizeLog + CompressionUnit); }
  HRESULT InitAndSeek(int compressionUnit)
  {
    CompressionUnit = compressionUnit;
    if (compressionUnit != 0)
    {
      UInt32 cuSize = GetCuSize();
      _inBuf.SetCapacity(cuSize);
      _chunkSizeLog = BlockSizeLog + CompressionUnit;
      _outBuf.SetCapacity(kNumCacheChunks << _chunkSizeLog);
    }
    for (int i = 0; i < kNumCacheChunks; i++)
      _tags[i] = kEmptyTag;

    _sparseMode = false;
    _curRem = 0;
    _virtPos = 0;
    _physPos = 0;
    const CExtent &e = Extents[0];
    if (!e.IsEmpty())
      _physPos = e.Phy << BlockSizeLog;
    return SeekToPhys();
  }

  MY_UNKNOWN_IMP1(IInStream)

  STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
  STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition);
};

static size_t Lznt1Dec(Byte *dest, size_t outBufLim, size_t destLen, const Byte *src, size_t srcLen)
{
  size_t destSize = 0;
  while (destSize < destLen)
  {
    if (srcLen < 2 || (destSize & 0xFFF) != 0)
      break;
    UInt32 v = Get16(src);
    if (v == 0)
      break;
    src += 2;
    srcLen -= 2;
    UInt32 comprSize = (v & 0xFFF) + 1;
    if (comprSize > srcLen)
      break;
    srcLen -= comprSize;
    if ((v & 0x8000) == 0)
    {
      if (comprSize != (1 << 12))
        break;
      memcpy(dest + destSize, src, comprSize);
      src += comprSize;
      destSize += comprSize;
    }
    else
    {
      if (destSize + (1 << 12) > outBufLim || (src[0] & 1) != 0)
        return 0;
      int numDistBits = 4;
      UInt32 sbOffset = 0;
      UInt32 pos = 0;

      do
      {
        comprSize--;
        for (UInt32 mask = src[pos++] | 0x100; mask > 1 && comprSize > 0; mask >>= 1)
        {
          if ((mask & 1) == 0)
          {
            if (sbOffset >= (1 << 12))
              return 0;
            dest[destSize++] = src[pos++];
            sbOffset++;
            comprSize--;
          }
          else
          {
            if (comprSize < 2)
              return 0;
            UInt32 v = Get16(src + pos);
            pos += 2;
            comprSize -= 2;

            while (((sbOffset - 1) >> numDistBits) != 0)
              numDistBits++;

            UInt32 len = (v & (0xFFFF >> numDistBits)) + 3;
            if (sbOffset + len > (1 << 12))
              return 0;
            UInt32 dist = (v >> (16 - numDistBits));
            if (dist >= sbOffset)
              return 0;
            Int32 offs = -1 - dist;
            Byte *p = dest + destSize;
            for (UInt32 t = 0; t < len; t++)
              p[t] = p[t + offs];
            destSize += len;
            sbOffset += len;
          }
        }
      }
      while (comprSize > 0);
      src += pos;
    }
  }
  return destSize;
}

STDMETHODIMP CInStream::Read(void *data, UInt32 size, UInt32 *processedSize)
{
  if (processedSize != NULL)
    *processedSize = 0;
  if (_virtPos >= Size)
    return (Size == _virtPos) ? S_OK: E_FAIL;
  if (size == 0)
    return S_OK;
  UInt64 rem = Size - _virtPos;
  if (size > rem)
    size = (UInt32)rem;
  if (_virtPos >= InitializedSize)
  {
    memset((Byte *)data, 0, size);
    _virtPos += size;
    *processedSize = size;
    return S_OK;
  }
  rem = InitializedSize - _virtPos;
  if (size > rem)
    size = (UInt32)rem;

  while (_curRem == 0)
  {
    UInt64 cacheTag = _virtPos >> _chunkSizeLog;
    UInt32 cacheIndex = (UInt32)cacheTag & (kNumCacheChunks - 1);
    if (_tags[cacheIndex] == cacheTag)
    {
      UInt32 chunkSize = (UInt32)1 << _chunkSizeLog;
      UInt32 offset = (UInt32)_virtPos & (chunkSize - 1);
      UInt32 cur = MyMin(chunkSize - offset, size);
      memcpy(data, _outBuf + (cacheIndex << _chunkSizeLog) + offset, cur);
      *processedSize = cur;
      _virtPos += cur;
      return S_OK;
    }

    PRF2(printf("\nVirtPos = %6d", _virtPos));
    
    UInt32 comprUnitSize = (UInt32)1 << CompressionUnit;
    UInt64 virtBlock = _virtPos >> BlockSizeLog;
    UInt64 virtBlock2 = virtBlock & ~((UInt64)comprUnitSize - 1);
    
    int left = 0, right = Extents.Size();
    for (;;)
    {
      int mid = (left + right) / 2;
      if (mid == left)
        break;
      if (virtBlock2 < Extents[mid].Virt)
        right = mid;
      else
        left = mid;
    }
    
    bool isCompressed = false;
    UInt64 virtBlock2End = virtBlock2 + comprUnitSize;
    if (CompressionUnit != 0)
      for (int i = left; i < Extents.Size(); i++)
      {
        const CExtent &e = Extents[i];
        if (e.Virt >= virtBlock2End)
          break;
        if (e.IsEmpty())
        {
          isCompressed = true;
          break;
        }
      }

    int i;
    for (i = left; Extents[i + 1].Virt <= virtBlock; i++);
    
    _sparseMode = false;
    if (!isCompressed)
    {
      const CExtent &e = Extents[i];
      UInt64 newPos = (e.Phy << BlockSizeLog) + _virtPos - (e.Virt << BlockSizeLog);
      if (newPos != _physPos)
      {
        _physPos = newPos;
        RINOK(SeekToPhys());
      }
      UInt64 next = Extents[i + 1].Virt;
      if (next > virtBlock2End)
        next &= ~((UInt64)comprUnitSize - 1);
      next <<= BlockSizeLog;
      if (next > Size)
        next = Size;
      _curRem = next - _virtPos;
      break;
    }
    bool thereArePhy = false;
    for (int i2 = left; i2 < Extents.Size(); i2++)
    {
      const CExtent &e = Extents[i2];
      if (e.Virt >= virtBlock2End)
        break;
      if (!e.IsEmpty())
      {
        thereArePhy = true;
        break;
      }
    }
    if (!thereArePhy)
    {
      _curRem = (Extents[i + 1].Virt << BlockSizeLog) - _virtPos;
      _sparseMode = true;
      break;
    }
    
    size_t offs = 0;
    UInt64 curVirt = virtBlock2;
    for (i = left; i < Extents.Size(); i++)
    {
      const CExtent &e = Extents[i];
      if (e.IsEmpty())
        break;
      if (e.Virt >= virtBlock2End)
        return S_FALSE;
      UInt64 newPos = (e.Phy + (curVirt - e.Virt)) << BlockSizeLog;
      if (newPos != _physPos)
      {
        _physPos = newPos;
        RINOK(SeekToPhys());
      }
      UInt64 numChunks = Extents[i + 1].Virt - curVirt;
      if (curVirt + numChunks > virtBlock2End)
        numChunks = virtBlock2End - curVirt;
      size_t compressed = (size_t)numChunks << BlockSizeLog;
      RINOK(ReadStream_FALSE(Stream, _inBuf + offs, compressed));
      curVirt += numChunks;
      _physPos += compressed;
      offs += compressed;
    }
    size_t destLenMax = GetCuSize();
    size_t destLen = destLenMax;
    UInt64 rem = Size - (virtBlock2 << BlockSizeLog);
    if (destLen > rem)
      destLen = (size_t)rem;

    Byte *dest = _outBuf + (cacheIndex << _chunkSizeLog);
    size_t destSizeRes = Lznt1Dec(dest, destLenMax, destLen, _inBuf, offs);
    _tags[cacheIndex] = cacheTag;

    // some files in Vista have destSize > destLen
    if (destSizeRes < destLen)
    {
      memset(dest, 0, destLenMax);
      if (InUse)
        return S_FALSE;
    }
  }
  if (size > _curRem)
    size = (UInt32)_curRem;
  HRESULT res = S_OK;
  if (_sparseMode)
    memset(data, 0, size);
  else
  {
    res = Stream->Read(data, size, &size);
    _physPos += size;
  }
  if (processedSize != NULL)
    *processedSize = size;
  _virtPos += size;
  _curRem -= size;
  return res;
}
 
STDMETHODIMP CInStream::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition)
{
  UInt64 newVirtPos = offset;
  switch(seekOrigin)
  {
    case STREAM_SEEK_SET: break;
    case STREAM_SEEK_CUR: newVirtPos += _virtPos; break;
    case STREAM_SEEK_END: newVirtPos += Size; break;
    default: return STG_E_INVALIDFUNCTION;
  }
  if (_virtPos != newVirtPos)
    _curRem = 0;
  _virtPos = newVirtPos;
  if (newPosition)
    *newPosition = newVirtPos;
  return S_OK;
}

class CByteBufStream:
  public IInStream,
  public CMyUnknownImp
{
  UInt64 _virtPos;
public:
  CByteBuffer Buf;
  void Init() { _virtPos = 0; }
 
  MY_UNKNOWN_IMP1(IInStream)

  STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
  STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition);
};

STDMETHODIMP CByteBufStream::Read(void *data, UInt32 size, UInt32 *processedSize)
{
  if (processedSize != NULL)
    *processedSize = 0;
  if (_virtPos >= Buf.GetCapacity())
    return (_virtPos == Buf.GetCapacity()) ? S_OK: E_FAIL;
  UInt64 rem = Buf.GetCapacity() - _virtPos;
  if (rem < size)
    size = (UInt32)rem;
  memcpy(data, Buf + (size_t)_virtPos, size);
  if (processedSize != NULL)
    *processedSize = size;
  _virtPos += size;
  return S_OK;
}

STDMETHODIMP CByteBufStream::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition)
{
  switch(seekOrigin)
  {
    case STREAM_SEEK_SET: _virtPos = offset; break;
    case STREAM_SEEK_CUR: _virtPos += offset; break;
    case STREAM_SEEK_END: _virtPos = Buf.GetCapacity() + offset; break;
    default: return STG_E_INVALIDFUNCTION;
  }
  if (newPosition)
    *newPosition = _virtPos;
  return S_OK;
}

HRESULT DataParseExtents(int clusterSizeLog, const CObjectVector<CAttr> attrs,
    int attrIndex, int attrIndexLim, UInt64 numPhysClusters, CRecordVector<CExtent> &Extents)
{
  CExtent e;
  e.Virt = 0;
  e.Phy = kEmptyExtent;
  Extents.Add(e);
  const CAttr &attr0 = attrs[attrIndex];

  if (attr0.AllocatedSize < attr0.Size ||
      (attrs[attrIndexLim - 1].HighVcn + 1) != (attr0.AllocatedSize >> clusterSizeLog) ||
      (attr0.AllocatedSize & ((1 << clusterSizeLog) - 1)) != 0)
    return S_FALSE;
  
  for (int i = attrIndex; i < attrIndexLim; i++)
    if (!attrs[i].ParseExtents(Extents, numPhysClusters, attr0.CompressionUnit))
      return S_FALSE;

  UInt64 packSizeCalc = 0;
  for (int k = 0; k < Extents.Size(); k++)
  {
    CExtent &e = Extents[k];
    if (!e.IsEmpty())
      packSizeCalc += (Extents[k + 1].Virt - e.Virt) << clusterSizeLog;
    PRF2(printf("\nSize = %4I64X", Extents[k + 1].Virt - e.Virt));
    PRF2(printf("  Pos = %4I64X", e.Phy));
  }
  
  if (attr0.CompressionUnit != 0)
  {
    if (packSizeCalc != attr0.PackSize)
      return S_FALSE;
  }
  else
  {
    if (packSizeCalc != attr0.AllocatedSize)
      return S_FALSE;
  }
  return S_OK;
}

struct CDataRef
{
  int Start;
  int Num;
};

static const UInt32 kMagic_FILE = 0x454c4946;
static const UInt32 kMagic_BAAD = 0x44414142;

struct CMftRec
{
  UInt32 Magic;
  // UInt64 Lsn;
  UInt16 SeqNumber;
  UInt16 Flags;
  // UInt16 LinkCount;
  // UInt16 NextAttrInstance;
  CMftRef BaseMftRef;
  // UInt32 ThisRecNumber;
  UInt32 MyNumNameLinks;

  CObjectVector<CAttr> DataAttrs;
  CObjectVector<CFileNameAttr> FileNames;
  CRecordVector<CDataRef> DataRefs;

  CSiAttr SiAttr;

  void MoveAttrsFrom(CMftRec &src)
  {
    DataAttrs += src.DataAttrs;
    FileNames += src.FileNames;
    src.DataAttrs.ClearAndFree();
    src.FileNames.ClearAndFree();
  }

  UInt64 GetPackSize() const
  {
    UInt64 res = 0;
    for (int i = 0; i < DataRefs.Size(); i++)
      res += DataAttrs[DataRefs[i].Start].GetPackSize();
    return res;
  }

  bool Parse(Byte *p, int sectorSizeLog, UInt32 numSectors, UInt32 recNumber, CObjectVector<CAttr> *attrs);

  bool IsEmpty() const { return (Magic <= 2); }
  bool IsFILE() const { return (Magic == kMagic_FILE); }
  bool IsBAAD() const { return (Magic == kMagic_BAAD); }

  bool InUse() const { return (Flags & 1) != 0; }
  bool IsDir() const { return (Flags & 2) != 0; }

  void ParseDataNames();
  HRESULT GetStream(IInStream *mainStream, int dataIndex,
      int clusterSizeLog, UInt64 numPhysClusters, IInStream **stream) const;

  UInt64 GetSize(int dataIndex) const { return DataAttrs[DataRefs[dataIndex].Start].GetSize(); }

  CMftRec(): MyNumNameLinks(0) {}
};

void CMftRec::ParseDataNames()
{
  DataRefs.Clear();
  DataAttrs.Sort(CompareAttr, 0);

  for (int i = 0; i < DataAttrs.Size();)
  {
    CDataRef ref;
    ref.Start = i;
    for (i++; i < DataAttrs.Size(); i++)
      if (DataAttrs[ref.Start].Name != DataAttrs[i].Name)
        break;
    ref.Num = i - ref.Start;
    DataRefs.Add(ref);
  }
}

HRESULT CMftRec::GetStream(IInStream *mainStream, int dataIndex,
    int clusterSizeLog, UInt64 numPhysClusters, IInStream **destStream) const
{
  *destStream = 0;
  CByteBufStream *streamSpec = new CByteBufStream;
  CMyComPtr<IInStream> streamTemp = streamSpec;

  if (dataIndex < 0)
    return E_FAIL;

  if (dataIndex < DataRefs.Size())
  {
    const CDataRef &ref = DataRefs[dataIndex];
    int numNonResident = 0;
    int i;
    for (i = ref.Start; i < ref.Start + ref.Num; i++)
      if (DataAttrs[i].NonResident)
        numNonResident++;

    const CAttr &attr0 = DataAttrs[ref.Start];
      
    if (numNonResident != 0 || ref.Num != 1)
    {
      if (numNonResident != ref.Num || !attr0.IsCompressionUnitSupported())
        return S_FALSE;
      CInStream *streamSpec = new CInStream;
      CMyComPtr<IInStream> streamTemp = streamSpec;
      RINOK(DataParseExtents(clusterSizeLog, DataAttrs, ref.Start, ref.Start + ref.Num, numPhysClusters, streamSpec->Extents));
      streamSpec->Size = attr0.Size;
      streamSpec->InitializedSize = attr0.InitializedSize;
      streamSpec->Stream = mainStream;
      streamSpec->BlockSizeLog = clusterSizeLog;
      streamSpec->InUse = InUse();
      RINOK(streamSpec->InitAndSeek(attr0.CompressionUnit));
      *destStream = streamTemp.Detach();
      return S_OK;
    }
    streamSpec->Buf = attr0.Data;
  }
  streamSpec->Init();
  *destStream = streamTemp.Detach();
  return S_OK;
}

bool CMftRec::Parse(Byte *p, int sectorSizeLog, UInt32 numSectors, UInt32 recNumber,
    CObjectVector<CAttr> *attrs)
{
  G32(p, Magic);
  if (!IsFILE())
    return IsEmpty() || IsBAAD();

  UInt32 usaOffset;
  UInt32 numUsaItems;
  G16(p + 0x04, usaOffset);
  G16(p + 0x06, numUsaItems);
  
  if ((usaOffset & 1) != 0 || usaOffset + numUsaItems * 2 > ((UInt32)1 << sectorSizeLog) - 2 ||
      numUsaItems == 0 || numUsaItems - 1 != numSectors)
    return false;

  UInt16 usn = Get16(p + usaOffset);
  // PRF(printf("\nusn = %d", usn));
  for (UInt32 i = 1; i < numUsaItems; i++)
  {
    void *pp = p + (i << sectorSizeLog)  - 2;
    if (Get16(pp) != usn)
      return false;
    SetUi16(pp, Get16(p + usaOffset + i * 2));
  }

  // G64(p + 0x08, Lsn);
  G16(p + 0x10, SeqNumber);
  // G16(p + 0x12, LinkCount);
  // PRF(printf(" L=%d", LinkCount));
  UInt32 attrOffs = Get16(p + 0x14);
  G16(p + 0x16, Flags);
  PRF(printf(" F=%4X", Flags));

  UInt32 bytesInUse = Get32(p + 0x18);
  UInt32 bytesAlloc = Get32(p + 0x1C);
  G64(p + 0x20, BaseMftRef.Val);
  if (BaseMftRef.Val != 0)
  {
    PRF(printf("  BaseRef=%d", (int)BaseMftRef.Val));
    // return false; // Check it;
  }
  // G16(p + 0x28, NextAttrInstance);
  if (usaOffset >= 0x30)
    if (Get32(p + 0x2C) != recNumber) // NTFS 3.1+
      return false;

  UInt32 limit = numSectors << sectorSizeLog;
  if (attrOffs >= limit || (attrOffs & 7) != 0 || bytesInUse > limit
      || bytesAlloc != limit)
    return false;


  for (UInt32 t = attrOffs; t < limit;)
  {
    CAttr attr;
    // PRF(printf("\n  %2d:", Attrs.Size()));
    PRF(printf("\n"));
    UInt32 length = attr.Parse(p + t, limit - t);
    if (length == 0 || limit - t < length)
      return false;
    t += length;
    if (attr.Type == 0xFFFFFFFF)
      break;
    switch(attr.Type)
    {
      case ATTR_TYPE_FILE_NAME:
      {
        CFileNameAttr fna;
        if (!attr.ParseFileName(fna))
          return false;
        FileNames.Add(fna);
        PRF(printf("  flags = %4x", (int)fna.NameType));
        PRF(printf("\n  %S", fna.Name));
        break;
      }
      case ATTR_TYPE_STANDARD_INFO:
        if (!attr.ParseSi(SiAttr))
          return false;
        break;
      case ATTR_TYPE_DATA:
        DataAttrs.Add(attr);
        break;
      default:
        if (attrs)
          attrs->Add(attr);
        break;
    }
  }

  return true;
}

struct CItem
{
  int RecIndex;
  int DataIndex;
  CMftRef ParentRef;
  UString Name;
  UInt32 Attrib;

  bool IsDir() const { return (DataIndex < 0); }
};

struct CDatabase
{
  CHeader Header;
  CObjectVector<CItem> Items;
  CObjectVector<CMftRec> Recs;
  CMyComPtr<IInStream> InStream;
  IArchiveOpenCallback *OpenCallback;

  CByteBuffer ByteBuf;

  CObjectVector<CAttr> VolAttrs;

  ~CDatabase() { ClearAndClose(); }

  void Clear();
  void ClearAndClose();

  UString GetItemPath(Int32 index) const;
  HRESULT Open();
  HRESULT ReadDir(Int32 parent, UInt32 cluster, int level);

  HRESULT SeekToCluster(UInt64 cluster);

  int FindMtfRec(const CMftRef &ref) const
  {
    UInt64 val = ref.GetIndex();
    int left = 0, right = Items.Size();
    while (left != right)
    {
      int mid = (left + right) / 2;
      UInt64 midValue = Items[mid].RecIndex;
      if (val == midValue)
        return mid;
      if (val < midValue)
        right = mid;
      else
        left = mid + 1;
    }
    return -1;
  }

};

HRESULT CDatabase::SeekToCluster(UInt64 cluster)
{
  return InStream->Seek(cluster << Header.ClusterSizeLog, STREAM_SEEK_SET, NULL);
}

void CDatabase::Clear()
{
  Items.Clear();
  Recs.Clear();
}

void CDatabase::ClearAndClose()
{
  Clear();
  InStream.Release();
}

#define MY_DIR_PREFIX(x) L"[" x L"]" WSTRING_PATH_SEPARATOR

UString CDatabase::GetItemPath(Int32 index) const
{
  const CItem *item = &Items[index];
  UString name = item->Name;
  for (int j = 0; j < 256; j++)
  {
    CMftRef ref = item->ParentRef;
    index = FindMtfRec(ref);
    if (ref.GetIndex() == 5)
      return name;
    if (index < 0 || Recs[Items[index].RecIndex].SeqNumber != ref.GetNumber())
      return MY_DIR_PREFIX(L"UNKNOWN") + name;
    item = &Items[index];
    name = item->Name + WCHAR_PATH_SEPARATOR + name;
  }
  return MY_DIR_PREFIX(L"BAD") + name;
}

HRESULT CDatabase::Open()
{
  Clear();
  
  static const UInt32 kHeaderSize = 512;
  Byte buf[kHeaderSize];
  RINOK(ReadStream_FALSE(InStream, buf, kHeaderSize));
  if (!Header.Parse(buf))
    return S_FALSE;
  UInt64 fileSize;
  RINOK(InStream->Seek(0, STREAM_SEEK_END, &fileSize));
  if (fileSize < Header.GetPhySize())
    return S_FALSE;
  
  SeekToCluster(Header.MftCluster);

  CMftRec mftRec;
  UInt32 numSectorsInRec;
  int recSizeLog;
  CMyComPtr<IInStream> mftStream;
  {
    UInt32 blockSize = 1 << 12;
    ByteBuf.SetCapacity(blockSize);
    RINOK(ReadStream_FALSE(InStream, ByteBuf, blockSize));
    
    UInt32 allocSize = Get32(ByteBuf + 0x1C);
    recSizeLog = GetLog(allocSize);
    if (recSizeLog < Header.SectorSizeLog)
      return false;
    numSectorsInRec = 1 << (recSizeLog - Header.SectorSizeLog);
    if (!mftRec.Parse(ByteBuf, Header.SectorSizeLog, numSectorsInRec, NULL, 0))
      return S_FALSE;
    if (!mftRec.IsFILE())
      return S_FALSE;
    mftRec.ParseDataNames();
    if (mftRec.DataRefs.IsEmpty())
      return S_FALSE;
    RINOK(mftRec.GetStream(InStream, 0, Header.ClusterSizeLog, Header.NumClusters, &mftStream));
    if (!mftStream)
      return S_FALSE;
  }

  UInt64 mftSize = mftRec.DataAttrs[0].Size;
  if ((mftSize >> 4) > Header.GetPhySize())
    return S_FALSE;

  UInt64 numFiles = mftSize >> recSizeLog;
  if (numFiles > (1 << 30))
    return S_FALSE;
  if (OpenCallback)
  {
    RINOK(OpenCallback->SetTotal(&numFiles, &mftSize));
  }
  const UInt32 kBufSize = (1 << 15);
  if (kBufSize < (1 << recSizeLog))
    return S_FALSE;

  ByteBuf.SetCapacity((size_t)kBufSize);
  Recs.Reserve((int)numFiles);
  for (UInt64 pos64 = 0;;)
  {
    if (OpenCallback)
    {
      // Sleep(0);
      UInt64 numFiles = Recs.Size();
      RINOK(OpenCallback->SetCompleted(&numFiles, &pos64));
    }
    UInt32 readSize = kBufSize;
    UInt64 rem = mftSize - pos64;
    if (readSize > rem)
      readSize = (UInt32)rem;
    if (readSize < ((UInt32)1 << recSizeLog))
      break;
    RINOK(ReadStream_FALSE(mftStream, ByteBuf, (size_t)readSize));
    pos64 += readSize;
    for (int i = 0; ((UInt32)(i + 1) << recSizeLog) <= readSize; i++)
    {
      PRF(printf("\n---------------------"));
      PRF(printf("\n%5d:", Recs.Size()));
      Byte *p = ByteBuf + ((UInt32)i << recSizeLog);
      CMftRec rec;
      if (!rec.Parse(p, Header.SectorSizeLog, numSectorsInRec, (UInt32)Recs.Size(),
          (Recs.Size() == kRecIndex_Volume) ? &VolAttrs: NULL))
        return S_FALSE;
      Recs.Add(rec);
    }
  }

  int i;
  for (i = 0; i < Recs.Size(); i++)
  {
    CMftRec &rec = Recs[i];
    if (!rec.BaseMftRef.IsBaseItself())
    {
      UInt64 refIndex = rec.BaseMftRef.GetIndex();
      if (refIndex > (UInt32)Recs.Size())
        return S_FALSE;
      CMftRec &refRec = Recs[(int)refIndex];
      bool moveAttrs = (refRec.SeqNumber == rec.BaseMftRef.GetNumber() && refRec.BaseMftRef.IsBaseItself());
      if (rec.InUse() && refRec.InUse())
      {
        if (!moveAttrs)
          return S_FALSE;
      }
      else if (rec.InUse() || refRec.InUse())
        moveAttrs = false;
      if (moveAttrs)
        refRec.MoveAttrsFrom(rec);
    }
  }

  for (i = 0; i < Recs.Size(); i++)
    Recs[i].ParseDataNames();
  
  for (i = 0; i < Recs.Size(); i++)
  {
    CMftRec &rec = Recs[i];
    if (!rec.IsFILE() || !rec.BaseMftRef.IsBaseItself())
      continue;
    int numNames = 0;
    // printf("\n%4d: ", i);
    for (int t = 0; t < rec.FileNames.Size(); t++)
    {
      const CFileNameAttr &fna = rec.FileNames[t];
      // printf("%4d %S  | ", (int)fna.NameType, fna.Name);
      if (fna.IsDos())
        continue;
      int numDatas = rec.DataRefs.Size();

      // For hard linked files we show substreams only for first Name.
      if (numDatas > 1 && numNames > 0)
        numDatas = 1;
      numNames++;

      if (rec.IsDir())
      {
        CItem item;
        item.Name = fna.Name;
        item.RecIndex = i;
        item.DataIndex = -1;
        item.ParentRef = fna.ParentDirRef;
        item.Attrib = rec.SiAttr.Attrib | 0x10;
        // item.Attrib = fna.Attrib;
        Items.Add(item);
      }
      for (int di = 0; di < numDatas; di++)
      {
        CItem item;
        item.Name = fna.Name;
        item.Attrib = rec.SiAttr.Attrib;
        const UString &subName = rec.DataAttrs[rec.DataRefs[di].Start].Name;
        if (!subName.IsEmpty())
        {
          // $BadClus:$Bad is sparse file for all clusters. So we skip it.
          if (i == kRecIndex_BadClus && subName == L"$Bad")
            continue;
          item.Name += L":";
          item.Name += subName;
          item.Attrib = fna.Attrib;
        }
        
        PRF(printf("\n%3d", i));
        PRF(printf("  attrib=%2x", rec.SiAttr.Attrib));
        PRF(printf(" %S", item.Name));
        
        item.RecIndex = i;
        item.DataIndex = di;
        item.ParentRef = fna.ParentDirRef;

        Items.Add(item);
        rec.MyNumNameLinks++;
      }
    }
    rec.FileNames.ClearAndFree();
  }
  
  return S_OK;
}

class CHandler:
  public IInArchive,
  public IInArchiveGetStream,
  public CMyUnknownImp,
  CDatabase
{
public:
  MY_UNKNOWN_IMP2(IInArchive, IInArchiveGetStream)
  INTERFACE_IInArchive(;)
  STDMETHOD(GetStream)(UInt32 index, ISequentialInStream **stream);
};

STDMETHODIMP CHandler::GetStream(UInt32 index, ISequentialInStream **stream)
{
  COM_TRY_BEGIN
  IInStream *stream2;
  const CItem &item = Items[index];
  const CMftRec &rec = Recs[item.RecIndex];
  HRESULT res = rec.GetStream(InStream, item.DataIndex, Header.ClusterSizeLog, Header.NumClusters, &stream2);
  *stream = (ISequentialInStream *)stream2;
  return res;
  COM_TRY_END
}

STATPROPSTG kProps[] =
{
  { NULL, kpidPath, VT_BSTR},
  { NULL, kpidIsDir, VT_BOOL},
  { NULL, kpidSize, VT_UI8},
  { NULL, kpidPackSize, VT_UI8},
  { NULL, kpidMTime, VT_FILETIME},
  { NULL, kpidCTime, VT_FILETIME},
  { NULL, kpidATime, VT_FILETIME},
  { NULL, kpidAttrib, VT_UI4},
  { NULL, kpidLinks, VT_UI4}
};

STATPROPSTG kArcProps[] =
{
  { NULL, kpidVolumeName, VT_BSTR},
  { NULL, kpidFileSystem, VT_BSTR},
  { NULL, kpidClusterSize, VT_UI4},
  { NULL, kpidPhySize, VT_UI8},
  { NULL, kpidHeadersSize, VT_UI8},
  { NULL, kpidCTime, VT_FILETIME},

  { NULL, kpidSectorSize, VT_UI4},
  { NULL, kpidId, VT_UI8}
  // { NULL, kpidSectorsPerTrack, VT_UI4},
  // { NULL, kpidNumHeads, VT_UI4},
  // { NULL, kpidHiddenSectors, VT_UI4}
};

IMP_IInArchive_Props
IMP_IInArchive_ArcProps

static void NtfsTimeToProp(UInt64 t, NWindows::NCOM::CPropVariant &prop)
{
  FILETIME ft;
  ft.dwLowDateTime = (DWORD)t;
  ft.dwHighDateTime = (DWORD)(t >> 32);
  prop = ft;
}

STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
{
  COM_TRY_BEGIN
  NWindows::NCOM::CPropVariant prop;

  const CMftRec *volRec = (Recs.Size() > kRecIndex_Volume ? &Recs[kRecIndex_Volume] : NULL);

  switch(propID)
  {
    case kpidClusterSize: prop = Header.ClusterSize(); break;
    case kpidPhySize: prop = Header.GetPhySize(); break;
    /*
    case kpidHeadersSize:
    {
      UInt64 val = 0;
      for (int i = 0; i < kNumSysRecs; i++)
      {
        printf("\n%2d: %8I64d ", i, Recs[i].GetPackSize());
        if (i == 8)
          i = i
        val += Recs[i].GetPackSize();
      }
      prop = val;
      break;
    }
    */
    case kpidCTime: if (volRec) NtfsTimeToProp(volRec->SiAttr.CTime, prop); break;break;
    case kpidVolumeName:
    {
      for (int i = 0; i < VolAttrs.Size(); i++)
      {
        const CAttr &attr = VolAttrs[i];
        if (attr.Type == ATTR_TYPE_VOLUME_NAME)
        {
          UString name;
          GetString(attr.Data, (int)attr.Data.GetCapacity() / 2, name);
          prop = name;
          break;
        }
      }
      break;
    }
    case kpidFileSystem:
    {
      AString s = "NTFS";
      for (int i = 0; i < VolAttrs.Size(); i++)
      {
        const CAttr &attr = VolAttrs[i];
        if (attr.Type == ATTR_TYPE_VOLUME_INFO)
        {
          CVolInfo vi;
          if (attr.ParseVolInfo(vi))
          {
            s += ' ';
            char temp[16];
            ConvertUInt32ToString(vi.MajorVer, temp);
            s += temp;
            s += '.';
            ConvertUInt32ToString(vi.MinorVer, temp);
            s += temp;
          }
          break;
        }
      }
      prop = s;
      break;
    }
    case kpidSectorSize: prop = (UInt32)1 << Header.SectorSizeLog; break;
    case kpidId: prop = Header.SerialNumber; break;
    // case kpidMediaType: prop = Header.MediaType; break;
    // case kpidSectorsPerTrack: prop = Header.SectorsPerTrack; break;
    // case kpidNumHeads: prop = Header.NumHeads; break;
    // case kpidHiddenSectors: prop = Header.NumHiddenSectors; break;
  }
  prop.Detach(value);
  return S_OK;
  COM_TRY_END
}

STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
{
  COM_TRY_BEGIN
  NWindows::NCOM::CPropVariant prop;
  const CItem &item = Items[index];
  const CMftRec &rec = Recs[item.RecIndex];

  const CAttr *data= NULL;
  if (item.DataIndex >= 0)
    data = &rec.DataAttrs[rec.DataRefs[item.DataIndex].Start];

  switch(propID)
  {
    case kpidPath:
    {
      UString name = GetItemPath(index);
      const wchar_t *prefix = NULL;
      if (!rec.InUse())
        prefix = MY_DIR_PREFIX(L"DELETED");
      else if (item.RecIndex < kNumSysRecs)
        prefix = MY_DIR_PREFIX(L"SYSTEM");
      if (prefix)
        name = prefix + name;
      prop = name;
      break;
    }

    case kpidIsDir: prop = item.IsDir(); break;
    case kpidMTime: NtfsTimeToProp(rec.SiAttr.MTime, prop); break;
      
    case kpidCTime: NtfsTimeToProp(rec.SiAttr.CTime, prop); break;
    case kpidATime: NtfsTimeToProp(rec.SiAttr.ATime, prop); break;
    case kpidAttrib:
      prop = item.Attrib;
      break;
    case kpidLinks: prop = rec.MyNumNameLinks; break;
    case kpidSize: if (data) prop = data->GetSize(); break;
    case kpidPackSize: if (data) prop = data->GetPackSize(); break;
  }
  prop.Detach(value);
  return S_OK;
  COM_TRY_END
}

STDMETHODIMP CHandler::Open(IInStream *stream, const UInt64 *, IArchiveOpenCallback *callback)
{
  COM_TRY_BEGIN
  {
    OpenCallback = callback;
    InStream = stream;
    HRESULT res;
    try
    {
      res = CDatabase::Open();
      if (res == S_OK)
        return S_OK;
    }
    catch(...)
    {
      Close();
      throw;
    }
    Close();
    return res;
  }
  COM_TRY_END
}

STDMETHODIMP CHandler::Close()
{
  ClearAndClose();
  return S_OK;
}

STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
    Int32 testMode, IArchiveExtractCallback *extractCallback)
{
  COM_TRY_BEGIN
  bool allFilesMode = (numItems == (UInt32)-1);
  if (allFilesMode)
    numItems = Items.Size();
  if (numItems == 0)
    return S_OK;
  UInt32 i;
  UInt64 totalSize = 0;
  for (i = 0; i < numItems; i++)
  {
    const CItem &item = Items[allFilesMode ? i : indices[i]];
    const CMftRec &rec = Recs[item.RecIndex];
    if (!rec.IsDir())
      totalSize += rec.GetSize(item.DataIndex);
  }
  RINOK(extractCallback->SetTotal(totalSize));

  UInt64 totalPackSize;
  totalSize = totalPackSize = 0;
  
  CByteBuffer buf;
  UInt32 clusterSize = Header.ClusterSize();
  buf.SetCapacity(clusterSize);

  NCompress::CCopyCoder *copyCoderSpec = new NCompress::CCopyCoder();
  CMyComPtr<ICompressCoder> copyCoder = copyCoderSpec;

  CLocalProgress *lps = new CLocalProgress;
  CMyComPtr<ICompressProgressInfo> progress = lps;
  lps->Init(extractCallback, false);

  CDummyOutStream *outStreamSpec = new CDummyOutStream;
  CMyComPtr<ISequentialOutStream> outStream(outStreamSpec);

  for (i = 0; i < numItems; i++)
  {
    lps->InSize = totalPackSize;
    lps->OutSize = totalSize;
    RINOK(lps->SetCur());
    CMyComPtr<ISequentialOutStream> realOutStream;
    Int32 askMode = testMode ?
        NExtract::NAskMode::kTest :
        NExtract::NAskMode::kExtract;
    Int32 index = allFilesMode ? i : indices[i];
    RINOK(extractCallback->GetStream(index, &realOutStream, askMode));

    const CItem &item = Items[index];
    if (item.IsDir())
    {
      RINOK(extractCallback->PrepareOperation(askMode));
      RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kOK));
      continue;
    }

    if (!testMode && !realOutStream)
      continue;
    RINOK(extractCallback->PrepareOperation(askMode));

    outStreamSpec->SetStream(realOutStream);
    realOutStream.Release();
    outStreamSpec->Init();

    const CMftRec &rec = Recs[item.RecIndex];
    const CAttr &data = rec.DataAttrs[rec.DataRefs[item.DataIndex].Start];

    int res = NExtract::NOperationResult::kDataError;
    {
      CMyComPtr<IInStream> inStream;
      HRESULT hres = rec.GetStream(InStream, item.DataIndex, Header.ClusterSizeLog, Header.NumClusters, &inStream);
      if (hres == S_FALSE)
        res = NExtract::NOperationResult::kUnSupportedMethod;
      else
      {
        RINOK(hres);
        if (inStream)
        {
          HRESULT hres = copyCoder->Code(inStream, outStream, NULL, NULL, progress);
          if (hres != S_OK &&  hres != S_FALSE)
          {
            RINOK(hres);
          }
          if (/* copyCoderSpec->TotalSize == item.GetSize() && */ hres == S_OK)
            res = NExtract::NOperationResult::kOK;
        }
      }
    }
    totalPackSize += data.GetPackSize();
    totalSize += data.GetSize();
    outStreamSpec->ReleaseStream();
    RINOK(extractCallback->SetOperationResult(res));
  }
  return S_OK;
  COM_TRY_END
}

STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
{
  *numItems = Items.Size();
  return S_OK;
}

static IInArchive *CreateArc() { return new CHandler; }

static CArcInfo g_ArcInfo =
  { L"NTFS", L"ntfs img", 0, 0xD9, { 'N', 'T', 'F', 'S', ' ', ' ', ' ', ' ', 0 }, 9, false, CreateArc, 0 };

REGISTER_ARC(Fat)

}}
<file_sep>/FBReader/zlibrary/ui/src/qt4/dialogs/ZLQtSelectionDialog.h
/*
 * Copyright (C) 2004-2010 <NAME> <<EMAIL>>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 * 02110-1301, USA.
 */

#ifndef __ZLQTSELECTIONDIALOG_H__
#define __ZLQTSELECTIONDIALOG_H__

#include <string>
#include <map>

#include <QtGui/QDialog>
#include <QtGui/QPainter>
#include <QtGui/QListWidget>

#include "../../../../core/src/desktop/dialogs/ZLDesktopSelectionDialog.h"

class QVBox;
class QLineEdit;

class ZLQtSelectionDialogItem : public QListWidgetItem {

public:
	ZLQtSelectionDialogItem(QListWidget *listWidget, const ZLTreeNodePtr node);
	ZLTreeNodePtr node() const { return myNode; }

private:
	ZLTreeNodePtr myNode;
};

class ZLQListWidget : public QListWidget {

Q_OBJECT

public:
	ZLQListWidget(QWidget *parent);

Q_SIGNALS:
	void returnPressed();

private:
	void keyPressEvent(QKeyEvent *event);
};


class ZLQtSelectionDialog : public QDialog, public ZLDesktopSelectionDialog {

Q_OBJECT

public:
	ZLQtSelectionDialog(const std::string &caption, ZLTreeHandler &handler); 
	~ZLQtSelectionDialog();
	bool run();

private:
	QIcon &getIcon(const ZLTreeNodePtr node);

protected:
	void keyPressEvent(QKeyEvent *event);

	void setSize(int width, int height) { QDialog::resize(width, height); }
	int width() const { return QDialog::width(); }
	int height() const { return QDialog::height(); }

	void exitDialog();
	void updateStateLine();
	void updateList();
	void selectItem(int index);

private Q_SLOTS:
	void runNodeSlot();
	void accept();

private:
	QLineEdit *myStateLine;
	ZLQListWidget *myListWidget;
	std::map<std::string,QIcon*> myIcons;
};

#endif /* __ZLQTSELECTIONDIALOG_H__ */
<file_sep>/7-Zip/CPP/7zip/Crypto/ZipCrypto.cpp
// Crypto/ZipCrypto.cpp

#include "StdAfx.h"

#include "../../../C/7zCrc.h"

#include "../Common/StreamUtils.h"

#include "RandGen.h"
#include "ZipCrypto.h"

namespace NCrypto {
namespace NZip {

void CCipher::UpdateKeys(Byte b)
{
  Keys[0] = CRC_UPDATE_BYTE(Keys[0], b);
  Keys[1] += Keys[0] & 0xff;
  Keys[1] = Keys[1] * 134775813L + 1;
  Keys[2] = CRC_UPDATE_BYTE(Keys[2], (Byte)(Keys[1] >> 24));
}

void CCipher::SetPassword(const Byte *password, UInt32 passwordLen)
{
  Keys[0] = 305419896L;
  Keys[1] = 591751049L;
  Keys[2] = 878082192L;
  for (UInt32 i = 0; i < passwordLen; i++)
    UpdateKeys(password[i]);
}

Byte CCipher::DecryptByteSpec()
{
  UInt32 temp = Keys[2] | 2;
  return (Byte)((temp * (temp ^ 1)) >> 8);
}

Byte CCipher::DecryptByte(Byte b)
{
  Byte c = (Byte)(b ^ DecryptByteSpec());
  UpdateKeys(c);
  return c;
}

Byte CCipher::EncryptByte(Byte b)
{
  Byte c = (Byte)(b ^ DecryptByteSpec());
  UpdateKeys(b);
  return c;
}

void CCipher::DecryptHeader(Byte *buf)
{
  for (unsigned i = 0; i < kHeaderSize; i++)
    buf[i] = DecryptByte(buf[i]);
}

void CCipher::EncryptHeader(Byte *buf)
{
  for (unsigned i = 0; i < kHeaderSize; i++)
    buf[i] = EncryptByte(buf[i]);
}

STDMETHODIMP CEncoder::CryptoSetPassword(const Byte *data, UInt32 size)
{
  _cipher.SetPassword(data, size);
  return S_OK;
}

STDMETHODIMP CEncoder::CryptoSetCRC(UInt32 crc)
{
  _crc = crc;
  return S_OK;
}

STDMETHODIMP CEncoder::Init()
{
  return S_OK;
}

HRESULT CEncoder::WriteHeader(ISequentialOutStream *outStream)
{
  Byte header[kHeaderSize];
  g_RandomGenerator.Generate(header, kHeaderSize - 2);

  header[kHeaderSize - 1] = Byte(_crc >> 24);
  header[kHeaderSize - 2] = Byte(_crc >> 16);

  _cipher.EncryptHeader(header);
  return WriteStream(outStream, header, kHeaderSize);
}

STDMETHODIMP_(UInt32) CEncoder::Filter(Byte *data, UInt32 size)
{
  UInt32 i;
  for (i = 0; i < size; i++)
    data[i] = _cipher.EncryptByte(data[i]);
  return i;
}

STDMETHODIMP CDecoder::CryptoSetPassword(const Byte *data, UInt32 size)
{
  _cipher.SetPassword(data, size);
  return S_OK;
}

HRESULT CDecoder::ReadHeader(ISequentialInStream *inStream)
{
  Byte header[kHeaderSize];
  RINOK(ReadStream_FAIL(inStream, header, kHeaderSize));
  _cipher.DecryptHeader(header);
  return S_OK;
}

STDMETHODIMP CDecoder::Init()
{
  return S_OK;
}

STDMETHODIMP_(UInt32) CDecoder::Filter(Byte *data, UInt32 size)
{
  UInt32 i;
  for (i = 0; i < size; i++)
    data[i] = _cipher.DecryptByte(data[i]);
  return i;
}

}}
<file_sep>/7-Zip/CPP/7zip/UI/FileManager/PluginInterface.h
// PluginInterface.h

#ifndef __PLUGININTERFACE_H
#define __PLUGININTERFACE_H

#include "Common/MyString.h"

// {23170F69-40C1-278D-0000-000100010000}
DEFINE_GUID(IID_IInitContextMenu,
0x23170F69, 0x40C1, 0x278D, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00);
MIDL_INTERFACE("23170F69-40C1-278D-0000-000100010000")
IInitContextMenu: public IUnknown
{
public:
  STDMETHOD(InitContextMenu)(const wchar_t *aFolder, const wchar_t **aNames, UINT32 aNumFiles) PURE;

};

// {23170F69-40C1-278D-0000-000100020100}
DEFINE_GUID(IID_IPluginOptionsCallback,
0x23170F69, 0x40C1, 0x278D, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00);
MIDL_INTERFACE("23170F69-40C1-278D-0000-000100020000")
IPluginOptionsCallback: public IUnknown
{
public:
  STDMETHOD(GetProgramFolderPath)(BSTR *value) PURE;
  STDMETHOD(GetProgramPath)(BSTR *value) PURE;
  STDMETHOD(GetRegistryCUPath)(BSTR *value) PURE;
};

// {23170F69-40C1-278D-0000-000100020000}
DEFINE_GUID(IID_IPluginOptions,
0x23170F69, 0x40C1, 0x278D, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00);
MIDL_INTERFACE("23170F69-40C1-278D-0000-000100020000")
IPluginOptions: public IUnknown
{
public:
  STDMETHOD(PluginOptions)(HWND hWnd, IPluginOptionsCallback *callback) PURE;
  // STDMETHOD(GetFileExtensions)(BSTR *extensions) PURE;
};

#endif
<file_sep>/SQLCEHelper/Source/AddOffset.cpp
#include "stdafx.h"
#include "AddOffset.h"


ULONG AddOffset(ULONG nCurrent, ULONG nAdd)
{
	struct foobar
	{
		char    foo;
		long    bar;
	};
	ULONG	nAlign = offsetof(foobar, bar),
			nRet,
			nMod;

	nRet = nCurrent + nAdd;
	nMod = nRet % nAlign;

	if(nMod)
		nRet += nAlign - nMod;

	return nRet;
}
<file_sep>/FingerSuite/FingerSuiteCPL/Commons.h
#pragma once

#define UWM_UPDATECONFIGURATION_MSG  _T("UWM_UPDATECONFIGURATION-44E531B1_14D3_11d5_A025_006067718D04")
<file_sep>/7-Zip/CPP/7zip/Archive/Rar/RarIn.cpp
// Archive/RarIn.cpp

#include "StdAfx.h"

#include "../../../../C/7zCrc.h"

#include "Common/StringConvert.h"
#include "Common/UTFConvert.h"

#include "../../Common/LimitedStreams.h"
#include "../../Common/StreamUtils.h"

#include "../Common/FindSignature.h"

#include "RarIn.h"

namespace NArchive {
namespace NRar {
 
void CInArchive::ThrowExceptionWithCode(
    CInArchiveException::CCauseType cause)
{
  throw CInArchiveException(cause);
}

HRESULT CInArchive::Open(IInStream *inStream, const UInt64 *searchHeaderSizeLimit)
{
  try
  {
    Close();
    HRESULT res = Open2(inStream, searchHeaderSizeLimit);
    if (res == S_OK)
      return res;
    Close();
    return res;
  }
  catch(...) { Close(); throw; }
}

void CInArchive::Close()
{
  m_Stream.Release();
}


static inline bool TestMarkerCandidate(const void *aTestBytes)
{
  for (UInt32 i = 0; i < NHeader::kMarkerSize; i++)
    if (((const Byte *)aTestBytes)[i] != NHeader::kMarker[i])
      return false;
  return true;
}

HRESULT CInArchive::FindAndReadMarker(IInStream *stream, const UInt64 *searchHeaderSizeLimit)
{
  RINOK(FindSignatureInStream(stream,
      NHeader::kMarker, NHeader::kMarkerSize,
      searchHeaderSizeLimit, m_ArchiveStartPosition));
  m_Stream = stream;
  m_Position = m_ArchiveStartPosition + NHeader::kMarkerSize;
  return m_Stream->Seek(m_Position, STREAM_SEEK_SET, NULL);
}

void CInArchive::ThrowUnexpectedEndOfArchiveException()
{
  ThrowExceptionWithCode(CInArchiveException::kUnexpectedEndOfArchive);
}

bool CInArchive::ReadBytesAndTestSize(void *data, UInt32 size)
{
  if (m_CryptoMode)
  {
    const Byte *bufData = m_DecryptedDataAligned;
    UInt32 bufSize = m_DecryptedDataSize;
    UInt32 i;
    for (i = 0; i < size && m_CryptoPos < bufSize; i++)
      ((Byte *)data)[i] = bufData[m_CryptoPos++];
    return (i == size);
  }
  return (ReadStream_FALSE(m_Stream, data, size) == S_OK);
}

void CInArchive::ReadBytesAndTestResult(void *data, UInt32 size)
{
  if(!ReadBytesAndTestSize(data,size))
    ThrowUnexpectedEndOfArchiveException();
}

HRESULT CInArchive::ReadBytes(void *data, UInt32 size, UInt32 *processedSize)
{
  size_t realProcessedSize = size;
  HRESULT result = ReadStream(m_Stream, data, &realProcessedSize);
  if (processedSize != NULL)
    *processedSize = (UInt32)realProcessedSize;
  AddToSeekValue(realProcessedSize);
  return result;
}

static UInt32 CrcUpdateUInt16(UInt32 crc, UInt16 v)
{
  crc = CRC_UPDATE_BYTE(crc, (Byte)(v & 0xFF));
  crc = CRC_UPDATE_BYTE(crc, (Byte)((v >> 8) & 0xFF));
  return crc;
}

static UInt32 CrcUpdateUInt32(UInt32 crc, UInt32 v)
{
  crc = CRC_UPDATE_BYTE(crc, (Byte)(v & 0xFF));
  crc = CRC_UPDATE_BYTE(crc, (Byte)((v >> 8) & 0xFF));
  crc = CRC_UPDATE_BYTE(crc, (Byte)((v >> 16) & 0xFF));
  crc = CRC_UPDATE_BYTE(crc, (Byte)((v >> 24) & 0xFF));
  return crc;
}


HRESULT CInArchive::Open2(IInStream *stream, const UInt64 *searchHeaderSizeLimit)
{
  m_CryptoMode = false;
  RINOK(stream->Seek(0, STREAM_SEEK_SET, &m_StreamStartPosition));
  m_Position = m_StreamStartPosition;

  RINOK(FindAndReadMarker(stream, searchHeaderSizeLimit));

  Byte buf[NHeader::NArchive::kArchiveHeaderSize];
  UInt32 processedSize;
  ReadBytes(buf, sizeof(buf), &processedSize);
  if (processedSize != sizeof(buf))
    return S_FALSE;
  m_CurData = buf;
  m_CurPos = 0;
  m_PosLimit = sizeof(buf);

  m_ArchiveHeader.CRC = ReadUInt16();
  m_ArchiveHeader.Type = ReadByte();
  m_ArchiveHeader.Flags = ReadUInt16();
  m_ArchiveHeader.Size = ReadUInt16();
  m_ArchiveHeader.Reserved1 = ReadUInt16();
  m_ArchiveHeader.Reserved2 = ReadUInt32();
  m_ArchiveHeader.EncryptVersion = 0;

  UInt32 crc = CRC_INIT_VAL;
  crc = CRC_UPDATE_BYTE(crc, m_ArchiveHeader.Type);
  crc = CrcUpdateUInt16(crc, m_ArchiveHeader.Flags);
  crc = CrcUpdateUInt16(crc, m_ArchiveHeader.Size);
  crc = CrcUpdateUInt16(crc, m_ArchiveHeader.Reserved1);
  crc = CrcUpdateUInt32(crc, m_ArchiveHeader.Reserved2);

  if (m_ArchiveHeader.IsThereEncryptVer() && m_ArchiveHeader.Size > NHeader::NArchive::kArchiveHeaderSize)
  {
    ReadBytes(&m_ArchiveHeader.EncryptVersion, 1, &processedSize);
    if (processedSize != 1)
      return S_FALSE;
    crc = CRC_UPDATE_BYTE(crc, m_ArchiveHeader.EncryptVersion);
  }

  if(m_ArchiveHeader.CRC != (CRC_GET_DIGEST(crc) & 0xFFFF))
    ThrowExceptionWithCode(CInArchiveException::kArchiveHeaderCRCError);
  if (m_ArchiveHeader.Type != NHeader::NBlockType::kArchiveHeader)
    return S_FALSE;
  m_ArchiveCommentPosition = m_Position;
  m_SeekOnArchiveComment = true;
  return S_OK;
}

void CInArchive::SkipArchiveComment()
{
  if (!m_SeekOnArchiveComment)
    return;
  AddToSeekValue(m_ArchiveHeader.Size - m_ArchiveHeader.GetBaseSize());
  m_SeekOnArchiveComment = false;
}

void CInArchive::GetArchiveInfo(CInArchiveInfo &archiveInfo) const
{
  archiveInfo.StartPosition = m_ArchiveStartPosition;
  archiveInfo.Flags = m_ArchiveHeader.Flags;
  archiveInfo.CommentPosition = m_ArchiveCommentPosition;
  archiveInfo.CommentSize = (UInt16)(m_ArchiveHeader.Size - NHeader::NArchive::kArchiveHeaderSize);
}

static void DecodeUnicodeFileName(const char *name, const Byte *encName,
    int encSize, wchar_t *unicodeName, int maxDecSize)
{
  int encPos = 0;
  int decPos = 0;
  int flagBits = 0;
  Byte flags = 0;
  Byte highByte = encName[encPos++];
  while (encPos < encSize && decPos < maxDecSize)
  {
    if (flagBits == 0)
    {
      flags = encName[encPos++];
      flagBits = 8;
    }
    switch(flags >> 6)
    {
      case 0:
        unicodeName[decPos++] = encName[encPos++];
        break;
      case 1:
        unicodeName[decPos++] = (wchar_t)(encName[encPos++] + (highByte << 8));
        break;
      case 2:
        unicodeName[decPos++] = (wchar_t)(encName[encPos] + (encName[encPos + 1] << 8));
        encPos += 2;
        break;
      case 3:
        {
          int length = encName[encPos++];
          if (length & 0x80)
          {
            Byte correction = encName[encPos++];
            for (length = (length & 0x7f) + 2;
                length > 0 && decPos < maxDecSize; length--, decPos++)
              unicodeName[decPos] = (wchar_t)(((name[decPos] + correction) & 0xff) + (highByte << 8));
          }
          else
            for (length += 2; length > 0 && decPos < maxDecSize; length--, decPos++)
              unicodeName[decPos] = name[decPos];
        }
        break;
    }
    flags <<= 2;
    flagBits -= 2;
  }
  unicodeName[decPos < maxDecSize ? decPos : maxDecSize - 1] = 0;
}

void CInArchive::ReadName(CItemEx &item, int nameSize)
{
  item.UnicodeName.Empty();
  if (nameSize > 0)
  {
    m_NameBuffer.EnsureCapacity(nameSize + 1);
    char *buffer = (char *)m_NameBuffer;

    for (int i = 0; i < nameSize; i++)
      buffer[i] = ReadByte();

    int mainLen;
    for (mainLen = 0; mainLen < nameSize; mainLen++)
      if (buffer[mainLen] == '\0')
        break;
    buffer[mainLen] = '\0';
    item.Name = buffer;

    if(item.HasUnicodeName())
    {
      if(mainLen < nameSize)
      {
        int unicodeNameSizeMax = MyMin(nameSize, (0x400));
        _unicodeNameBuffer.EnsureCapacity(unicodeNameSizeMax + 1);
        DecodeUnicodeFileName(buffer, (const Byte *)buffer + mainLen + 1,
            nameSize - (mainLen + 1), _unicodeNameBuffer, unicodeNameSizeMax);
        item.UnicodeName = _unicodeNameBuffer;
      }
      else if (!ConvertUTF8ToUnicode(item.Name, item.UnicodeName))
        item.UnicodeName.Empty();
    }
  }
  else
    item.Name.Empty();
}

Byte CInArchive::ReadByte()
{
  if (m_CurPos >= m_PosLimit)
    throw CInArchiveException(CInArchiveException::kIncorrectArchive);
  return m_CurData[m_CurPos++];
}

UInt16 CInArchive::ReadUInt16()
{
  UInt16 value = 0;
  for (int i = 0; i < 2; i++)
  {
    Byte b = ReadByte();
    value |= (UInt16(b) << (8 * i));
  }
  return value;
}

UInt32 CInArchive::ReadUInt32()
{
  UInt32 value = 0;
  for (int i = 0; i < 4; i++)
  {
    Byte b = ReadByte();
    value |= (UInt32(b) << (8 * i));
  }
  return value;
}

void CInArchive::ReadTime(Byte mask, CRarTime &rarTime)
{
  rarTime.LowSecond = (Byte)(((mask & 4) != 0) ? 1 : 0);
  int numDigits = (mask & 3);
  rarTime.SubTime[0] = rarTime.SubTime[1] = rarTime.SubTime[2] = 0;
  for (int i = 0; i < numDigits; i++)
    rarTime.SubTime[3 - numDigits + i] = ReadByte();
}

void CInArchive::ReadHeaderReal(CItemEx &item)
{
  item.Flags = m_BlockHeader.Flags;
  item.PackSize = ReadUInt32();
  item.Size = ReadUInt32();
  item.HostOS = ReadByte();
  item.FileCRC = ReadUInt32();
  item.MTime.DosTime = ReadUInt32();
  item.UnPackVersion = ReadByte();
  item.Method = ReadByte();
  int nameSize = ReadUInt16();
  item.Attrib = ReadUInt32();

  item.MTime.LowSecond = 0;
  item.MTime.SubTime[0] =
      item.MTime.SubTime[1] =
      item.MTime.SubTime[2] = 0;

  if((item.Flags & NHeader::NFile::kSize64Bits) != 0)
  {
    item.PackSize |= ((UInt64)ReadUInt32() << 32);
    item.Size |= ((UInt64)ReadUInt32() << 32);
  }

  ReadName(item, nameSize);

  if (item.HasSalt())
    for (int i = 0; i < sizeof(item.Salt); i++)
      item.Salt[i] = ReadByte();

  // some rar archives have HasExtTime flag without field.
  if (m_CurPos < m_PosLimit && item.HasExtTime())
  {
    Byte accessMask = (Byte)(ReadByte() >> 4);
    Byte b = ReadByte();
    Byte modifMask = (Byte)(b >> 4);
    Byte createMask = (Byte)(b & 0xF);
    if ((modifMask & 8) != 0)
      ReadTime(modifMask, item.MTime);
    item.CTimeDefined = ((createMask & 8) != 0);
    if (item.CTimeDefined)
    {
      item.CTime.DosTime = ReadUInt32();
      ReadTime(createMask, item.CTime);
    }
    item.ATimeDefined = ((accessMask & 8) != 0);
    if (item.ATimeDefined)
    {
      item.ATime.DosTime = ReadUInt32();
      ReadTime(accessMask, item.ATime);
    }
  }

  UInt16 fileHeaderWithNameSize = (UInt16)m_CurPos;
  
  item.Position = m_Position;
  item.MainPartSize = fileHeaderWithNameSize;
  item.CommentSize = (UInt16)(m_BlockHeader.HeadSize - fileHeaderWithNameSize);

  if (m_CryptoMode)
    item.AlignSize = (UInt16)((16 - ((m_BlockHeader.HeadSize) & 0xF)) & 0xF);
  else
    item.AlignSize = 0;
  AddToSeekValue(m_BlockHeader.HeadSize);
}

void CInArchive::AddToSeekValue(UInt64 addValue)
{
  m_Position += addValue;
}

HRESULT CInArchive::GetNextItem(CItemEx &item, ICryptoGetTextPassword *getTextPassword, bool &decryptionError)
{
  decryptionError = false;
  if (m_SeekOnArchiveComment)
    SkipArchiveComment();
  for (;;)
  {
    if(!SeekInArchive(m_Position))
      return S_FALSE;
    if (!m_CryptoMode && (m_ArchiveHeader.Flags &
        NHeader::NArchive::kBlockHeadersAreEncrypted) != 0)
    {
      m_CryptoMode = false;
      if (getTextPassword == 0)
        return S_FALSE;
      if(!SeekInArchive(m_Position))
        return S_FALSE;
      if (!m_RarAES)
      {
        m_RarAESSpec = new NCrypto::NRar29::CDecoder;
        m_RarAES = m_RarAESSpec;
      }
      m_RarAESSpec->SetRar350Mode(m_ArchiveHeader.IsEncryptOld());

      // Salt
      const UInt32 kSaltSize = 8;
      Byte salt[kSaltSize];
      if(!ReadBytesAndTestSize(salt, kSaltSize))
        return S_FALSE;
      m_Position += kSaltSize;
      RINOK(m_RarAESSpec->SetDecoderProperties2(salt, kSaltSize))
      // Password
      <PASSWORD>STR password;
      RINOK(getTextPassword->CryptoGetTextPassword(&password))
      UString unicodePassword(<PASSWORD>);

      CByteBuffer buffer;
      const UInt32 sizeInBytes = unicodePassword.Length() * 2;
      buffer.SetCapacity(sizeInBytes);
      for (int i = 0; i < unicodePassword.Length(); i++)
      {
        wchar_t c = unicodePassword[i];
        ((Byte *)buffer)[i * 2] = (Byte)c;
        ((Byte *)buffer)[i * 2 + 1] = (Byte)(c >> 8);
      }

      RINOK(m_RarAESSpec->CryptoSetPassword((const Byte *)buffer, sizeInBytes));

      const UInt32 kDecryptedBufferSize = (1 << 12);
      if (m_DecryptedData.GetCapacity() == 0)
      {
        const UInt32 kAlign = 16;
        m_DecryptedData.SetCapacity(kDecryptedBufferSize + kAlign);
        m_DecryptedDataAligned = (Byte *)((ptrdiff_t)((Byte *)m_DecryptedData + kAlign - 1) & ~(ptrdiff_t)(kAlign - 1));
      }
      RINOK(m_RarAES->Init());
      size_t decryptedDataSizeT = kDecryptedBufferSize;
      RINOK(ReadStream(m_Stream, m_DecryptedDataAligned, &decryptedDataSizeT));
      m_DecryptedDataSize = (UInt32)decryptedDataSizeT;
      m_DecryptedDataSize = m_RarAES->Filter(m_DecryptedDataAligned, m_DecryptedDataSize);

      m_CryptoMode = true;
      m_CryptoPos = 0;
    }

    m_FileHeaderData.EnsureCapacity(7);
    if(!ReadBytesAndTestSize((Byte *)m_FileHeaderData, 7))
      return S_FALSE;

    m_CurData = (Byte *)m_FileHeaderData;
    m_CurPos = 0;
    m_PosLimit = 7;
    m_BlockHeader.CRC = ReadUInt16();
    m_BlockHeader.Type = ReadByte();
    m_BlockHeader.Flags = ReadUInt16();
    m_BlockHeader.HeadSize = ReadUInt16();

    if (m_BlockHeader.HeadSize < 7)
      ThrowExceptionWithCode(CInArchiveException::kIncorrectArchive);

    if (m_BlockHeader.Type == NHeader::NBlockType::kEndOfArchive)
      return S_FALSE;

    if (m_BlockHeader.Type == NHeader::NBlockType::kFileHeader)
    {
      m_FileHeaderData.EnsureCapacity(m_BlockHeader.HeadSize);
      m_CurData = (Byte *)m_FileHeaderData;
      m_PosLimit = m_BlockHeader.HeadSize;
      ReadBytesAndTestResult(m_CurData + m_CurPos, m_BlockHeader.HeadSize - 7);
      ReadHeaderReal(item);
      if ((CrcCalc(m_CurData + 2,
          m_BlockHeader.HeadSize - item.CommentSize - 2) & 0xFFFF) != m_BlockHeader.CRC)
        ThrowExceptionWithCode(CInArchiveException::kFileHeaderCRCError);

      FinishCryptoBlock();
      m_CryptoMode = false;
      SeekInArchive(m_Position); // Move Position to compressed Data;
      AddToSeekValue(item.PackSize);  // m_Position points to next header;
      return S_OK;
    }
    if (m_CryptoMode && m_BlockHeader.HeadSize > (1 << 10))
    {
      decryptionError = true;
      return S_FALSE;
    }
    if ((m_BlockHeader.Flags & NHeader::NBlock::kLongBlock) != 0)
    {
      m_FileHeaderData.EnsureCapacity(7 + 4);
      m_CurData = (Byte *)m_FileHeaderData;
      ReadBytesAndTestResult(m_CurData + m_CurPos, 4); // test it
      m_PosLimit = 7 + 4;
      UInt32 dataSize = ReadUInt32();
      AddToSeekValue(dataSize);
      if (m_CryptoMode && dataSize > (1 << 27))
      {
        decryptionError = true;
        return S_FALSE;
      }
      m_CryptoPos = m_BlockHeader.HeadSize;
    }
    else
      m_CryptoPos = 0;
    AddToSeekValue(m_BlockHeader.HeadSize);
    FinishCryptoBlock();
    m_CryptoMode = false;
  }
}

bool CInArchive::SeekInArchive(UInt64 position)
{
  UInt64 newPosition;
  m_Stream->Seek(position, STREAM_SEEK_SET, &newPosition);
  return newPosition == position;
}

ISequentialInStream* CInArchive::CreateLimitedStream(UInt64 position, UInt64 size)
{
  CLimitedSequentialInStream *streamSpec = new CLimitedSequentialInStream;
  CMyComPtr<ISequentialInStream> inStream(streamSpec);
  SeekInArchive(position);
  streamSpec->SetStream(m_Stream);
  streamSpec->Init(size);
  return inStream.Detach();
}

}}
<file_sep>/FBReaderJ/jni/Android.mk
LOCAL_PATH := $(call my-dir)
#############################################
# 调试信息： TRUE=打印日志
DEBUG := true
LDDEBUG :=
DEBUG_FLAG :=

$(info ============================================)
DMODE := $(shell echo $(DEBUG) | tr a-z A-Z)
ifeq ($(DMODE),TRUE)
  $(eval LDDEBUG := -llog)
  $(eval DEBUG_FLAG := -DDEBUG_LOG)
  $(info LOG_MODE = debug)
else
  $(info LOG_MODE = release)
endif
$(info ============================================)
COMMON_CFLAGS := -fsigned-char $(DEBUG_FLAG) 
#############################################
# 
include $(CLEAR_VARS)

LOCAL_MODULE                  := DeflatingDecompressor
LOCAL_SRC_FILES               := DeflatingDecompressor/DeflatingDecompressor.cpp
LOCAL_LDLIBS                  := -lz


LOCAL_CFLAGS += $(COMMON_CFLAGS)
LOCAL_LDLIBS += $(LDDEBUG)

include $(BUILD_SHARED_LIBRARY)

#############################################
# 
include $(CLEAR_VARS)

LOCAL_MODULE                  := LineBreak
LOCAL_SRC_FILES               := LineBreak/LineBreaker.cpp LineBreak/liblinebreak-2.0/linebreak.c LineBreak/liblinebreak-2.0/linebreakdata.c LineBreak/liblinebreak-2.0/linebreakdef.c


LOCAL_CFLAGS += $(COMMON_CFLAGS)
LOCAL_LDLIBS += $(LDDEBUG)

include $(BUILD_SHARED_LIBRARY)

#############################################
# 
include $(CLEAR_VARS)

LOCAL_MODULE                  := TxtParser
LOCAL_SRC_FILES               := TxtParser/TxtParser.cpp


LOCAL_CFLAGS += $(COMMON_CFLAGS)
LOCAL_LDLIBS += $(LDDEBUG)

include $(BUILD_SHARED_LIBRARY)
<file_sep>/FingerSuite/Common/fngrscrl.h
#ifndef __FNGRSCRL_H__
#define __FNGRSCRL_H__

#pragma once

#ifndef __cplusplus
	#error ATL requires C++ compilation (use a .cpp suffix)
#endif

#ifndef __ATLAPP_H__
	#error fngrscrl.h requires atlapp.h to be included first
#endif

#ifndef __ATLWIN_H__
	#error fngrscrl.h requires atlwin.h to be included first
#endif

#ifndef __FNGRBUFDC_H__
	#error fngrscrl.h requires fngrbufdc.h to be included first
#endif

#define IDT_TIMER_ANIMATION    10001
#define TMR_INTERVAL 10

#define IDT_TIMER_AUTOSCROLL   10002
#define TMR_INTERVAL 10


#define UM_SCRL_NOTIFY     WM_USER + 100001

///////////////////////////////////////////////////////////////////////////////
// Classes in this file:
//
// CFingerScrollImpl<T>

template <class T, bool t_bBuffered = false, bool t_bNotifyParentWnd = false>
class CFingerScrollImpl
{
public:

	CFingerScrollImpl()
	{
		Reset();
	}

	~CFingerScrollImpl()
	{
		T* pT = static_cast<T*>(this);
		if (::IsWindow(pT->m_hWnd))
			pT->KillTimer(IDT_TIMER_ANIMATION);
	}
	
// Overrideables
	void DoPaint(CDCHandle /*dc*/)
	{
		// must be implemented in a derived class
		ATLASSERT(FALSE);
	}

	void DoScroll(int /*yOffset*/)
	{
		// can be override
	}	

	void ScrollTo(int offset)
	{
		m_offsetScrollTo = offset;

		if (m_offsetScrollTo < 0)
			m_offsetScrollTo = 0;
		if (m_offsetScrollTo > m_scrollableAreaHeight)
			m_offsetScrollTo = m_scrollableAreaHeight;

		T* pT = static_cast<T*>(this);
		ATLASSERT(::IsWindow(pT->m_hWnd));

		//m_velocity = 1;
		pT->SetTimer(IDT_TIMER_AUTOSCROLL, TMR_INTERVAL);
	}

	void SetFingerScrollRegion(int scrollableAreaHeight, int clientAreaHeight)
	{
		Reset();

		m_scrollableAreaHeight = max(scrollableAreaHeight - clientAreaHeight, 0);
		m_clientAreaHeight = clientAreaHeight;		
	}

	int GetScrollableAreaHeight()
	{
		return m_scrollableAreaHeight;
	}

	void SetMaxVelocity(int value)
	{
		m_maxVelocity = value;
	}

	int GetOffset()
	{
		return m_offset;
	}

	void SetThreshold(int value)
	{
		m_threshold = value;
	}

	int GetThreshold()
	{
		return m_threshold;
	}

	BOOL IsScrolling()
	{
		return ((m_velocity > 0) || m_bMouseIsDown);
	}


	BEGIN_MSG_MAP(CFingerScrollImpl)
		MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown)
		MESSAGE_HANDLER(WM_MOUSEMOVE, OnMouseMove)
		MESSAGE_HANDLER(WM_LBUTTONUP, OnLButtonUp)
		MESSAGE_HANDLER(WM_TIMER, OnTimer)
		MESSAGE_HANDLER(WM_PAINT, OnPaint)
		MESSAGE_HANDLER(WM_CAPTURECHANGED, OnCaptureChanged)
	END_MSG_MAP()

	LRESULT OnLButtonDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
	{
		T* pT = static_cast<T*>(this);
		ATLASSERT(::IsWindow(pT->m_hWnd));

        m_bMouseIsDown = TRUE;
		m_tMouseDown = ::GetTickCount();

		pT->KillTimer(IDT_TIMER_ANIMATION);
		pT->KillTimer(IDT_TIMER_AUTOSCROLL);
		
        m_mouseDown.x = LOWORD(lParam);
        m_mouseDown.y = HIWORD(lParam);
        m_mousePrev = m_mouseDown;


		return 0;
	}

	LRESULT OnMouseMove(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
	{
		T* pT = static_cast<T*>(this);
		ATLASSERT(::IsWindow(pT->m_hWnd));

		int distanceY = m_mousePrev.y - HIWORD(lParam);

		if (abs(distanceY) > m_threshold)
		{
			ModifyOffset(distanceY, FALSE);
		    
			ClipScrollPosition();

			m_mousePrev.x = LOWORD(lParam);
			m_mousePrev.y = HIWORD(lParam);

			UpdateLayout();
		}

		return 0;
	}

	LRESULT OnLButtonUp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
	{
		T* pT = static_cast<T*>(this);
		ATLASSERT(::IsWindow(pT->m_hWnd));

		int y = HIWORD(lParam);

		// Did the click end on the same item it started on?
		BOOL sameY = (y == m_mouseDown.y);

		if (!(sameY) && (::GetTickCount() - m_tMouseDown < 500) ) 
		{
			m_velocity = m_mouseDown.y - y;
			pT->SetTimer(IDT_TIMER_ANIMATION, TMR_INTERVAL);
		}

		m_mouseDown.y = -1;
		m_bMouseIsDown = FALSE;

		UpdateLayout();

		return 0;
	}


	LRESULT OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
	{
		T* pT = static_cast<T*>(this);
		ATLASSERT(::IsWindow(pT->m_hWnd));

		if (wParam == IDT_TIMER_ANIMATION)
		{
            if (m_velocity == 0)
            {
				pT->KillTimer(IDT_TIMER_ANIMATION);
            }

			if (!m_bMouseIsDown && (m_velocity != 0))
            {
				m_velocity = min(m_velocity, m_maxVelocity);
				m_velocity = max(m_velocity, -m_maxVelocity);

				ModifyOffset(m_velocity, FALSE);

                ClipScrollPosition();

                // Slow down
                if (((++m_timerCount) % 10) == 0)
                {
                    if (m_velocity < 0)
                    {
                        //m_velocity ++;
						m_velocity = m_velocity / 2;
                    }
                    else if (m_velocity > 0)
                    {
                        //m_velocity --;
						m_velocity = m_velocity / 2;

                    }
                }
				UpdateLayout();
            }

			//wprintf(L"m_velocity = %d\n", m_velocity);
		}

		if (wParam == IDT_TIMER_AUTOSCROLL)
		{
			int velocity = m_offsetScrollTo - m_offset;

			velocity = min(velocity, m_maxVelocity);
			velocity = max(velocity, -m_maxVelocity);

			ModifyOffset(velocity, FALSE);
			    
			if (m_offset < 0)
			{
				velocity = 0;
				ModifyOffset(0, TRUE);
			}
	        else if (m_offset > m_scrollableAreaHeight)
			{
				velocity = 0;
				ModifyOffset(m_scrollableAreaHeight, TRUE);
			}
        
			if (velocity != 0)
				UpdateLayout();
			else
				pT->KillTimer(IDT_TIMER_AUTOSCROLL);
		}
		return 0;
	}


	LRESULT OnPaint(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		T* pT = static_cast<T*>(this);
		ATLASSERT(::IsWindow(pT->m_hWnd));
		if(wParam != NULL)
		{
			CDCHandle dc = (HDC)wParam;
			POINT ptViewportOrg = { 0, 0 };
			dc.SetViewportOrg(0, -m_offset, &ptViewportOrg);
			pT->DoPaint(dc);
			dc.SetViewportOrg(ptViewportOrg);
		}
		else
		{
			if (t_bBuffered)
			{
				CBufferedPaintDC dc(pT->m_hWnd, -m_offset);
				dc.SetViewportOrg(0, -m_offset);
				pT->DoPaint(dc.m_hDC);
			}
			else
			{
				CPaintDC dc(pT->m_hWnd);
				dc.SetViewportOrg(0, -m_offset);
				pT->DoPaint(dc.m_hDC);
			}
		}
		return 0;
	}

	LRESULT OnCaptureChanged(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		m_bMouseIsDown = FALSE;
		return 0;
	}

private:

	void Reset()
	{
		//m_maxVelocity = 15;
		m_velocity = 0;
		ModifyOffset(0, TRUE);
		m_timerCount = 0;
        m_mouseDown.x = -1; m_mouseDown.y = -1;
        m_mousePrev.x = -1; m_mousePrev.y = -1;
		m_t1 = ::GetTickCount();
		//m_bMiddlePosNotified = FALSE;
	}

	/*
    void ClipVelocity()
    {
        m_velocity = min(m_velocity, m_maxVelocity);
        m_velocity = max(m_velocity, -m_maxVelocity);
    }
	*/

    void ClipScrollPosition()
    {
        if (m_offset < 0)
        {
            ModifyOffset(0, TRUE);
            m_velocity = 0;
        }
        else if (m_offset > m_scrollableAreaHeight)
        {
            ModifyOffset(m_scrollableAreaHeight, TRUE);
			m_velocity = 0;
        }
    }

	void UpdateLayout()
	{
		T* pT = static_cast<T*>(this);
		ATLASSERT(::IsWindow(pT->m_hWnd));

		pT->InvalidateRect(NULL, TRUE);

		DWORD t2 = ::GetTickCount();
		if (t2 - m_t1 > 50) // ms elapsed
		{
			m_t1 = ::GetTickCount();
			pT->UpdateWindow();
		}

	}

	void ModifyOffset(int value, BOOL bAbsolute)
	{
		T* pT = static_cast<T*>(this);

		if (bAbsolute)
			m_offset = value;
		else
		{
			m_offset += value;
			//pT->DoScroll(value); TODO
		}

		if ((t_bNotifyParentWnd) && (::IsWindow(pT->m_hWnd)))
			::SendMessage(pT->GetParent(), UM_SCRL_NOTIFY, (WPARAM)m_offset, 0); 
	}

protected:
	// nuovi
    POINT m_mouseDown;
    POINT m_mousePrev;
	int m_scrollableAreaHeight;
	int m_clientAreaHeight;
	BOOL m_bMouseIsDown;
	
	//BOOL m_bMiddlePosNotified;
	int m_maxVelocity;
	int m_velocity;
	int m_offset;
	int m_timerCount;
	DWORD m_t1;
	int m_offsetScrollTo;
	DWORD m_tMouseDown;
	int m_threshold;
	//HWND m_hWndNotify;
};




/*
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
template <class T>
class CFingerScrollItemImpl
{
public:

	CFingerScrollItemImpl()
	{
		m_top = 0;
	}

	~CFingerScrollItemImpl() {}

	BEGIN_MSG_MAP(CFingerScrollItemImpl)
		MESSAGE_HANDLER(WM_WINDOWPOSCHANGED, OnWindowPosChanged)
		MESSAGE_HANDLER(WM_LBUTTONDOWN, OnForwardMessage)
		MESSAGE_HANDLER(WM_MOUSEMOVE, OnForwardMessage)
		MESSAGE_HANDLER(WM_LBUTTONUP, OnForwardMessage)
	END_MSG_MAP()

	LRESULT OnWindowPosChanged(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
	{
		LPWINDOWPOS lpwp = (LPWINDOWPOS) lParam;
		m_top = lpwp->y;
		return 0;
	}

	LRESULT OnForwardMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
	{
		T* pT = static_cast<T*>(this);
		ATLASSERT(::IsWindow(pT->m_hWnd));
		int y = m_top + HIWORD(lParam);
		pT->GetParent().SendMessage(uMsg, wParam, (LPARAM)MAKELONG(0, y)); // no matter on x position

		return 0;
	}
protected:
	int m_top;

};
*/
#endif // __FNGRSCRL_H__