|
Note: Without seeing any of your code, I'm just guessing...
It's probably because when you create the BSTR, you let it count characters to determine its length, rather than telling it what the length actually is. Any string length function in C/C++ will see a NULL as the end of string.
So, create your BSTR like this, telling it what its length is:
BST b = SysAllocStringLen(L"ABC\0XYZ", 7);
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
CodeProject MVP for 2010 - who'd'a thunk it!
|
|
|
|
|
Still I am getting only ABC in VB
So please tell me how to send full string.
I am getting what you have told me. but I want to transfer this full string from vc to vb.
So please tell me the solution
It's very urgent
Thanks for help.
|
|
|
|
|
This begs an obvious question: can VB handle strings with embedded NULLs? Many of C's CRT functions such as wcscmp can't for example.
Steve
|
|
|
|
|
As I recall you won't be able to do as you want, either the ATL Event Wizard generated code sees the internal NULL and loses the rest (even with the BSTR length set) or VB will see a a NULL terminated string. I'm pretty sure You'll have do do more one way or the other. Maybe pass an array of characters?
|
|
|
|
|
The NULL character is your problem. Try replacing it with some other unique Unicode character which both parts of your application can recognise. Alternatively put the box character in your source string in the first place.
It's time for a new signature.
|
|
|
|
|
Hello Friends
I am using namespace MSXML in my application to traverse and read XML file.But I have some confusion regarding MSXML is that this one is related to c++ DOM APIs na? And what its relation with COM?
And these both COM AND DOM are provoding different APIs?and then what is DCOM?
Please Suggest me something.I am too confused.
Thanks & Regards
Yogesh
|
|
|
|
|
you should read about the TLAs.
The short run:
MSXML is MS-XML and implemented in a COM-object. It uses the DOM of XML.
And DCOM is completly different. It is D-COM. D stand for distributed.
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
Hi,i am creating a Outlook plugin in ATL to get export the selected mail details to a web service.I am able to get the mail details.
But i occasionally get "Could not complete the operation.One or more parameters are invalid" messagebox when i click on Send/Receive.
Once i reopen the outlook, i am able to do Send/Receive.
I could not figure out in what scenario the error occurs.Pls help.
|
|
|
|
|
did you introduce new controls such as button to outlook UI for this purpose? or did you subscribed for Send/Receive event via connectionPoint? Explaining the procedure you have followed may help to get quick solutions..
|
|
|
|
|
I have introduced new toolbar using ATL.On selecting some mails and clicking on the button, mail details will be sent to a web service.The part of retrieving the mail details is working fine.On doing the export a few times, and then clicking on Send/Receive button, a message box "Could not complete the operation" appears.
As the message box does not appear on a single Export action, i could not find the scenario.
|
|
|
|
|
problem seems strange, but after googling the error msg, it is found that this error msg comes in several other scenarios like repeatedly creating New Appointment, New Tasks etc also. So can we conclude that repeatedly retrieving mail items conflicts with send/receive action.? 
|
|
|
|
|
thanks for your time..
yes.. the error msg comes in several case in outlook.i am trying to find what causes the Send/Receive action to show the error msg.
what object of outlook gets changed, so the error occurs on the Send/Receive action??
|
|
|
|
|
Hi All..
I need to use FFDShow interfaces in my VC++ project. how can i proceed. I got ffdshow.ax file from the FFDShow instalation directory. But there is no tlb file to import. Can i use this .ax file for getting the interfaces...? Or any other methods there to proceed...
Please help me...
|
|
|
|
|
directshow filters normally doesn't have a typelib, because its not necessary for them to support IDispatch interface. Isn't it possible to get header files of ffdshow? How did you solve the problem?
|
|
|
|
|
Still i am not able to fix the problem. For the time being i am using the FFDShow registry settings for my purpose. But this is not A PERMANENT SOLUTION for me...
|
|
|
|
|
I have the following method to capture image from a window it works ok but today it save the same image to disk every times called. Please help me! I cannot understand what is the problem.
_______________________________________________
public void GetWindowPicture(IntPtr hWnd)
{
IntPtr hdcDest = default(IntPtr);
IntPtr hdcSrc = default(IntPtr);
RECT r = new RECT();
int w = 0;
int h = 0;
GetWindowRect(hWnd, ref r);
w = r.Right - r.Left;
h = r.Bottom - r.Top;
Bitmap bm = new Bitmap(w, h);
Graphics g = Graphics.FromImage(bm);
hdcSrc = GetWindowDC(hWnd);
hdcDest = g.GetHdc();
BitBlt(hdcDest, 0, 0, w, h, hdcSrc, 0, 0, SRCCOPY);
g.ReleaseHdc(hdcDest);
ReleaseDC(hWnd, hdcSrc);
bm.Save(GetOutputInfo(),System.Drawing.Imaging.ImageFormat.Jpeg);
}
_____________________________________
Thanks for your attention,
|
|
|
|
|
This doesn't really look like a COM problem,...but, copying the same image every time is probably because the HWND is the same every time.
Give us some context as to where in an application this code is being executed.
|
|
|
|
|
Hello All,
I tried to register simpleui5.ocx control in system32 from command prompt but not able to and i came across with the error LoadLibrary("c:\windows\system32\simpleui5.ocx") failed - invalid access memory location.
Can any buddy tell me how do i successfully register this active x control?
Best regards,
Ghaffar
I am an intermediate in this fantastic filed of science. I want to gain knowledge from profesionals of high caliber & Offcourse I want to share with other.
|
|
|
|
|
Did u checked the registry whether this OCX is already registered.
if it is the, Unregister and register once more.
And check whether the same error is occuring?
Величие не Бога может быть недооценена.
|
|
|
|
|
I am sorry my pool English.
I would like to filter the URL address by sink the IWebBrowser interface of current IE. first I get the current IE's IWebBrowser Interface, And the IConnectionPoint interface. but There is error when I connect with function "Advise".
this is my code:
// Get IE
BOOL EnumIE(HWND hWnd)
{
CoInitialize(NULL);
SHDocVw::IShellWindowsPtr spShWinds;
if (FAILED(spShWinds.CreateInstance(__uuidof(SHDocVw::ShellWindows))))
{
return FALSE;
}
long nCount = spShWinds->GetCount();
for (int n = 0; n < nCount; n++)
{
IDispatchPtr spDisp;
_variant_t var = (long)n;
spDisp = spShWinds->Item(var);
SHDocVw::IWebBrowser2Ptr spBrowser(spDisp);
if (spBrowser != NULL)
{
HWND hProcHwnd = NULL;
spBrowser->get_HWND((long*)&hProcHwnd);
if (hProcHwnd == hWnd)
{
ConnectIE(spBrowser); // connect the IE
}
}
}
return TRUE;
}
// connect current IE
void ConnectIE(IUnknown *pUnkSite) // 连接IE接口
{
HRESULT hr;
IWebBrowser2 *pSite; // the currently set site
if (pUnkSite)
pUnkSite->AddRef();
hr = pUnkSite->QueryInterface(IID_IWebBrowser2, (void**)&pSite);
pUnkSite->Release();
if (FAILED(hr))
return;
IConnectionPointContainer* pCPC;
IConnectionPoint *pCP;
hr = pSite->QueryInterface(IID_IConnectionPointContainer, (void**)&pCPC);
if (FAILED(hr))
return;
hr = pCPC->FindConnectionPoint(DIID_DWebBrowserEvents2,&pCP); // 得到连接点
if (FAILED(hr))
{
pCPC->Release();
return;
}
CComPtr<iunknown>> spUnk; //得到接受器接口
CSink theSink;
DWORD m_dwCookie;
theSink.QueryInterface(IID_IUnknown, (LPVOID *)&spUnk);
hr = pCP->Advise(spUnk, &m_dwCookie); // 建立连接 注意: 此处会失败。
// here will be fail. return hr = 0x80004000
if (FAILED(hr))
return;
}
this is my sink class:
// sink.h
class CSink: public IDispatch
{
public:
CSink();
virtual ~CSink();
// IUnknown
STDMETHOD(QueryInterface)(const struct _GUID &iid,void ** ppv);
ULONG __stdcall AddRef(void);
ULONG __stdcall Release(void);
// IDispatch
STDMETHOD(GetTypeInfoCount)(unsigned int *);
STDMETHOD(GetTypeInfo)(unsigned int,unsigned long,struct ITypeInfo ** );
STDMETHOD(GetIDsOfNames)(const struct _GUID &,unsigned short ** ,unsigned int,unsigned long,long *);
STDMETHOD(Invoke)(long dispID,const struct _GUID &,unsigned long,unsigned short,struct tagDISPPARAMS * pParams,struct tagVARIANT *,struct tagEXCEPINFO *,unsigned int *);
STDMETHODIMP SetSite(IUnknown *pUnkSite);
private:
DWORD m_dwCookie; // 连接的 cookie
};
// sink.cpp
CSink::CSink()
{
}
CSink::~CSink()
{
}
// STDMETHODIMP 是宏,等价于 long __stdcall
STDMETHODIMP CSink::QueryInterface(const struct _GUID &iid,void ** ppv)
{
*ppv=this;
return S_OK;
}
ULONG __stdcall CSink::AddRef(void)
{ return 1; }
ULONG __stdcall CSink::Release(void)
{ return 0; }
STDMETHODIMP CSink::GetTypeInfoCount(unsigned int *)
{ return E_NOTIMPL; }
STDMETHODIMP CSink::GetTypeInfo(unsigned int,unsigned long,struct ITypeInfo ** )
{ return E_NOTIMPL; }
STDMETHODIMP CSink::GetIDsOfNames(const struct _GUID &,unsigned short ** ,unsigned int,unsigned long,long *)
{ return E_NOTIMPL; }
STDMETHODIMP CSink::Invoke(
long dispID,
const struct _GUID &,
unsigned long,
unsigned short,
struct tagDISPPARAMS * pParams,
struct tagVARIANT *,
struct tagEXCEPINFO *,
unsigned int *)
{
switch(dispID)
{
case DISPID_BEFORENAVIGATE2:
MessageBox(NULL, "Filter", "HAHA", MB_OK);
break;
default:
break;
}
return S_OK;
}
Hope to get help, Thank you.
|
|
|
|
|
Hi Guys,
I have 32-bit ocx which i am trying to register using regsvr32 command on 64-bit vista operating system. I am getting the message that registration is successful but later when i am launching my application , exe fails to load the OCX.
Can anybody knows how to solve this problem?
|
|
|
|
|
Is your application 64bit?
|
|
|
|
|
|
Could someone point me in the direction of any information on how to do error handling using HRESULT ?
I'm not sure about OR -ing values with masks and I don't quite understand bit-wise operations on HRESULT data types.
I read things like "C" is left empty for Microsoft errors but set to a value for user defined errors. How exactly do I set a value to the 0x20000000th bit of a HRESULT data type value?
Any help greatly appreciated.
Almost, but not quite, entirely unlike... me...
|
|
|
|
|
Firstly note that there are multiple success and failure code. If you're only interested in failure or success (and not the type of failure or success) then you can use the FAILED and SUCCEEDED macros:
HRESULT hr = pObj->SomeMethod();
if (FAILED(hr))
{
}
if (SUCCEEDED(hr))
{
}
A HRESULT is made from a number of components. The easiest way to create one from its component parts is with the MAKE_HRESULT[^] macro.
To make a user defined error code to be returned from a COM interface you'd do something like this (MS recommends error values in the range 0x0200 to 0xffff):
MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x200)
The structure of a HRESULT is shown here[^].
Some more information is here[^].
Steve
|
|
|
|