|
try sending the second parameter as widechar L"VPCI" or as BSTR.
and if the last parameter is string, do not send as 0. try sending NULL or empty string L"".
^-^
@|@
- redCat
|
|
|
|
|
Hi redCat,
Actually there are around 10 to 20 member functions in that class. I couldn't able to call any one of the functions. even the one which doesn't have any arguments.
The probable reason seems to me is like the class object pointer returned by cocreateinstance(returns successfully) is accessing a memory location which is not part of the process memory area. But iam not sure. even if this is the problem i don't know how to resolve it?.
please help
|
|
|
|
|
Some updates which i verified.
I could check the typelib registration process in REGISTRY and found it to be perfect according to the procedure shown @ link :
http://blogs.msdn.com/larryosterman/archive/2006/01.aspx
"Minimal COM object registration"
"COM registration for cross process access"
"COM registration if you need a typelib"
"COM registration of PROGIDs."
"What registry entries are needed to register a COM object."
but still the problem persists
please help
|
|
|
|
|
You call your function with bad parameters. Make correct bstr and so on.
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
Hi all,
thanks for your time.
the problem is solved at my end.
Problem lies in importing the type library (tlb) of the COM server in to my client application. Because of which, object gets a corrupted pointer. when a member function is called it gives ACCESS VOILATION error.
I actually imported the typelibrary in my Visual C++ application using "CLASS WIZARD" as mentioned @ MSDN link:
http://msdn.microsoft.com/en-us/library/aa279228(VS.60).aspx
Which actually caused the above problem.
Later I found by importing typelibrary using simple #import "xyz.tlb"
it generates two files .tlh and .tli files which also contains all the classes and member function definitions.
When i used these files in my project it worked.
Sorry for bothering you......
thanks and regards
sandeep r.
|
|
|
|
|
Hi everybody, this is my first post on this forum.
I am trying to find a way to call a constructor of my managed (C#) class registered as a COM object
(with regasm gacutil etc ...)
I can build an object calling:
<br />
HRESULT hr = CoInitialize(NULL);<br />
MyNamespace::IMyClassIntf l_myObject;<br />
l_myObject = MyNamespace::IMyClassIntf(__uuidof(MyNamespace::IMyClass));<br />
I suppose this calls my managed class's the constructor without parameters.
Is there a way to call a constructor with parameters.
Reguards.
|
|
|
|
|
write in an init(...) function. Doing "stuff" in a constructor is a bad idea. Try to reduce it, because error handling and exceptions are really a pain for that.
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
KarstenK, thanks for your answer,
does it mean it's impossible ?
In the end I did it this way.
But sometime you need to pass arguments to object's constructor:
An object <A> wich works only with another object <B> has no reason to exist without <B>.
So In my way, <B> should be passed as argument in <A>'s constructor.
|
|
|
|
|
I dont know.
But the problem of verification of the parameters or error/exception handling in the constructor is a minefield. And also timing: for instance connecting to a remote host, which doesnt answer?
The same is also valid for deconstructors: "Dont do stuff!"
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
No it doesn't tell me if it's possible or not.
I understand that "doing stuff" in constructors should be avoided, but for me it's not a valid answer
It doesn't matter anymore, I used an init function anyway. It was just in order to clarify my mind.
I think it's much worse to do stuff in destructors than in constructors, especially when you use your class as COM object, you can't be sure when your object will be destruct (Probably on the CoUninitialize call).
It's much better to use a Finalize method. But that was not the question.
Thank you anyway KarstenK.
If someone come with something over this point, it would be nice.
|
|
|
|
|
Sorry for the double post, but I didn't get any love on the C# forum, thought I'd try my luck here.
Please could someone point me in the right direction. I've written an ActiveX control in C# and it's working well except for one "small" problem. I'm trying to access the ambient properties of the ActiveX container and am drawing blank.
I'm trying to replicate the following VB 6.0 functionality in C#:
Ambient Properties:
ActiveXAmbientMode = UserControl.Ambient.UserMode
Ambient Properties changed event:
Private Sub UserControl_AmbientChanged(PropertyName As String)
If PropertyName = "UserMode" Then
' Do Stuff Here
End If
End Sub
From what I can find out so far is that this "might" have something do to with implimenting the IOLEControl COM interface? But I can find NO examples of this ever being done? Anyone ever managed to get this working because I can't find any useful info on this anywhere?
|
|
|
|
|
BUMP for any feedback? Does anyone know if this is even possible?
This has nothing to do with UserControl.Site.DesignMode, because that doesn't get exposed to COM. So will always return FALSE when the ActiveX is used in an application.
I'm looking for the COM interface implimentation of how a VB 6.0 ActiveX interacts with it's container....
|
|
|
|
|
Did you ever get an answer on this?
|
|
|
|
|
Hello!
There is interface IWebBrowser2, which I use to get IHTMLDocument2, IHTMLElementCollection, IHTMLElement, IHTMLImgElement from.
I can get different picture options from IHTMLImgElement, but I can't get the picture itself.
How can I do that? Please advise.
P.S.
I've tried to use the following code:
IOleCommandTarget* pCT;
CComVariant vGlyphTableEntry;
vGlyphTableEntry = "c:\\temp.jpg";
if (pElemDispatch->QueryInterface(__uuidof(IOleCommandTarget), (void**)&pCT)==S_OK)
{
pCT->Exec(&CGID_MSHTML, IDM_SAVEPICTURE , OLECMDEXECOPT_DONTPROMPTUSER ,&vGlyphTableEntry, 0);
pCT->Release();
}
But this code shows the 'Save as' dialog, which shouldn't appear. What's wrong with this code? Is there some other way to do that?
Thanks in advance
|
|
|
|
|
Take a look at IHTMLElementRender which you should be able to query the IHTMLImgElement for. This interface has a DrawToDC method that you could use to render the element to a DC of your own creation.
|
|
|
|
|
I want to write a program which checks present available wireless networks through my wireless application ,
and to ping message to all the networks to check their availability..... i think i have use aodv concept but dont no how to start .... pls help in getting start ...
Thanks for any suggestion ....
|
|
|
|
|
I am trying open a excel file after downloading it from website, but its giving error "Missing file: C:\default.css?5".how can i overcome the error thru C#.
Thanks
Senz
|
|
|
|
|
Hello,
I want to create a C# DLL that passes out a string as a parameter. I have tried this (partial code):
[C# Code]
public interface iInterface1
{
[System.Runtime.InteropServices.DispId(13)]
void Call13(
[System.Runtime.InteropServices.In]
[System.Runtime.InteropServices.Out]
[System.Runtime.InteropServices.MarshalAs(
System.Runtime.InteropServices.UnmanagedType.BStr)]
ref string s1);
[System.Runtime.InteropServices.DispId(17)]
void Call17(
[System.Runtime.InteropServices.In,
System.Runtime.InteropServices.Out,
System.Runtime.InteropServices.MarshalAs(
System.Runtime.InteropServices.UnmanagedType.LPWStr)]
ref System.String s1);
}
[C++ Code]
BSTR s;
m_int0.Call13(&s);
[C++ Code]
LPWSTR s2;
m_int0.Call17(&s2);
The programs compile, but do not run:
The C++ call to Call13 gives me the message "Not enough storage is available to complete this operation".
The C++ call to Call17 in Debug mode shows that there is a breakpoint in the program:
"This may be due to a corruption of the heap, and indicates a bug in go2.exe or any of the DLLs it has loaded."
Does anyone have any ideas?
Regards,
Mike
modified on Wednesday, April 15, 2009 10:23 AM
|
|
|
|
|
|
Hi
My VB.NET Library references ADODB. When I build it, the above message comes out.
Should I run tlbimp.exe ?
Thanks
Marcello Turnbull
|
|
|
|
|
You may need a strong name key file. Investigate Project Properties->Signing:
Sign the assembly
Choose a strong name key file
Regards,
Mike
|
|
|
|
|
Hi all,
I am new to COM,
and i use MFC for developing com
I developed an out process server(Automation Server) and i exposed a singleton comobject to outside world
to achieve singleton what i have done is inherited a class from COleObjectFactory and override the OnCreateObject in the derived class and it looks like this
CCmdTarget* CSingletonFactory::OnCreateObject()
{
//static CServer m_sServer;
//return &m_sServer;
if (m_Server == NULL)
{
m_Server = new CServer;
}
return m_Server;
}
and i wrote a client that too in MFC which just creates the object every time i click start button
(here always it returns same object's IDispatch pointer)
void CComClientDlg::OnBnClickedStart()
{
// TODO: Add your control notification handler code here
CLSID id = { 0xe856e42c, 0xe479, 0x4008, {0xb2, 0xf8, 0x1, 0xec, 0x9e, 0x5a, 0x84, 0x63} };
COSERVERINFO si;
si.pwszName = OLESTR("127.0.0.1");
si.pAuthInfo = NULL;
si.dwReserved1 = 0;
si.dwReserved2 = 0;
MULTI_QI rgmqi;
rgmqi.pIID = &IID_IDispatch;
rgmqi.pItf=NULL;
rgmqi.hr=S_OK;
HRESULT hresult = ::CoCreateInstanceEx(
id,
NULL,
CLSCTX_LOCAL_SERVER,
&si, 1, &rgmqi);
if (hresult == S_OK)
{
//hmmm success
;
}
}
but wat happens is when i click the start button 6 times my server is getting crashed
running in debugger alone i could able to find the crash(if not in debugger my server is getting shutdown silently and opening again)
In Debugging what i have found is the reference count of my object is steady getting reduced,
when i try to create the object first time(first time when the OnBnClickedStart is called) the ref count is 0 and next time it becomes 4(i dono how) and when i continuously call OnBnClickedStart for six time server crashes)
am i missing some thing here?
As it is a singleton should i give my one addref and release?
help me please
Thanks,
Jey
jey
|
|
|
|
|
For one of my customers I simply used the TAPIRequestMakeCall method for making an outgoing call.
The problems is that it triggers Windows Dialer which popups 2 windows.
This is very annoying.
So I am looking for another way to make an outgoing call (not using the requestmakecall method) using the TAPI3LIB.
So my question is, what is the minimum required code/steps for making an outgoing call?
The article at http://msdn.microsoft.com/en-us/library/ms733298(VS.85).aspx[^]
Seems to have too much overhead for me.
Can anyone help me out here?
|
|
|
|
|
I'm at the end of my rope here... I've been bashing my head on my keyboard for the last week trying to figure out this issue.
I'm trying to display a flash control on a DirectDraw surface and my call to AtlAxAttachControl fails - preventing the flash player from appearing within the control.
Here's a stripped down version of my code:
#pragma once
#include <string>
#include <windows.h>
#include <exdisp.h>
#include <mshtmlc.h>
#include <atlbase.h>
#include <atlcom.h>
#include <atlwin.h>
using std::string;
#import "PROGID:ShockwaveFlash.ShockwaveFlash" no_namespace raw_interfaces_only
typedef HRESULT (WINAPI *LPAtlAxWinInit) ();
typedef HRESULT (WINAPI *LPAtlAxGetControl)(HWND hwnd, IUnknown** unk);
class FlashViewer
{
public:
FlashViewer();
~FlashViewer();
bool Init(int Width, int Height);
void OpenFlash(const char* filename);
void DrawToSurface(LPDIRECTDRAWSURFACE7 lpdds);
private:
int mViewerWidth;
int mViewerHeight;
HWND mViewerWnd;
IShockwaveFlash* mFlashCtrl;
};
FlashViewer::FlashViewer()
{
mViewerWidth = 0;
mViewerHeight = 0;
mViewerWnd = 0;
mFlashCtrl = NULL;
}
FlashViewer::~FlashViewer()
{
DestroyWindow(this->mViewerWnd);
if (this->mFlashCtrl != NULL)
{
this->mFlashCtrl->Release();
this->mFlashCtrl = NULL;
}
}
bool FlashViewer::Init(int width, int height)
{
LPAtlAxWinInit AtlAxWinInit3 = (LPAtlAxWinInit)GetProcAddress(LoadLibrary("atl"), "AtlAxWinInit");
LPAtlAxGetControl AtlAxGetControl3 = (LPAtlAxGetControl)GetProcAddress(LoadLibrary("atl"), "AtlAxGetControl");
MSG msg;
HRESULT hr = AtlAxWinInit3();
HWND hwnd = CreateWindow("AtlAxWin", "", WS_VISIBLE|WS_POPUP, 0, 0, 1024, 768, 0, 0, 0, 0);
IShockwaveFlash* flash = 0;
hr = CoCreateInstance(__uuidof(ShockwaveFlash), 0, CLSCTX_ALL, __uuidof(IShockwaveFlash), (void **)&flash);
hr = flash->put_WMode(L"transparent");
hr = flash->put_Loop(true);
hr = AtlAxAttachControl(flash, hwnd, NULL);
hr = flash->put_Movie(L"c:\\FrontEnd.swf");
long pVal = -1;
flash->get_ReadyState(&pVal);
return true;
}
void FlashViewer::OpenFlash(const char *filename)
{
this->mFlashCtrl->LoadMovie(0, _bstr_t(filename));
}
void FlashViewer::DrawToSurface(LPDIRECTDRAWSURFACE7 lpdds)
{
if (this->mViewerWnd == NULL)
return;
RECT rect = {0, 0, this->mViewerWidth, this->mViewerHeight};
HDC hdcSurface;
HRESULT hr = lpdds->GetDC(&hdcSurface);
if (FAILED(hr))
return;
SetMapMode(hdcSurface, MM_TEXT);
OleDraw(this->mFlashCtrl, DVASPECT_CONTENT, hdcSurface, &rect);
lpdds->ReleaseDC(hdcSurface);
}
When debugging - the console displays two First-chance exceptions as soon as AtlAxAttachControl() is called... Both are 0x8001010D: An outgoing call cannot be made since the application is dispatching an input-syncronous call.
This problem is totally driving me crazy... PLEASE SOMEONE HELP.
|
|
|
|
|
How to create new object in C# for reading COM port.
I am having 'Comet.xyz' object. this object comes from COM port.
please tell me how can i convert following code into c#.
/////////code in delphi
Coment := CreateOleObject('Comet.xyz');
Coment.COmPort="COM1";
please convert it into C#
|
|
|
|