By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,234 Members | 1,869 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,234 IT Pros & Developers. It's quick & easy.

More Thread CoInitialiseEx woes.........

P: n/a
I'm going to kindof restart this thread, because its going up in the list
(on my browser anyway). I'm still not able to call OleSetClipboard from
within my thread in my VB application. As a refresher, the reason I want to
do this is so I can paste links into a Word document from some Ole object I
have lying around. The problem I'm having is that OleSetClipboard returns
HRESULT -2147221008 ("CoInitialize has not been called.").

Anyway, I set my thread up like this:

' Create the worker thread

m_Thread = New Thread(New ThreadStart(AddressOf _Start))
m_Thread.ApartmentState = ApartmentState.STA
m_Thread.Start()

At the start of my thread main() I write this to initialise COM:

m_ComInitialized = DLLImports.CoInitializeEx(0,
DLLImports.COINIT.COINIT_APARTMENTTHREADED)

(
Note that CoInitialiseEx is defined as:

Public Declare Function CoInitializeEx Lib "OLE32.DLL" ( ByVal
pvReserved As Int32, ByVal dwCoInit As Long) As Int32
)

When I want to set OLE to clipboard I write this:

m_Result = DLLImports.OleSetClipboard ( theObject )

(
Note that OleSetClipboard is defined as:

Public Declare Auto Function OleSetClipboard Lib "OLE32.DLL" _

(<MarshalAs(UnmanagedType.Interface)> ByVal theDataObject As
COM.IDataObject) As Integer
}
m_ComInitialized returns a value of 1. And m_Result after OleSetClipboard
returns "CoInitialize has not been called".
Any further ideas?
Thanks

Robin
Nov 20 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.