|
That probably means that SafeArray initialization was wrong on the C++ (client) side. How do you perform that task?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
SAFEARRAY* CreateASafeArray()
{
USES_CONVERSION;
char buffer[20];
HRESULT hr= S_OK;
SAFEARRAY *pSA;
SAFEARRAYBOUND aDim[1];
aDim[0].lLbound= 0;
aDim[0].cElements= 10;
pSA= SafeArrayCreate(VT_VARIANT,1,aDim);
if (pSA != NULL) {
long aLong[1];
for (long l= aDim[0].lLbound; l< (long)(aDim[0].cElements + aDim[0].lLbound); l++) {
VARIANT vOut;
VariantInit(&vOut);
vOut.vt= VT_BSTR;
_ltoa_s(l,buffer,10);
vOut.bstrVal= ::SysAllocString(A2W(buffer));
aLong[0]= l;
if (hr= SafeArrayPutElement(pSA, aLong, &vOut)) {
VariantClear(&vOut);
SafeArrayDestroy(pSA);
return NULL;
}
VariantClear(&vOut);
}
}
return pSA;
SafeArrayDestroy(pSA);
}
void CaxDlg::OnBnClickedButton1()
{
SAFEARRAY *pSA3 = CreateASafeArray ();
}
Regards,
Mike
|
|
|
|
|
Hello Michael,
Your VB object method f1 declared arr1() as of type "string".
Your CreateASafeArray() C++ function declared the SAFERRAY as holding elements of type VT_VARIANT.
This is the problem : VT_VARIANT type is not a string. VT_BSTR is.
To resolve the problem, either :
1. Change the signature of f1 to :
Public Function f1(ByRef arr1() As Variant, ByRef arr2() As Double) As String()
ShowList arr1
End Function
or
2. Change the call to CreateSafeArray() in CreateASafeArray() function to :
pSA= SafeArrayCreate(VT_BSTR,1,aDim); // create a 1D SafeArray of VARIANTS
and then make the appropriate changes to the rest of the code in CreateASafeArray().
Hope the above suggestions will help you.
Best Regards,
Bio.
|
|
|
|
|
Bio.,
Your second piece of advice allowed the string array to be read correctly. Thank you.
Regards,
Mike
modified on Thursday, January 10, 2008 11:52:12 AM
|
|
|
|
|
Congratulations, Michael. Best wishes to your project.
- Bio.
|
|
|
|
|
Hi !
Can anybody help me with this error below ?
I try to use MSSOAPLib30.SoapReader30Class.LoadWithParser to send request to an Apache Java Web Service and that Web Service will return documents.
When I tried to call LoadWithParser, it throws an error.
It works just fine before my computer did an automatic update and restart the computer.
After restarting the computer, the code always throw an error below
The specified module could not be found. (Exception from HRESULT: 0x8007007E)
at MSSOAPLib30.SoapReader30Class.LoadWithParser(Object par_source, IMessageParser par_parser, String par_soapAction)
at DxServices.CorazioManagerServices.DownloadDocuments() in C:\\Documents and Settings\\user\\My Documents\\Visual Studio 2005\\Projects\\CSharpDxManager\\DxServices\\CorazioManagerServices.cs:line 14737\r\nSystem.IO.FileNotFoundException: The specified module could not be found. (Exception from HRESULT: 0x8007007E)
at MSSOAPLib30.SoapReader30Class.LoadWithParser(Object par_source, IMessageParser par_parser, String par_soapAction)
at DxServices.CorazioManagerServices.DownloadDocuments() in C:\\Documents and Settings\\user\\My Documents\\Visual Studio 2005\\Projects\\CSharpDxManager\\DxServices\\CorazioManagerServices.cs:line 14737
|
|
|
|
|
Hello all,
I am working on a project in VS 2005.
I am having a VB.NET dll that interactes with some hardware.
I am using this dll's .tlb file in VC.NET
How can I handle the events raised by the VB.NET dll in VC.NET
Pls help it is urgent.
Thanks in advance & a Happy New Year to all of you.
ritz1234
|
|
|
|
|
I have to translate c++ into c# using an activeXcontrol.
The .NET Wrapper translate all dll function into c# calls.
How can I use emtpty parameters like
c++ acontrol.h (header) code:
....
void Fun1(short par1, short par2, short par3)<br />
{ Fun1(par1, par2, par3, COptionalVariant(), COptionalVariant(), COptionalVariant()); }<br />
....
This calls Fun1 using only 3 Parameters
COptionalVaraint is defined as:
class COptionalVariant: public COleVariant<br />
{<br />
public:<br />
COptionalVariant() { vt = VT_ERROR; scode = DISP_E_PARAMNOTFOUND; }<br />
};<br />
The c# .NET wrapper only translates Fun1 with all! Parameters
What do I insert for the empty ones !
Fun1( par1, par2, par3 , null , null, ...) <br /> does not work
I cannot change the wrapper itself, its metadata
is there any c# type for Variant() like
Fun1( par1 , par2 , par3, new Variant(), .... ) ???? 
|
|
|
|
|
C++ code to stop the ejection of paper from dot matrix printer after the last printed line.
bijumon mathew
kattappana
|
|
|
|
|
This is not the Serial Port Forum.
However, IMHO that is a rather difficult task, your code must access the printer spooler and I don't know if it is even possible. Try to ask the OS/SysAdmin
or the Hardware forum.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
Hi all,
how can I track every left-click of a specific file in a shell extension?
Right-click works with ContentMenu-Handler. Should I use the IQueryInfo extension?
Thx. Jens
|
|
|
|
|
I am using CHtmlView in my Regular MFC application. I have to override registry settings for internet explorer. I want to override GetOverrideKeyPath of IDocHostUIHandler2 interface . (CHtmlView provides notification OnGetOptionKeyPath to override GetOptionKeyPath of IDocHostUIHandler interface which i do not want to use.) Since i am new to Com and ATL I feel a simple example would be better for me. PLease help.
|
|
|
|
|
When I created a project inATL/COM wizard......
First I have tried for DLL and after using EXE i.e. while creating component..
Now both the programs are running finely...
so now whts the difference internaaly in both files???
shailesh
|
|
|
|
|
|
Is that possible to register 32bit deskband DLL in Vista64? I tried regsvr32 the example from VistaSDK without success - it didn't appear in the list of toolbars on taskbar.
Thank you.
|
|
|
|
|
64 bit applications do not load 32 bit DLLs
« Superman »
|
|
|
|
|
hi friends,
1)I have designed .aspx page in which user input the values.
2)when i click the save button, after that the save button should not be visible.
3)Whatever be the design of the .aspx page with values is to be saved as pdf file.
Now My problem starts from here,
I have used itextsharp.dll for creation of pdf files at runtime in asp.net but i don't know how to solve this problem with the help of itextsharp.
i have used many dlls which can be used for .aspx to .pdf conversion on fly but they are not working properly. For Example:PDFizers,ABC pdf,Ntidy,Ghtmldoc.exe etc....
what they all do is converting simple pages to pdf........
but this is complex page containing images and all that........
as per my knowledge about itextsharp.dll, it create pdf file but the designing of the page is not possible with this..(if i am wrong then correct me..)
so what i have to do tell me about this....following is my code of creating pdf file by using itext sharp.
if any suggestion please reply,
all reply appreciated.....
thanks in advance.............
Private Sub function1()
Dim mydoc As iTextSharp.text.Document
Dim str As String
Dim a As PdfWriter
Dim ms As FileStream
cmdSave.Visible = False
str = Server.MapPath("bin\1.pdf")
mydoc = New iTextSharp.text.Document
If File.Exists(str) Then File.Delete(str)
ms = New FileStream(str, FileMode.OpenOrCreate)
mydoc.Open()
mydoc.Add(New Paragraph("123"))
mydoc.Add(New Paragraph("123"))
mydoc.Add(New Annotation("123", "123"))
mydoc.Close()
End Sub
|
|
|
|
|
Do we have an pre-requistes before creating an excel object for a windows application developed using c#?
Is there any sort of memory limitation when creating an excel object. Our application runs fine when few processes are running along with the application, however when the number of other processes are increased then an error is displayed " <b>THERE IS NOT ENOUGH MEMORY TO RUN MICROSOFT EXCEL. PLEASE CLOSE OTHER APPLICATION AND TRY AGAIN </b>". The solution to this error is a system restart, when this error occurs you cannot open any existing excel file too!
Please note that our application has needed excel objects clean up code.
What could be the cause for this error? How to resolve this?
Kindly help!
gauthee
|
|
|
|
|
|
Hi,
I am programming a COM object in C++, to be used in a Visual Basic Apllication.
I want to know if there is a way to separate the interface members with namespaces like this
Study.FramesOfReference.Series.Item()
where Study is a COM Object that contains a CoClass FramesOfReference which Contains a CoClass Series wich has a method Item()
Thank U very Much
JO
|
|
|
|
|
Ju@ncho wrote: I am programming a COM object in C++, to be used in a Visual Basic Apllication.
I want to know if there is a way to separate the interface members with namespaces like this
Study.FramesOfReference.Series.Item()
where Study is a COM Object that contains a CoClass FramesOfReference which Contains a CoClass Series wich has a method Item()
Thank U very Much
I wonder if you have your terminology right. A COM object can reasonably contain another COM object, but not a CoClass. Also, a method of a CoClass would be equivalent to a C++ static method, which I don't think COM supports either. Also neither containment of objects or CoClasses is considered a namespace.
If you are using VB.NET, there is probably a way to import COM objects into specific namespaces, even though COM doesn't really support namespaces. In both VB.NET and VB6, a COM object Study can have a property FrameOfReference, which is an object that has a property named Series, which is an object with an Item method. Is this what you were trying to say?
Nathan
|
|
|
|
|
When i said Coclass i was trying to say a COM Object or a C++ Object, so what i want to do, like you say is:
having a property Frame of Reference which is an Object that has a property named Series named Series Which is an Object with an Item Methhod , the diffulty arises when i try to use properties which are objects. Especially with IDL.
Do you know if i can use C++ objects as properties in ATL or i have to use COM objects, in that case which parameters i Have to use in the definition of the property in mi idl file?
Thank you very much
JO
|
|
|
|
|
Ju@ncho wrote: Do you know if i can use C++ objects as properties in ATL or i have to use COM objects, in that case which parameters i Have to use in the definition of the property in mi idl file?
COM objects would definitely be more apropriate. They only need to have CoClasses if you need a client to be able to create instances of them directly. Within your own code, you can create an object without a CoClass using CComObject<yourclass>::CreateInstance()</yourclass>
It is possible to use plain structures if you don't need to fully support automation. (Visual Basic can handle structures though.) You need to define your structures in the idl file, and you should give each structure type its own guid.
Nathan
|
|
|
|
|
Hello Ju@ncho,
There are two ways you can achieve your design :
1. By declaring the object properties "FramesOfReference" and "Series" as of their individual interface types (e.g. IFramesOfReference, ISeries, respectively) :
interface IStudy : IDispatch
{
[propget, id(1), helpstring("property FramesOfReference")]
HRESULT FramesOfReference([out, retval] IFramesOfReference** pVal);
[propput, id(1), helpstring("property FramesOfReference")]
HRESULT FramesOfReference([in] IFramesOfReference* newVal);
}
interface IFramesOfReference : IDispatch
{
[propget, id(1), helpstring("property Series")]
HRESULT Series([out, retval] ISeries** pVal);
[propput, id(1), helpstring("property Series")]
HRESULT Series([in] ISeries* newVal);
}
2. By delaring the object properties as of type VARIANT :
interface IStudy : IDispatch
{
[propget, id(1), helpstring("property FramesOfReference")]
HRESULT FramesOfReference([out, retval] VARIANT *pVal);
[propput, id(1), helpstring("property FramesOfReference")]
HRESULT FramesOfReference([in] VARIANT newVal);
};
interface IFramesOfReference : IDispatch
{
[propget, id(1), helpstring("property Series")]
HRESULT Series([out, retval] VARIANT *pVal);
[propput, id(1), helpstring("property Series")]
HRESULT Series([in] VARIANT newVal);
};
I have written a set of sample codes. Email me :
bio_lim_2004@yahoo.com
and I will send it to you.
Best Regards,
- Bio.
|
|
|
|
|
Quit posting the same question but with different termnology. Seen the same post in the ATL forum. But asking for ATL namespace.
|
|
|
|
|