Locating MAPI directory using FGetComponentPath

Codes below quoted from
URL
By Sam Charchian

typedef BOOL (STDAPICALLTYPE FGETCOMPONENTPATH)
(LPSTR szComponent,
LPSTR szQualifier,
LPSTR szDllPath,
DWORD cchBufferSize,
BOOL fInstall);
typedef FGETCOMPONENTPATH FAR * LPFGETCOMPONENTPATH;

static TCHAR s_szMSIApplicationLCID[] =
"Microsoft\\Office\\9.0\\Outlook\0LastUILanguage\0"; // STRING_OK
static TCHAR s_szMSIOfficeLCID[] =

"Microsoft\\Office\\9.0\\Common\\LanguageResources\0UILanguage\0InstallLangu
age\0"; // STRING_OK

////////////////////////////////////////////////////////////////////////////
///
// Function name : CSVCFile::InitMAPIDir
// Description : For Outlook 2000 compliance. This will get the
correct path to the
// : MAPISVC.INF file.
// Return type : void
// Argument : LPSTR szMAPIDir - Buffer to hold the path to the
MAPISVC file.
void CSVCFile::InitMAPIDir(LPTSTR szMAPIDir)
{
HINSTANCE hinstStub = NULL;

// Call common code in mapistub.dll
hinstStub = LoadLibrary("mapistub.dll");
if (!hinstStub)
{
// Try stub mapi32.dll if mapistub.dll missing
hinstStub = LoadLibrary("mapi32.dll");
if (!hinstStub)
goto Done;
}

LPFGETCOMPONENTPATH pfnFGetComponentPath;

pfnFGetComponentPath = (LPFGETCOMPONENTPATH)
GetProcAddress(hinstStub, "FGetComponentPath");

if (!pfnFGetComponentPath)
goto Done;

if ((pfnFGetComponentPath("{FF1D0740-D227-11D1-A4B0-006008AF820E}",
s_szMSIApplicationLCID, szMAPIDir, MAX_PATH, TRUE)
||

pfnFGetComponentPath("{FF1D0740-D227-11D1-A4B0-006008AF820E}",
s_szMSIOfficeLCID, szMAPIDir, MAX_PATH, TRUE) ||

pfnFGetComponentPath("{FF1D0740-D227-11D1-A4B0-006008AF820E}",
NULL, szMAPIDir, MAX_PATH, TRUE)) &&
szMAPIDir[0] != '\0')
{
szMAPIDir[lstrlen(szMAPIDir) - 13] = 0; // Strip
"\msmapi32.dll"
}
else
{
szMAPIDir[0] = '\0'; // Terminate String at pos 0.
}

Done:

if (hinstStub)
FreeLibrary(hinstStub);
}


Another reference available in

http://support.microsoft.com/kb/229700

and

(In Delphi by Dmitry Streblechenko)

URL

Comments

Mary Morgan said…
Social Networks on the Semantic Web
Total Number of Members: 8,220,800 Jennifer Golbeck is a researcher in the Computer Science ... Weblog authors are solely responsible for the content and accuracy of their weblogs, including opinions they express, and O'Reilly Media, Inc.
Find out how to buy and sell anything, like things related to tennesse road construction on interest free credit and pay back whenever you want! Exchange FREE ads on any topic, like tennesse road construction!
Chris Klein said…
A real enlightening blog. Don't stop now. This may be of interest to you to stop football betting uk There's lots of information about football betting uk
bloggrez said…
Prompted
Reaction to current events by INtake's Blog Squad Parks-like leaders needed This is a woman who deserves great praise and admiration from the public and most especially the black community for her courage and ...
Hey you've got a great blog here, the best I've seen so far, keep up the good job! A few days ago I was surfing the web and came across this cool site on Apply for loans online. It features all sorts of interesting information on Apply for loans online and makes it super easy to apply online. Now I know that people want fast services I recommend they visit Apply for loans online for quick and hassle-free service.
Linda Johnson said…
Prompted
Reaction to current events by INtake's Blog Squad Parks-like leaders needed This is a woman who deserves great praise and admiration from the public and most especially the black community for her courage and ...
Find out how to buy and sell anything, like things related to arkansas highway construction on interest free credit and pay back whenever you want! Exchange FREE ads on any topic, like arkansas highway construction!

Popular posts from this blog

Clearcase check in/uncheck out all the checked out files script

MSSQL GROUP_CONCAT

Duplicating a local copy of project from TFS and making web software client factory to work