I am trying to use Managed C++ to get the dir from which my .msi was
launched and set a property with that value. I am pretty lost. I have no
clue if I am even on the right track, but this all seems so simple. Right
now the last line below - I can't get the 3rd arg right. It needs to be an
LPCSTR.

String *cdromDir = NULL;

if ((status = getInstallProperty(hInstall, "OriginalDatabase",
&imageLocation)) != ERROR_SUCCESS) return status;

cdromDir = Path::GetDirectoryName(imageLocation);

USES_CONVERSION;

MsiSetProperty(hInstall, "CDROMDIR", A2W(*cdromDir));



Thanks,

owen

Re: cannot convert from 'System::String' to 'LPCSTR' by Doug

Doug
Mon Jun 06 23:36:25 CDT 2005

On Mon, 6 Jun 2005 23:25:32 -0500, Owen Corpening wrote:

> I am trying to use Managed C++ to get the dir from which my .msi was
> launched and set a property with that value. I am pretty lost. I have no
> clue if I am even on the right track, but this all seems so simple. Right
> now the last line below - I can't get the 3rd arg right. It needs to be an
> LPCSTR.
>
> String *cdromDir = NULL;
>
> if ((status = getInstallProperty(hInstall, "OriginalDatabase",
> &imageLocation)) != ERROR_SUCCESS) return status;
>
> cdromDir = Path::GetDirectoryName(imageLocation);
>
> USES_CONVERSION;
>
> MsiSetProperty(hInstall, "CDROMDIR", A2W(*cdromDir));

See:

How To Convert from System::String* to Char* in Visual C++ .NET
http://support.microsoft.com/?kbid=311259

--
Doug Harrison
Microsoft MVP - Visual C++