Psst! Did you know DevelopmentNow is a mobile web site design agency?

Contact us for help mobilizing your site, or to sign up for our beta Mobile Web SDK!
all groups > inetserver iis > june 2009 >

inetserver iis : MimeType


abcd
7/13/2004 10:50:05 AM
Can somebody give me the example of setting MimeTypes in C++. MSDN gives
only VB examples. I have not very much experience with SAFEArrays

Andrey P
7/13/2004 8:58:10 PM
[quoted text, click to view]

Well, information on how to manage MIME via ADSI you can find here:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/iissdk/iis/ref_prog_iaorefimm.asp

and general idea on how to access ADSI via C# you can find here:

http://support.microsoft.com/default.aspx?scid=KB;EN-US;315716

I don't think translate this examples to MS/VC++ is a very big problem :-)

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/adsi/adsi/setting_up_c___for_adsi_development.asp

abcd
7/13/2004 11:27:45 PM
for me its a big problem.

I am reading the MimeMap, VB does the job in one line...In VC++ I get that
as a SafeArray and I dont know how to read that SafeArray. Not that simple
for me.
If Safe Array can be avoided then I would like to see some sample.

I am stucked


[quoted text, click to view]

Andrey P
7/14/2004 12:59:34 PM
Sorry, I don't have big experience tricking Visual C++. I usually follow
documentation and examples :-)

By the way, I don't see anything to be afraid of using SafeArrays ....

-Andrey

[quoted text, click to view]
abcd
7/14/2004 1:12:50 PM
there is no fear but somehow the code is not working and documentation on
IISMimeMap, IISMimeType looks insufficient.

I am not getting the below code runnning. Its not iterating through with the
values....I only get type and not the extension.....In VB the values are
accessed as ArrName[i].Extension and ArrName[i].Type...so simple....

==>

The code is

VARIANT var;
VariantInit(&var);


hr = LP.pADs->GetEx(L"MimeMap", &var);


if ( SUCCEEDED(hr) )
{
LONG lstart, lend;
SAFEARRAY *sa = V_ARRAY( &var );
VARIANT varItem;

// Get the lower and upper bound.
hr = SafeArrayGetLBound( sa, 1, &lstart );
hr = SafeArrayGetUBound( sa, 1, &lend );

// Iterate and print the content.
VariantInit(&varItem);


for ( long idx=lstart; idx <= lend; idx++ )
{
hr = SafeArrayGetElement( sa, &idx, &varItem );

_variant_t var1(varItem);

IISMimeType *mt = NULL;
IUnknown *uk = (IUnknown *) var1;
HRESULT hr = uk->QueryInterface(IID_IISMimeType, (void **)&mt);
if(SUCCEEDED(hr))
{
BSTR type;
BSTR extension;
hr = mt->get_Extension(&extension);
hr = mt->get_MimeType(&type);
mt->Release();
/*SysFreeString(type);
SysFreeString(extension);*/
}

VariantClear(&varItem);
}

VariantClear(&var);

}

[quoted text, click to view]

Andrey P
7/14/2004 1:31:48 PM
Hello,

I would suggest to post the coding question to the Dev news groups :o)

news://microsoft.public.win32.programmer.*

-Andrey.

[quoted text, click to view]
NehaDas
6/9/2009 2:35:33 AM
Hi abcd,
have u been able to solve this issue ? How did u get the statement :
uk->QueryInterface(IID_IISMimeType, (void **)&mt); to complie .
I get a linker error on IID_IISMimeType . Can u tell me what all header/lib files did u include?

From http://www.developmentnow.com/g/59_2004_7_0_0_277496/MimeType.htm

Posted via DevelopmentNow.com Groups
AddThis Social Bookmark Button