Hi Steve, Below is the implementation which I'm using now.... BSTR* TargetBSTR ; string *SourceStr=new string; string StrBuff; const char *CharBuff; StrBuff=*SourceStr; CharBuff=StrBuff.c_str(); *TargetBSTR = _com_util::ConvertStringToBSTR(CharBuff);
Is this what you are asking me to do??? It is working fine for me for time being... I would like to know if I'm doing any mistake. Is there any issues with it??? -Arun
agarunk
Posts
-
How to convert *string to _bstr_t and *BSTR -
How to convert *string to _bstr_t and *BSTRHi Bio, Its "
std::string*
", i.e., pointer to std string. and yes "BSTR*
" is pointer to a BSTR. -Arun -
How to convert *string to _bstr_t and *BSTRHi, I'm creating dll using VS2005 ATL project. I'm using third party SDK API's which extracts data into a *string variable. Now I'm facing problem with converting the *string to _bstr_t and *BSTR. Please guide me whether is it possible to convert *string to _bstr_t and *BSTR, if so how to do it. If possible with a sample piece of code. thanking you, Arun
-
How to use "fprintf" and "sprintf" in ATL dll creation.I don't think so because I experimented with the fresh ATL project, by adding only 3 lines of extra code of file operation consists of "fopen, fprintf and fclose". Here also I have found that "fprintf" is posing same problem. Please you can easily check it by creating simple ATL dll with a method consists of these file operation lines. And we should use that method in C#. It 'll definately throw the same error. Regards, Arun
-
How to use "fprintf" and "sprintf" in ATL dll creation.Hi all, I'm developing ATL dll which will be used in C#. But I have done many things so far now I have to use either file operation (say fprintf) or string operations ("sprintf"). I have tried to do it as in the usuall fashion(like in normal exe) but when I'm calling the methods containing "fprintf or sprintf" in C# project it'll start throwing following error. ........................................ Debug Assertion Failed! "location\system32\inetsrv\w3wp.exe" File:sprintf.c Line:55 Expression: (str != NU.LL) ............................................ when I hit retry i'll get the following messege The server threw an exception. (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT)) ................................................... As per me its not the right way to use fprintf/sprintf in ATL dlls I guess. You can test it by creating simple ATL dll project and placing file operation including fprintf/sprintf, and calling the method in C#. plzzzzz guide me to come over it. Thanks, Arun
-
Getting debug Assertion failed messegeI'm writing dll and using it in C# so I cant put the break point. That is main problem to trace out.
-
Getting debug Assertion failed messegeBut it is creating the file in the "fopen" statement. Ok incase as you said if it is doing so then what is the solution for that. What I'm supposed to do on that case.
-
Getting debug Assertion failed messegeThanks. I tried it but didnt solve the problem. I refered in some other atricles and I think it might happening because of default debugging output directory. What do you think???
-
Getting debug Assertion failed messegeThanks. I tried that too but didn't work either.
-
Getting debug Assertion failed messegeYes I agree with you, but what exactly I'm supposed to do now. Please tell me if you are having some other alternatives or proper approach to tackle this. If possible with a sample piece of code. (I'm getting error in "fprintf" part of file operation though "fopen" is working properly) Thanks, Arun
-
Getting debug Assertion failed messegeNo I'm not making use of c_str(). Please let me know if it is required to take someother way to get this thing done. If possible with a sample piece of code. Thanking you Arun
-
Getting debug Assertion failed messegeAs per me yes it is. Is there something I need to takecare about that??? Its just a File pointer. Its creating empty file but while coming to "fprintf" it'll throw the error. version.message is a string. I have got lots of "fprintf" statement in the module and I checked with all of them one by one its throwing the same error as above. I'm creatin .dll using ATL in VS 2005. Regards, Arun
-
Getting debug Assertion failed messegeHi all, Im creating a .dll using ATL. Recently I have got to add the file operation part to it but as soon as I did it, it started to throw error saying : " Drawing Assertion failed Program : c:\windows........ File : fprintf.c Line :55 Expression : (str!= NULL) .................. " This is the part of code which I'm using. It works well as far as I'll keep fprintf(......); statement away. But as soon as I included that its throwing error.
STDMETHODIMP CYourClass::YourATLMethod(BSTR Filepath, BSTR* ReturnString) { _bstr_t LbstrFilepath = Filepath; XMP_VersionInfo version; SXMPMeta::GetVersionInfo ( &version ); FILE * sLogFile=fopen( "XMPLog.txt", "wb" ); ; fprintf ( sLogFile, "Version : %s\n" , version.message ); //here it is throwing errror
please guide me. where and why it is throwing error. What I'm supposed to get rid of this. Regards, Arun -
Need help to return string value from COMHi Milton, Yes, it solved my problem. Really thank u very much man. Thanking U, Arun
-
Need help to return string value from COMhello @ Roozbeh69 thanks for that solution but I have faced few problems which are listed below : I have created property using wizard but when it comes to
private: _bstr_t m_bstrTitle; // variable holding the property value and in the implementation file of your object: STDMETHODIMP CYourClass::get_Title(BSTR *pVal) { *pVal = m_bstrTitle.copy(); //troubling here return S_OK; } STDMETHODIMP CYourClass::put_Title(BSTR newVal) { m_bstrTitle = _bstr_t(newVal); //troubling here return S_OK; }
and As per me the syntax which u have given varies a lot from auto generated one. I'm using VS 2005. Once again I would like to clear what exactly I'm trying after ... I want to create a .dll using ATL. After I want to create a method inside this, which I can call from C#. This method should take Filepath(string) as input while invoking from C# and should return some string back to C#.(not pointer) Please guide me if possible with a proper working code. Thanking you, Arun -
Need help to return string value from COMI'm trying to create a .dll using ATL, which I want use in C#. Can anybody please guide me to create a simple method / function which takes string in input parameters and returns the same(string).. I tried a lot but always faced problem of returing string back to calling function in C#. I did the same with C++ class library successfully but when it comes to ATL its not the same. As I'm using other SDK API's in creation of .dll and I can't go with Class Library its having problem with "CLR and MTd". Which can't go together. Finally I decided to stick to ATL. Now please guide me to create the methods which I can use in C# to get the string value. Arun
-
Need help to return string value from COMI'm trying to create a .dll using ATL, which I want use in C#. Can anybody please guide me to create a simple method / function which takes string in input parameters and returns the same(string).. I tried a lot but always faced problem of returing string back to calling function in C#. I did the same with C++ class library successfully but when it comes to ATL its not the same. As I'm using other SDK API's in creation of .dll and I can't go with Class Library its having problem with "CLR and MTd". Which can't go together. Finally I decided to stick to ATL. Now please guide me to create the methods which I can use in C# to get the string value. Arun
-
Need help to return string value from COMI'm trying to create a .dll using ATL, which I want use in C#. Can anybody please guide me to create a simple method / function which takes string in input parameters and returns the same(string).. I tried a lot but always faced problem of returing string back to calling function in C#. I did the same with C++ class library successfully but when it comes to ATL its not the same. As I'm using other SDK API's in creation of .dll and I can't go with Class Library its having problem with "CLR and MTd". Which can't go together. Finally I decided to stick to ATL. Now please guide me to create the methods which I can use in C# to get the string value. Arun
-
Need help to return string value from COMI'm trying to create a .dll using ATL, which I want use in C#. Can anybody please guide me to create a simple method / function which takes string in input parameters and returns the same(string).. I tried a lot but always faced problem of returing string back to calling function in C#. I did the same with C++ class library successfully but when it comes to ATL its not the same. As I'm using other SDK API's in creation of .dll and I can't go with Class Library its having problem with "CLR and MTd". Which can't go together. Finally I decided to stick to ATL. Now please guide me to create the methods which I can use in C# to get the string value. Arun