
ãã倧ããªã倧ããªåœã§ã¯ãå°ãããŠãããã人ãäœãã§ããŸããã ãããŠããã®å€§ããªããŸãã¯ããªã倧ããªåœã®çãäžã«æ·±ãæ·±ãç©ŽãçŸãããŸã§ããã¹ãŠãããŸããããŸããã ããŠãç§ã¯èšããªããã°ãªããªãã圌女ã¯äžäººã§ã¯ãªãããããŠãã¡ãããããã«ã¯çŸããªãã£ããã誰ããããããèŠããŠããªãã ããããããã¯ãã¯ã誰ã«ãšã£ãŠãéèŠã§ã¯ãªãã
äž»ãªãã®ã¯ãããã§ãããããã¯å€§ãããéåžžã«å€§ããããããç¡éã§ãããããæ£ç¢ºã«ã¯èª°ãç¥ããªãã£ãã ãããã倧ããªåœã®æ¿åºã¯ããããã§äœããããªããã°ãªããªãããšãç¥ã£ãŠããŠãå匷ããŠç ãã«ã€ãããšã«æ±ºããŸããã ãã®çŸããç¶æ ã«ãã£ã人ãã¡ã®äžã§æãåšå§çã§åšçšã§åæ°ããããè³¢ããŠæãè³¢ã人ã¯äœãšåŒã°ããŠããŸãããã
ãããŠãæãäºèšçãªã»ããã 圌ãã¯å匷ããç ãã«èœã¡ãç ãã«èœã¡ãå匷ããå匷ããç ãã«èœã¡ãç ãã«èœã¡ãå匷ããŸããããããŠãããã¯äœåºŠãç¹°ãè¿ãããŸããã§ããã
ç§ãã¡ã®ã»ãšãã©ã®ã»ãšãã©ã®ããŒããŒãå»ã£ãããããã圌ãã¯å»ããªããã°ãªããªãã£ãã®ã§ãããããæ®ã£ãŠããŸããã ããããæ°ããããŒããŒã¯ãåããããå°ãããåãã§ããŸã£ããåãã§ãåãããšãå§ããŸããã
äžè¬ã«ãããã¯1ã€ãæ®ã£ãŠããéãç¶ããŸããã ãããŠãããæŽããæ¥ããããèªäœã¯å§¿ãæ¶ãããŸã£ããå¥ã®å Žæã®ã©ããã«çŸããŸãããããã§åœŒãã¯åã³å匷ããåãå§ããŸãã...
ãã¹ãŠã®å¶ç¶ã¯ã©ã³ãã ã§ããããã¹ãŠãæ¶ç©ºã®ãã®ã§ããããã®ãããªãã®ã¯ãã€ãŠãªãã£ããããçŸå®ã«ã¯ããããŸããã§ããïŒ çå®ãçå®ããŸãããŸãã¯ã»ãšãã©çå®ã
ãã®ãããªãããã®1ã€ã«ã€ããŠã¯ãåŸã§èª¬æããŸãã ããããä»¥æ¥ ãã©ã€ãã·ãŒããªã·ãŒã§ã¯ããã®äžéšã®ã¿ã察象ãšããŸããããã«ã¯ã ãªãŒãã³ãœãŒã¹ãšææžåããã APIã®ã¿ã䜿çšããŠã¢ã¯ã»ã¹ã§ããŸãã
ææã¯ã»ãšãã©æä»çã§ã ç©ç©ã®ãããã¯ã«é¢ããæ å ±ã
MS Exchange Serverããã¹ãŠã®ã¡ãŒã«ãä¿åããå ŽæãèããããšããããŸããããããšãæäžäœã¬ãã«ã§ã©ã®ããã«åäœããŸããïŒ ããã«ã€ããŠå°ã説æããŸãã®ã§ãããã«æžããŸãã
èŠåïŒãã®ãããã¯ã«æ·±ãå ¥ãããšããªãã§ãã ãããããªãã®äººçã¯ååã§ã¯ãããŸããã èŠåããã
ã¯ããã«
MS Exchange ServerïŒä»¥äžãåã«ExchangeïŒã¯ãMicrosoft補åã©ã€ã³ã®äž»èŠè£œåã®1ã€ã§ãã äž»ãªæ©èœã«ã€ããŠã¯ã wikiãŸãã¯å ¬åŒWebãµã€ãã§èªãããšãã§ããŸãã èŠããã«ãããã¯ã¡ãŒã«ãã«ã¬ã³ããŒããã®ä»ã®ãŠãŒã¶ãŒããŒã¿ãæäœããããã®äžçš®ã®ãããŒãã¹ã¿ãŒãã§ãããããŸããŸãªMS補åïŒSharePointãTFSãªã©ïŒãšååã«çµ±åãããŠããŸãã
ãã ãããã®èšäºã®ãã¬ãŒã ã¯ãŒã¯ã§ã¯ããšã³ããŠãŒã¶ãŒã«æäŸãããã®ã§ã¯ãªãããã®ããŒã¿ãã©ãããååŸããã©ã®APIã䜿çšãããã«é¢å¿ããããŸãã Exchange 2010ïŒ ã¡ãŒã«ããã¯ã¹ãµãŒã㌠ïŒã®ã¡ãŒã«ããã¯ã¹ã®åœ¹å²ã§ã¡ãŒã«ããã¯ã¹ããŒã¿ããŒã¹ãåå¥ã«èªã¿åãããšããŸãã
Exchangeã«ã¯ããŠãŒã¶ãŒãããŒã¿ã«ã¢ã¯ã»ã¹ã§ããããã€ãã®ãšã³ããªãã€ã³ãïŒ CASãµãŒã㌠ïŒãšãããã«äœ¿çšã§ããããã€ãã®ãããã³ã«ïŒOWAãRPCïŒOutlookïŒãPOP3 / IMAP4ãªã©ïŒããããŸãã
æ¹æ³ã«é¢ä¿ãªããExchangeãžã®ã¢ã¯ã»ã¹ãååŸãããšããã¹ãŠã®èŠæ±ãã¡ãŒã«ããã¯ã¹ã®åœ¹å² ïŒExchange 2007ããåã¯ãããå¯äžã®åœ¹å²ã§ããïŒã«è»¢éãããŸãã ç©ççã«ããããã®ããŒã¿ããŒã¹ã¯* .edbãã¡ã€ã«å ã®ããŒããã£ã¹ã¯ã«ãããŸãã ãããã¯ãExchangeãã€ã³ã¹ããŒã«ããããã£ã¬ã¯ããªã®Mailbox \ <ããŒã¿ããŒã¹å>ãã©ã«ããŒã«ãããŸãã ãŸããããŒã¿ããŒã¹ã®ã©ã€ããµã€ã¯ã«ã«é¢é£ãããã©ã³ã¶ã¯ã·ã§ã³ãã°ããã®ä»ã®ãã¡ã€ã«ãããã«é 眮ãããŸããããããã¯å¿ èŠãããŸãããæãåºæ¬çãªãã®ã¯* .edbã§ãã
å°ãæãäžãããšãExchangeã¯Extensible Storage EngineïŒESEïŒã䜿çšããŠããŒã¿ããŒã¹ã®ã³ã³ãã³ãã«ã¢ã¯ã»ã¹ããŠããããšãããããŸãã ãããŠãæãäžãããšãESEé¢æ°ã®å®è£ ãã©ã€ãã©ãªese.dllïŒãŸãã¯esent.dllïŒã«ããããšãæããã«ãªããŸãã ããã¯ã ãã¹ãŠã® Exchange æäœã®äžæ žã§ã ã ESEã¯ãããŒã¿ããŒã¹ãæäœããããã®åºç¯ãªããŒã«ã»ãããæäŸããŸãã é¢æ°ãå®æ°ãæ§é ãããã³å¿ èŠãªãã¹ãŠã®èª¬æã¯ã ããã«ãããŸã ã æ®å¿µãªããããã®ããã¥ã¡ã³ãã¯é·ãéæŽæ°ãããŠããªããããExchange 2010ã«ç»å Žããæ©èœã¯å€ããããŸãããããã®ãããã¯ã§ã¯å¿ èŠãããŸããã ese.dllã¯ãExchangeã¡ã€ã³ãã£ã¬ã¯ããªå ã®Binãã©ã«ããŒã«ãããŸãã
ESEã®èª¬æãèªãã åŸãããŒã¿ã衚圢åŒã§ä¿åãããŠããããšãæããã«ãªããŸãã åãšè¡ãæã€ããŒãã«ã®ã»ããã ããŒãã«ã»ã«ã¯ãããŸããŸãªçš®é¡ã®ã»ããããŒã¹ã®ãã¹ãŠã®æ©èœïŒã€ã³ããã¯ã¹ãæ€çŽ¢ãªã©ïŒã䜿çšã§ããŸãã
åèšã§ãExchangeã¯ããŒã¿ããŒã¹ã.edbæ¡åŒµåãæã€ãã¡ã€ã«ã®åœ¢åŒã§ã¡ãŒã«ããã¯ã¹ã®åœ¹å²ã«æ ŒçŽããESEïŒese.dllïŒã®ãããã§ãããã«ã¢ã¯ã»ã¹ããããšãç¥ã£ãŠããŸãã ããã§ååã§ãããã³ãŒãã£ã³ã°ãéå§ã§ããŸãã
ããŒã¿ããŒã¹å ã®ããŒãã«ãããã³ãã¹ãŠã®åãšåããªã¹ãããŸãã ãã¡ãããããããäœãæå³ããã®ã
ããã°ã©ãã³ã°
æºåãã
æåã«å¿ èŠãªãã®ïŒ
- Visual Studio 2008-2010
- MS Exchange Server 2010ïŒä»ã®ãããã§ãå¯èœã§ããããã®ãããã¯ã§ã¯2010ã«ã€ããŠèª¬æããŸãïŒ
- C / C ++ã®ç¥è
Binãã©ã«ããŒããese.dllãã³ããŒããŸããããã«ãããããŒã¿ããŒã¹ãæäœã§ããŸãã
Visual Studioã§ã¯ãã³ã³ãœãŒã«C ++ãããžã§ã¯ããäœæããŸãã ããã«éèŠãªãã¥ã¢ã³ã¹ããããŸã Exchange 2010ïŒä»¥åã®ãã¹ãŠã®ããŒãžã§ã³ãšã¯ç°ãªãïŒã¯64ãããããŒãžã§ã³ã®ã¿ã§ãããããx64ããµããŒããããããžã§ã¯ããäœæããå¿ èŠããããŸãã ããããªããšãåã«ã¢ãã¬ã¹ã¹ããŒã¹ã«ese.dllãããŒãã§ããŸããã ãããã£ãŠãã¢ããªã±ãŒã·ã§ã³ããã¹ãããã«ã¯ã64ãããããŒãžã§ã³ã®OSãå¿ èŠã§ãããExchangeèªäœã§ç¢ºå®ã«ãã¹ãã§ããŸããããã®ç®çã®ããã«Windows 7ã§ã¯ãŒã¯ã¹ããŒã·ã§ã³ã䜿çšããŸãããŸããUnicodeããŒãžã§ã³ã®APIã䜿çšããŸãã
ãããã£ãŠãæ°ããäœæããããããžã§ã¯ãã§ã¯ãx64ããã³UnicodeïŒäžè¬-Unicodeæåã»ããã䜿çšïŒããµããŒããããŠããããšã確èªããŸãã 次ã«ãESEã®ã¡ã€ã³ããããŒãã¡ã€ã«ãæ¥ç¶ããŸãã
#include <esent.h>ãã®ãã¡ã€ã«ã«ã¯ãVS 2008以éã®ã¹ã¿ãžãªãšå ±ã«SDKãä»å±ããŠããŸãã
stdafx.hã§ãJETããŒãžã§ã³ïŒESEïŒã§2ã€ã®å®çŸ©ãè¿œå ãããŠãã³ãŒãããŒãžã§ã³ã®APIã䜿çšããããšã瀺ããŸãã
#define JET_UNICODE
#define JET_VERSION 0x0600
ããŠãããŒã¿ããŒã¹ããäœãååŸããããã決å®ããå¿ èŠããããŸãã ESEã¯ãããŒãã«ãåãããã³è¡ãæã€ããŒã¿ããŒã¹ã§ãããããããæœåºããããšãããã®ããŸãã«ããŒãã«ãåãããã³è¡ã§ãã ãããè¡ãã«ã¯ã次ã®æ§é ãæºåããŸãã
typedef struct tagDBColumnsInfo
{
std :: wstring sColumnName ;
std :: vector < std :: wstring > sColumnValues ;
} SDBColumnInfo ;
typedef struct tagDBTableInfo
{
std :: wstring sTableName ;
std :: vector < SDBColumnInfo > sColumnInfo ;
} SDBTableInfo ;
typedef struct tagDBTablesInfo
{
std :: wstring sDBName ;
std :: vector < SDBTableInfo > sTablesInfo ;
} SDBTablesInfo ;
æåã«è¡ãããšã¯ãDLLèªäœãããŒãããããšã§ããããã¯ãéåžžã©ãã:: LoadLibraryïŒ...ïŒã䜿çšããŠè¡ããŸãã
ese.dllããé¢æ°ãåçã«ããŒããã次ã®é¢æ°ãå¿ èŠã«ãªããŸãã
- Jetinit
- JetCreateInstanceW
- JetBeginSessionW
- JetAttachDatabaseW
- JetOpenDatabaseW
- Jetclosedatabase
- JetDetachDatabaseW
- ãžã§ããã¿ãŒã
- JetSetSystemParameterW
- JetOpenTableW
- JetGetColumnInfoW
- JetRetrieveColumns
- Jetove
- JetGetTableColumnInfoW
- JetCloseTable
- JetGetSystemParameter
ããŒã¹éå£éš
å¿ èŠãªé¢æ°ãæ£åžžã«ããŒãããããããŒã¿ããŒã¹ã®çŽæ¥èªã¿åããéå§ããŸãã MSDNã«ãããšã JET_paramDatabasePageSize ïŒesent.hïŒãã©ã¡ãŒã¿ãŒãèšå®ããŠã ããŒã¿ããŒã¹ã®ããŒãžãµã€ãºãæå®ããå¿ èŠããããŸãã ãããåé¡ã®åºçªã§ãã EDBãã¡ã€ã«ã®ã¿ãæã€ãã®å€ãèŠã€ããããšã¯ã§ããŸããããããŒã¿ããŒã¹ãéããªãå Žåã¯æ£ç¢ºã«æå®ããå¿ èŠããããŸãã ããã¯eseutilsïŒExchangeã«å«ãŸããŠããŸãïŒã䜿çšããŠå®è¡ã§ããŸãããå°ãç°ãªããã¹ã䜿çšããŠããã®å€ã¯åãããŒãžã§ã³ã®Exchangeã§äžå®ã§ãããåžžã«4096ã®åæ°ã§ããããšãããããŸãããExchange2010ã§ã¯32768ã§ããããšãå®éšçã«ããããŸãã
ãŸããããŒãžãµã€ãºãèšå®ããŸãã
JET_ERR jRes = _JetSetSystemParameter ïŒ NULL ã NULL ãJET_paramDatabasePageSizeã 32768 ã NULL ïŒ ;
JET_ERRã¯ããšã©ãŒã³ãŒããå«ãåãªãlongã§ãã JetGetSystemParameteré¢æ°ïŒala :: FormatMessageïŒ...ïŒïŒã䜿çšããŠããã®ã³ãŒããããã¹ãèšè¿°ã«å€æã§ããŸãã
JetGetSystemParameter ïŒ m_instanceãm_sesidãJET_paramErrorToStringã
reinterpret_cast < JET_API_PTR * > ïŒ ïŒ jeterror ïŒ ãcBuffãMAX_BUFFER_SIZE ïŒ ;
ãšã©ãŒã³ãŒãã®è§£æã®äŸ¿å®äžã次ã®ãã¯ãã䜿çšããŸãïŒm_cLogã¯ç§ã®å éšãã°ã¯ã©ã¹ã§ãïŒã
#define WRITE_TO_LOG_AND_RETURN_IF_ERRORïŒjeterrorïŒ\
ifïŒjeterrorïŒ{\
char cBuff [MAX_BUFFER_SIZE] = {0}; \
ifïŒm_instanceïŒ_JetGetSystemParameterïŒm_instanceãm_sesidã\
JET_paramErrorToStringãreinterpret_cast <JET_API_PTR *>ïŒïŒjeterrorïŒãcBuffãMAX_BUFFER_SIZEïŒ; \
m_cLog.writeïŒm_sEDBPathãcBuffãjeterrorã__ FILE __ã__ LINE__ïŒ; \
return jeterror; }
次ã«ãExchangeåºæã®ã³ãŒã«ããã¯ãç¡å¹ã«ããå¿ èŠããããŸãã ãããã«ã€ããŠã¯äœãç¥ããŸããïŒ
jRes = _JetSetSystemParameter ïŒ NULL ã NULL ãJET_paramDisableCallbacksã true ã NULL ïŒ ;
次ã«ãããŒã¿ããŒã¹ãæäœããããã®æ°ããã€ã³ã¹ã¿ã³ã¹ ïŒJET_INSTANCE m_instanceïŒãäœæããŸãã
jRes = _JetCreateInstance ïŒ ïŒ m_instanceã NULL ïŒ ;
äœæãããã€ã³ã¹ã¿ã³ã¹ãåæåããŠãããŒã¿ããŒã¹ã®æäœãéå§ããŸãã
jRes = _JetInit ïŒ ïŒ m_instance ïŒ ;
æ°ããã»ãã·ã§ã³ã®éå§ïŒJET_SESID m_sesidïŒïŒ
jRes = _JetBeginSession ïŒ m_instanceã ïŒ m_sesidã NULL ã NULL ïŒ ;
EDBãã¡ã€ã«ãæ¥ç¶ããŸãã
jRes = _JetAttachDatabase ïŒ m_sesidãL "demo.edb" ãJET_bitDbReadOnly ïŒ ;
ãããŠãããéããŸãïŒ
jRes = _JetOpenDatabase ïŒ m_sesidãL "demo.edb" ã NULL ã ïŒ m_dbidãJET_bitDbReadOnly ïŒ ;
åèšããã¹ãŠã®é¢æ°ãJET_errSuccessãè¿ããå ŽåãããŒã¿ããŒã¹ã¯éããŠããŸããã€ãŸããã³ã³ãã³ãã®èªã¿åããéå§ã§ããŸãã
次ã¯ã³ãŒãã§ãã æã£ãŠãããã ãã®ä»¶ã«ã€ããŠã¯ãååŸã«ç«ãã€ããŠãã圌ãèŠã€ããããšã¯ã§ããŸããã
ãªã¹ãè¡š
åæããã«ã¯ã次ã®é¢æ°ãäœæããŸãã
JET_ERR CJetDBReaderCore :: EnumRootTables ïŒ SDBTablesInfo ããã³ sDBTablesInfo ïŒ
{
sDBTablesInfoã sDBName = m_sEDBPath ;
JET_ERR jRes = OpenTable ïŒ ROOT_TABLE ïŒ ;
if ïŒ jRes == JET_errSuccess ïŒ
{
JET_COLUMNBASE sNameInfoã
sTypeInfo ;
if ïŒ ïŒ ReadFromTable ïŒ ROOT_TABLEãNAME_COLUMNãsNameInfo ïŒ &&
ïŒ ReadFromTable ïŒ ROOT_TABLEãTYPE_COLUMNãsTypeInfo ïŒ ïŒ
{
JET_RETRIEVECOLUMN sJetRC [ 2 ] ;
sJetRC [ 0 ] columnid = sNameInfoã columnid ;
sJetRC [ 0 ] cbData = sNameInfoã cbMax ;
sJetRC [ 0 ] itagSequence = 1 ;
sJetRC [ 0 ] grbit = 0 ;
CHAR szName [ MAX_BUFFER_SIZE ] ;
sJetRC [ 0 ] pvData = szName ;
sJetRC [ 1 ] ã columnid = sTypeInfoã columnid ;
sJetRC [ 1 ] ã cbData = sTypeInfoã cbMax ;
sJetRC [ 1 ] ã itagSequence = 1 ;
sJetRC [ 1 ] ã grbit = 0 ;
WORD wType ;
sJetRC [ 1 ] ã pvData = ïŒ wType ;
ãã
{
jRes = GetColumns ïŒ ROOT_TABLEãsJetRCã 2 ïŒ ;
if ïŒ jRes ïŒ = JET_errSuccess ïŒ return jRes ;
if ïŒ wType == 1 ïŒ
{
szName [ sJetRC [ 0 ] ã cbActual ] = 0 ;
SDBTableInfo sTableInfo ;
std :: string tmp ïŒ szName ïŒ ;
sTableInfoã sTableName assign ïŒ tmpãbegin ïŒ ïŒ ãtmp.end ïŒ ïŒ ïŒ ;
sDBTablesInfoã sTablesInfo ã push_back ïŒ sTableInfo ïŒ ;
}
} while ïŒ ïŒ TableEnd ïŒ ROOT_TABLE ïŒ ïŒïŒ ;
}
jRes = CloseTable ïŒ ROOT_TABLE ïŒ ;
}
return jRes ;
}
ã©ãã§ïŒ
- ROOT_TABLE- ãMSysObjectsãããã®ããŒãã«ã«ãŒããåŒã³åºããŸãããã ããŒã¿ããŒã¹å ã®ä»ã®ãã¹ãŠã®ããŒãã«ã®ãªã¹ããå«ãŸããŠããŸãã
- NAME_COLUMN- ãååãããã¹ãŠã®ããŒãã«ã®ååãå«ãåã
- TYPE_COLUMN- ãã¿ã€ãããããŒãã«ã®ã¿ã€ããå«ãåã
ã³ãŒãã§ãããããã«ãæåã«ã«ãŒãããŒãã«ãéããŸããããã¯ã JetOpenTableé¢æ°ã䜿çšããŠè¡ããŸãã
JET_ERR CJetDBReaderCore :: OpenTable ïŒ std :: wstring sTableName ïŒ
{
std :: map < std :: wstring ãJET_TABLEID > :: const_iterator iter = m_tablesã æ€çŽ¢ ïŒ sTableName ïŒ ;
if ïŒ iter == m_tablesãend ïŒ ïŒ ïŒ
{
JET_TABLEID tableid ïŒ 0 ïŒ ;
JET_ERR jRes = _JetOpenTable ïŒ m_sesidãm_dbidã sTableNameãC_str ïŒ ïŒ ã NULL ã
0 ãJET_bitTableReadOnlyã ïŒ tableid ïŒ ;
WRITE_TO_LOG_AND_RETURN_IF_ERROR_2 ïŒ jRes ïŒ
m_tables [ sTableName ] = tableid ;
}
return JET_errSuccess ;
}
次ã«ãReadFromTableå ã®åã«é¢ããæ å ±ãååŸããŸãã ã³ã³ãã³ããååŸããã«ã¯åœŒå¥³ã®IDãå¿ èŠã§ãã
JET_ERR CJetDBReaderCore :: ReadFromTable ïŒ
std :: wstring sTableNameã
std :: wstring sColumnNameã
JET_COLUMNBASE ïŒ sColumnBase ïŒ
{
std :: map < std :: wstring ãJET_TABLEID > :: const_iterator iter = m_tablesã æ€çŽ¢ ïŒ sTableName ïŒ ;
if ïŒ iter ïŒ = m_tablesãend ïŒ ïŒ ïŒ
{
JET_ERR jRes = _JetGetColumnInfo ïŒ m_sesidãm_dbidã sTableNameãC_str ïŒ ïŒ ã
sColumnNameã c_str ïŒ ïŒ ã ïŒ sColumnBaseã sizeof ïŒ JET_COLUMNBASE ïŒ ãJET_ColInfoBase ïŒ ;
WRITE_TO_LOG_AND_RETURN_IF_ERROR_2 ïŒ jRes ïŒ
}
return JET_errSuccess ;
}
IDãJET_RETRIEVECOLUMNæ§é äœã«å ¥åããGetColumnså ã§JetRetrieveColumnsãå®è¡ããŠããŒãã«åãååŸããŸãã
JET_ERR CJetDBReaderCore :: GetColumns ïŒ
std :: wstring sTableNameã
JET_RETRIEVECOLUMN * sJetRCã
INT nCount ïŒ
{
std :: map < std :: wstring ãJET_TABLEID > :: const_iterator iter = m_tablesã æ€çŽ¢ ïŒ sTableName ïŒ ;
if ïŒ iter ïŒ = m_tablesãend ïŒ ïŒ ïŒ
{
JET_ERR jRes = _JetRetrieveColumns ïŒ m_sesidãiter- > secondãsJetRCãnCount ïŒ ;
WRITE_TO_LOG_AND_RETURN_IF_ERROR_2 ïŒ jRes ïŒ
}
return JET_errSuccess ;
}
ããã§ããŒãã«ã®ãªã¹ããååŸã§ããŸããã次ã«åã®ã³ã³ãã³ãã®ååŸã«é²ã¿ãŸãããã åããŒãã«ã«ã€ããŠããã®äžã®åã®ãªã¹ããåãåããåãåã£ããšãã«ããã®æ å ±ãæ§é ã«ä¿åããŸãã
åããªã¹ãããŸã
次ã®é¢æ°ãäœæããŸãã
JET_ERR CJetDBReaderCore :: EnumColumns ïŒ
SDBTableInfo ïŒ sTableInfoã
std :: list < SColumnInfo > ïŒ sColumnsInfo ïŒ
{
if ïŒ ïŒ OpenTable ïŒ sTableInfoãsTableName ïŒ ïŒ
{
JET_COLUMNLIST sColumnInfo ;
GetTableColumnInfo ïŒ sTableInfoãSTableNameã ïŒ sColumnInfo ïŒ ;
MoveToFirst ïŒ sTableInfoãSTableName ïŒ ;
char szNameBuff [ MAX_BUFFER_SIZE ] ;
ãã
{
SColumnInfo ci ;
JET_RETRIEVECOLUMN sJetRC [ 4 ] ;
sJetRC [ 0 ] columnid = sColumnInfoã columnidcolumnname ;
sJetRC [ 0 ] cbData = sizeof ïŒ szNameBuff ïŒ ;
sJetRC [ 0 ] itagSequence = 1 ;
sJetRC [ 0 ] grbit = 0 ;
sJetRC [ 0 ] pvData = szNameBuff ;
sJetRC [ 1 ] ã columnid = sColumnInfoã columnidcolumnid ;
sJetRC [ 1 ] ã cbData = sizeof ïŒ DWORD ïŒ ;
sJetRC [ 1 ] ã itagSequence = 1 ;
sJetRC [ 1 ] ã grbit = 0 ;
sJetRC [ 1 ] ã pvData = ïŒ ciã dwId ;
sJetRC [ 2 ] ã columnid = sColumnInfoã columnidcoltyp ;
sJetRC [ 2 ] ã cbData = sizeof ïŒ DWORD ïŒ ;
sJetRC [ 2 ] ã itagSequence = 1 ;
sJetRC [ 2 ] ã grbit = 0 ;
sJetRC [ 2 ] ã pvData = ïŒ ciã dwType ;
sJetRC [ 3 ] ã columnid = sColumnInfoã columnidcbMax ;
sJetRC [ 3 ] ã cbData = sizeof ïŒ DWORD ïŒ ;
sJetRC [ 3 ] ã itagSequence = 1 ;
sJetRC [ 3 ] ã grbit = 0 ;
sJetRC [ 3 ] ã pvData = ïŒ ciã dwMaxSize ;
GetColumns ïŒ sTableInfoãSTableNameãsJetRCã 4 ïŒ ;
ciã sName ã assign ïŒ reinterpret_cast < wchar_t * > ïŒ sJetRC [ 0 ] .pvData ïŒïŒ ãsJetRC [ 0 ] .cbActual / 2 ïŒ ;
SDBColumnInfo sDBColumnInfo ;
sDBColumnInfoã sColumnName = ciã sName ;
sColumnsInfoã push_back ïŒ ci ïŒ ;
sTableInfoã sColumnInfo ã push_back ïŒ sDBColumnInfo ïŒ ;
}
while ïŒ ïŒ TableEnd ïŒ sTableInfo.sTableName ïŒ ïŒïŒ ;
CloseTable ïŒ sTableInfoãSTableName ïŒ ;
}
return JET_errSuccess ;
}
ããã§ãããŒãã«ãåã³éããŸãããã«ãŒãã§ã¯ãªããåã®æé ã§èŠã€ããããŒãã«ãéããŸãã
次ã«ããã¹ãŠã®åã«é¢ããæ å ±ãååŸããå¿ èŠããããŸãããã®ãããæåã®ãã€ã³ã¿ãŒãååŸããæåŸã®åã«1ã€ãã€ç§»åããŸãã
JET_ERR CJetDBReaderCore :: MoveToFirst ïŒ std :: wstring sTableName ïŒ
{
std :: map < std :: wstring ãJET_TABLEID > :: const_iterator iter = m_tablesã æ€çŽ¢ ïŒ sTableName ïŒ ;
if ïŒ iter ïŒ = m_tablesãend ïŒ ïŒ ïŒ //æ¢ã«éããŠããå Žå
{
JET_ERR jRes = _JetMove ïŒ m_sesidãiter- > secondãJET_MoveFirstã 0 ïŒ ;
BOOL bIsEmpty = ïŒ jRes == JET_errNoCurrentRecord ïŒ ;
if ïŒ bIsEmpty ïŒ jResãè¿ããŸãã //空ã®å Žåã¯ç¡èŠããŸã
WRITE_TO_LOG_AND_RETURN_IF_ERROR_2 ïŒ jRes ïŒ ;
}
NO_ERRORãè¿ããŸãã
}
JET_ERR CJetDBReaderCore :: GetTableColumnInfo ïŒ
std :: wstring sTableNameã
JET_COLUMNLIST * pClã
BOOL bReplaceOld ïŒ
{
JET_ERR jRes = JET_errSuccess ;
std :: map < std :: wstring ãJET_TABLEID > :: ã€ãã¬ãŒã¿ iter = m_tablesã æ€çŽ¢ ïŒ sTableName ïŒ ;
if ïŒ iter ïŒ = m_tablesãend ïŒ ïŒ ïŒ
{
jRes = _JetGetTableColumnInfo ïŒ m_sesidãiter- > secondã NULL ãpClã
sizeof ïŒ JET_COLUMNLIST ïŒ ãJET_ColInfoList ïŒ ;
WRITE_TO_LOG_AND_RETURN_IF_ERROR_2 ïŒ jRes ïŒ
if ïŒ bReplaceOld ïŒ //æåŸã«ããŒãã«ãéãå¿ èŠããªãå Žå
{
jRes = CloseTable ïŒ sTableName ïŒ ;
m_tables [ sTableName ] = pCl- > tableid ;
}
ä»ã«
{
jRes = _JetCloseTable ïŒ m_sesidãpCl- > tableid ïŒ ;
WRITE_TO_LOG_AND_RETURN_IF_ERROR_2 ïŒ jRes ïŒ
}
}
return jRes ;
}
ç³ãèš³ãããŸããããæçš¿ã®æåã®ããŒãžã§ã³ã¯åæãããç§ã¯æéå ã«å¿çããããšãã§ããŸããã§ãããæããã«ãèšäºã®ãµã€ãºã«ã¯äœããã®çš®é¡ã®å¶éãããããã2ã€ã®éšåã«åå²ãããŸãã
ç¶ç¶ããã«ã¯...
次ã®ããŒãã§ã¯ãããŒã¹ãèªãã§çµè«ãå°ããããŒã¹ãããåŒãè£ããããå¯èœæ§ã®ããããŒã¿ã®äŸãèŠãŠãããŸãã
PSãã®ã³ãŒãã¯ãæçš¿çšã«å€æŽãããããŒãžã§ã³ã§ãã ãããã£ãŠãã³ãŒãã«ã¯ããã€ãã®æ¬ é¥ããããæ©èœãåãè©°ããããŠããå Žæã«ã¯ã®ã£ã°ããããŸãã ãããã«æ³šæãæã£ãŠã¯ãããŸãããããã¯çç£ã§ã¯ãããŸãããã å®éã®äŸã瀺ãããã£ãã®ã§ãã ã³ãŒãã¯å®å šã«æ©èœããŠãããã€ã³ã¿ãŒãããäžã«é 眮ã§ãããšåæã«ãããŒãžäžã®ãã¹ãŠã®ã¹ããŒã¹ããé£ã¹ãªããããã«èšè¿°ãããŠããŸãã ãç解ããã ãããããšãããããŸãã
PPSç§ã¯ã詳现ã®ããã«ããã®æ å ±ãåºç¯å²ã®äººã ã«ãšã£ãŠæçšã§ãããšã¯æããªãããããã1人ã§ã圹ç«ã€ãªãã°ãç§ã¯ããããã§ãããããŠããã®ãã¹ãã«è²»ããããæéã¯å ±ãããã§ãããã
é¢é£ãªã³ã¯
- MSDNã®Extensible Storage Engine
- ãã·ã¢èªã®èšäº ïŒESE APIã®äœ¿çšã«é¢ããRuNetã®èšäºã¯ã»ãŒå¯äžïŒ
- ESEæ©èœã®äŸ