|
No need to use a SafeArray.
If the string is using ANSI, convert it to UNICODE using MultibyteToWideChar API.
For the Unicode string, call SysAllocString to make it a "good" BSTR, which is the "VB-native" string type.
Depending on the parameter declaration, you need to SysFreeString the BSTR when you are done.
Some of us walk the memory lane, others plummet into a rabbit hole
Tree<t> in C# || Fold With Us! || sighist
|
|
|
|
|
Hi all,
Im new to ATL COM programming(2 weeks!). im using an api in my component.
unfortunately i havnt been able to load it appropriately(atleast this is what
the client says!). this is how i've done it... pls tell where im wrong.
i created an ATL class in the dll and added the following to the class' cpp
file in the global area
<br />
HINSTANCE hDll=LoadLibrary("API.dll");<br />
typedef short (*Init_type)();<br />
typedef short (*Close_type)();<br />
typedef short (*SetAnalog_type)(int,double);<br />
typedef short (*SetOutput_type)(int);<br />
typedef short (*ResetOutput_type)(int);<br />
typedef short (*IsInput_type)(int);<br />
<br />
Init_type Init;<br />
Close_type Close;<br />
SetAnalog_type SetAnalog;<br />
SetOutput_type SetOutput;<br />
ResetOutput_type ResetOutput;<br />
IsInput_type IsInput;<br />
<br />
Class::Class()
{<br />
Init = (Init_type)GetProcAddress(hDll,"Init");<br />
Close =(Close_type)GetProcAddress(hDll,"Close");<br />
SetAnalog = (SetAnalog_type)GetProcAddress(hDll,"SetAnalog");<br />
SetOutput = (SetOutput_type)GetProcAddress(hDll,"SetOutput");<br />
ResetOutput = (ResetOutput_type)GetProcAddress(hDll,"ResetOutput");<br />
IsInput = (IsInput_type)GetProcAddress(hDll,"IsInput");<br />
}<br />
after this i've created other methods in the class where i use these api
functions.
the dll compiles without problems, but when i use these methods in a vb
client i get this error...
The instruction at "0x00000000" referenced memeory at "0x00000000". The
memmory could not be "read".
Click on OK to terminate the program...
pls help... maybe i dont know how to load an api...im new to this. can
somebody give a link to a sample code where the coder has loaded the api and
used the functions.
Thanks in advance
Nikhil
|
|
|
|
|
I am writing windowless activex control with ATL. i want this control to blink with certain rate.
I am using all the techniks ( bitmap drawing, flickerfree activation ... ) but I still see some flicking. When I use windowed activation everighing is fine. For blinkking I am using timer funcion
Can somebody dive me some idea how to fix the problem
|
|
|
|
|
Hi,
I am a newbie and was not sure about the category under which my question comes. Therefore please move it to appropriate category if you guys feel so.
I have an address book application which I want to integrate with outlook/outlook express.
Can someone please tell me how can I do it ? Some tutorial or link.
My application is in some way similar to plaxo.
Thanks a lot
|
|
|
|
|
Hi all,
I have trouble with a vc dll com which im using in a vb client...
i've imported a third party ocx and a dll which consists of API functions
(basically its architecture is similar to kernel32.dll) in my vc com dll and
ive used them in other classes.
i wrote a class called myerrorhandling in which has a public method
error_logger
this is the method
<br />
STDMETHODIMP errorhandling::error_logger()<br />
{<br />
FILE *fptr;<br />
char error[10]={"ERROR***"};<br />
fptr=fopen("C:\\Debug.txt","a+");<br />
fprintf(fptr,error);<br />
fclose(fptr);<br />
return S_OK;<br />
}<br />
i get this error when i create an object of the errorhandling class in vb
<br />
Run-time error '-2147024770 (8007007e)':<br />
<br />
Automation error<br />
The specified module could not be found.<br />
infact i get this error while creating an object of any class in the dll
i havnt used any api functions or thirdparty dll objects anywhere in this
class(error handling)...
i created another com dll in vc and added this errorhandling class and it
worked fine.
what could the problem be?
thanks in advance
Nikhil
|
|
|
|
|
got it.. i havent been able to import the api properly.
how do i import kernel32.dll in my com dll if i wanna use gettickcount??
pls help
thnks
nikhil
|
|
|
|
|
I think you can use the LoadLibrary and make a call to GetTickCount function using the GetProcAddress
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
|
Hello,
I am using MFC - ActiveX control in C# based windows application.
I am not able to debug the control with the C# application while it is possible with the MFC applcation.
Is it possible to do so if yes then HOW.
Thanks.
Byee..
Gajesh
Pune(India
|
|
|
|
|
Is that DCOM is implemented through Microsoft Transaction Server. If not so then how it is implemented.
|
|
|
|
|
DCOM stands for Distributed COM, and refers to the ability to call COM objects running on another machine. DCOM is implemented over DCE-compatible Remote Procedure Calls [RPCs]. CoCreateInstance calls from the client are translated into a message that's sent over the network, which is received by the server computer's RPC subsystem, the RpcSs service. In modern versions of Windows, this service runs in a SvcHost.exe process. The RPC subsystem locates a process to serve that class, starting one if necessary, and calls the process on the client's behalf. I'm not sure if the system then hands the network connection over to the server process so that future calls don't have to go through the RPC subsystem. The exact network protocol used, below the RPC protocol, is dependent on the configuration and on which network protocols the system has installed. On Windows XP and Server 2003 machines, only connection-oriented protocols such as TCP are enabled by default; earlier versions could use UDP if the call security didn't require a connection.
MS Transaction Server was a way of setting up different contexts for objects, to allow them to interact without knowing about one another. It offered transaction support, object pooling and just-in-time activation. You had to program a little differently for MTS than for COM. In Windows 2000, MTS was incorporated into the regular COM APIs and was renamed COM+. With MTS and COM+, it's possible to have a COM component implemented as a DLL but still run outside the creating process, using a surrogate process (dllhost.exe). To communicate between processes running on the same system, COM uses a special form of RPC called Local RPC.
DCOM predates MTS by a couple of years.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Hello world!!!
I created a UPnP device which works as a control point. It succeeded but now I'm facing a great problem. I'm trying to register the device with the host in order to be published on the network. But the IUPnPRegistrar::RegisterRunningDevice method doesn't work. The return value of this is an E_FAIL which is a non-specified error value. Thus I think the DLL in which I wrote the device control object is bad. So I need a help from anyone who have already registered a UPnP device or anyone who know very well how to process.
Thanks for the help.
|
|
|
|
|
My ActiveX project has some problem, It's Can't Add Method and Property. It's hint Error adding a(n) method to the associated class.I'm use vc6+sp6.
tell me why ,thank you.
msn:Flashcutreg@hotmail.com
|
|
|
|
|
* Make sure all relevant files are not read-only
* close VC6, delete the .ncb and .clw (if any), then try again
Some of us walk the memory lane, others plummet into a rabbit hole
Tree<t> in C# || Fold With Us! || sighist
|
|
|
|
|
Hi,
I want to add content to a view derived from MFC's CHtmlView from a thread.
The following code is a stripped back version of the code executed by the
thread.
CMyHTMLView::AddHTML()
{
HRESULT hr = CoInitialize( NULL );
ASSERT( SUCCEEDED( hr ) );
string shtml( "Hello World" );
try
{
CComQIPtr< IHTMLDocument2 > pHtmlDoc( GetHtmlDocument() );
if ( pHtmlDoc )
{
CComQIPtr< IHTMLElement > pBodyElement;
HRESULT hr = pHtmlDoc->get_body( &pBodyElement );
if ( SUCCEEDED( hr ) )
hr = pBodyElement->insertAdjacentHTML( _bstr_t(L"beforeEnd"), _bstr_t( shtml.c_str() ) );
ASSERT( SUCCEEDED( hr ) );
}
}
catch( _com_error e )
{
REPORT_COM_ERROR(e);
}
catch(...)
{
}
CoUninitialize();
}
If the contents of shtml is small as shown above it works fine. However when
shtml is a few K of HTML the call to insertAdjacentHTML() throws an
exception which is caught in catch(...). The HTML is valid and the same code
works fine when it isn't in a thread. In the real code, shtml is on the
heap or maybe the stack?
Any clues about what I'm doing wrong?
Neville Franks, Author of Surfulater www.surfulater.com "Save what you Surf" and ED for Windows www.getsoft.com
|
|
|
|
|
It could be something to do with thread-local data, a lot of MFC uses it. I've had problems trying to manipulate objects from threads - usually you have to do the work in the thread that created the object, but presumably this takes away the point of what you're trying to do.
It won't matter if shtml is on the stack or heap, but you should check if insertAdjacentHTML completes when the function returns or maybe it takes the data, returns and then some other thread processes it. Some of the html stuff has other threads to do work. Have you tried putting a sleep in after the insert to give it time to complete?
|
|
|
|
|
Hi Keith,
Thanks for the reply. I got the following reply on an MS Newgroup, which explains things.
You cannot simply pass COM interface pointers to a worker thread - you
need to marshal them. See
http://support.microsoft.com/?kbid=150777
MSHTML is a single-threaded component. If you don't marshal the
pointers - in violation of COM rules - you'll likely get random crashes.
If you do marshal, then any call you make in the worker thread though
such a pointer gets marshalled back to the main thread, executed there,
and any results marshalled back to the worker. Essentially, the worker
thread isn't doing any work, it spends all its time waiting for the main
thread to serve its calls.
Bottom line: it's pointless to perform DHTML manipulations from a worker
thread. You add pure overhead, without gaining anything at all.
I was already working on implementation that built the HTML in a thead and
added it to a queue for the app thread to display. My main problem was
getting the main thread to be a bit more responsive when large chunks of
HTML are in play. After a few different implementations, I've now got
something I'm quite happy with.
Neville Franks, Author of Surfulater www.surfulater.com "Save what you Surf" and ED for Windows www.getsoft.com
|
|
|
|
|
If you are using the use the interfaces in a different thread than the one creating the control, you need to marshal it to this thread (CoMarshalInterThreadInterfaceInStream and CoGetInterfaceAndReleaseStream, which probably were made to win the WIN 32 API lyrics award)
chopping strings usually isn't a symptom of violating apartment boundaries, but MSHTML ctrl has a few message loop interacitons that make that possible.
Some of us walk the memory lane, others plummet into a rabbit hole
Tree<t> in C# || Fold With Us! || sighist
|
|
|
|
|
I'm trying to register a dll on a Win2003 server, but an getting the message "DllRegisterServer in ...filename... failed. Return code was 0x8007007e". This error supposedly means a module is missing. I think all the DLLs are there - it's a standard atl dll.
I can register the dll fine on my development pc and on another Win2003 server, just this one I can't. I tried loading up the registry entries manual, but I just get an error when I try to use createobject.
Any ideas why I can do it on one server and not another?
Thanks
|
|
|
|
|
Use a dependency viewer, like "Depends" which comes with MSVC6), to view the dependencies of the COM DLL. It will highlight missing DLLs.
Steve
|
|
|
|
|
Done that, there aren't any missing. I'd get a LoadModule failure if a dll was missing.
|
|
|
|
|
Have found the problem now - atl.dll was not registered!
|
|
|
|
|
Hi,
I'm trying to paste clipboard content in an outlook message window (new mail/reply) from an outlook addin (when a button is pushed)
I'm using VC++ 6, and the addin is based on several good articles from codeproject.
I was able to create a button in the message window, but I didn't found a way to paste content in this window through the Office API.
So I used SPY++ to get the structure of an Outlook message window and sent a WM_PASTE event to the body control handle. (Using Active window, FindWindowEx and SendMessage)
This works fine for text and rich text emails ('RichText20' window class), but I can't make it work for HTML mails (Window class is 'Internet Explorer_Server').
Since WM_PASTE event was not working, I managed to get an IHTMLDocument2 pointer on this control and tried to use execCommand( _T( "Paste" ) , ...) but nothing happens. On the contrary, when I use execCommand( _T( "SelectAll"), ... ), it works.
I'm running out of ideas on this, so i'm looking for hints.
Basically , I only want to insert text/links at the cursor position.
I think that if I can get an IWebBrowser2 pointer for this control, I should by able to send the event using execWB (I already did it in IE)
How Internet Server_Explorer handles Ctrl-C events ? Is it using another control ?
Do you know a better way to do this ?
Thanks
--
Nicolas
|
|
|
|
|
Hi again,
I found the solution.
I use Outlook::_Application to get the active inspector
I'm then able to get the editor type and the HTML editor in a clean way.
An interface query on the html editor gives an IHTMLDocument.
Insertion is done using get Selection and IHtmlTxtRange. (see http://starkravingfinkle.org/blog/2005/01/)
--
Nicolas
|
|
|
|
|
I heard Mac OS suports COM. Is that true? Do unix ,linux or QNX support COM or COM is just a binary standard on windows?
|
|
|
|