Go Back   Technology Questions > Hardware Questions > Electronics > Smartphones

Smartphones This is the Microsoft General Public Smartphones Newsgroup.

Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old 05-13-2007, 05:50 PM
cola
Tablet PC Guest
 
Posts: n/a
homescreen plugin program access type library?

refering to helloplug example ,i wrote a weather plugin for homescreen
by vc++ net on windows mobile 5.0 smartphone.and i want to access a .net
component,Weatherlib.dll,based on windows mobile 5.0 smartphone,so i exposed
Weatherlib.dll as a type library,Weatherlib.tlb.

here is the code to access Weatherlib.tlb.
but the method GetInfo() always returns "Com initialize failed",
that is CoInitializeEx fails to initialize com.
does it make,i mean,accessing a type library in my homescreen plugin program.
thanks in advance.

#include "objbase.h"
#import "Weatherlib.tlb"
using namespace Weatherlib;

LPCTSTR GetInfo()
{
HRESULT hr=CoInitializeEx(NULL,COINIT_MULTITHREAD);
LPCTSTR info;
if(hr==S_OK)
{
Weatherlib::_Weather *weather;
Weatherlib::_WeatherPtr p(__uuidof(Weatherlib::Weather));
weather=p;
info=(LPCTSTR)(weather->GetInfo());
weather->Release();
CoUninitialize();
}
else
{
info=L"Com initialize failed";
}
return info;
}

ps:Weatherlib implementation by C#
#region Using directives

using System;
using System.Text;
using System.Runtime.InteropServices;

#endregion

namespace Weatherlib
{
[Guid("D6F88E95-8A27-4ae6-B6DE-0542A0FC7039")]
[InterfaceType(ComInterfaceType.InterfaceIsIDispatc h)]
public interface _Weather
{
[DispId(1)]
string GetInfo();
}


[Guid("13FE32AD-4BF8-495f-AB4D-6C61BD463EA4")]
[ClassInterface(ClassInterfaceType.None)]
public class Weather :_Weather
{
public Weather()
{
}
public string GetInfo()
{
return "Testing ok";
}
}
}


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

 
Old 05-13-2007, 05:50 PM
Xploder HD Movie Player for PS3. Manage, convert and transfer media files between the PC and PS3.
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Cannot access explorer view of sharepoint doc library Robert Aldwinckle Windows Vista 2 03-28-2007 08:15 PM
Associate a file type or protocol with a program David Windows Vista 2 03-10-2007 09:00 AM
Cannot change program linked to file type Doug Windows XP 6 03-07-2007 05:00 AM
File Manager type program for use with Vista please kraut Windows Vista 5 03-05-2007 07:15 PM
file type: can;t get a program into the list Osiris Windows XP 2 01-04-2007 06:31 AM


All times are GMT -8. The time now is 01:04 PM.


2003 - 2008 All Rights Reserved. Technology Questions

SEO by vBSEO 3.1.0