|
Actually we are implementing a VC++ based application that use few COM objects, COM objects create problem when I think register them(not sure) during compilation.
So we want to replace COM objects by regular DLLs from our application.
I want to know the process that how to remove COM objects.
|
|
|
|
|
Prashant Gupta 241 wrote: So we want to replace COM objects by regular DLLs from our application.
I want to know the process that how to remove COM objects. There is no "process", you just need to rewrite the code where it makes calls to the COM interfaces, such that it uses regular function calls. I am not aware of any simplified method of doing this.
Use the best guess
|
|
|
|
|
Thank Richard
I have one more question
How to identify whether a module is dll or COM objects, so that we can easily identify and remove it.
its little bit confusing for us.
|
|
|
|
|
Prashant Gupta 241 wrote: How to identify whether a module is dll or COM objects Look at the documentation or source code. Although, you should know that from the implementation in your project.
Use the best guess
|
|
|
|
|
use inportt and outport commands
|
|
|
|
|
How to use that command I want to remove it from my code.
|
|
|
|
|
I am very very new to c++. I have been allowed lol to be a part of this c++ project. I am supposed to write a c++ dll that will export to c#. Anyways I am having trouble with class variables in functions that are exported. Could someone help me pleaser with this. Fyi we are using qt framework so that's why you see a few qt things. Basically it is crashing if I access a class variable which in this case is called testInt. this is not the actual code we are working with but it does duplicate the problem exactly as it occurs in the real code. The problem is my c# code crashes when the variable testInt is accessed but not if testInt2 is accessed.
header
#ifndef QTDDLLTESTCLASSVARIABLE_H
#define QTDDLLTESTCLASSVARIABLE_H
#include "qtddlltestclassvariable_global.h"
class QTDDLLTESTCLASSVARIABLE_EXPORT qtdDllTestClassVariable
{
public:
qtdDllTestClassVariable();
~qtdDllTestClassVariable();
void Test();
int testInt;
private:
};
#endif // QTDDLLTESTCLASSVARIABLE_H
#include "qtddlltestclassvariable.h"
#include <qDebug>
cpp file
qtdDllTestClassVariable::qtdDllTestClassVariable()
{
}
qtdDllTestClassVariable::~qtdDllTestClassVariable()
{
}
void qtdDllTestClassVariable::Test()
{
qDebug() << "started";
testInt = 5;
int testInt2 = 5;
qDebug() << testInt << " after int";
qDebug() << testInt2 << " after int2";
}
c# code
[DllImport(@"..\..\..\Win32\Debug\qtdDllTestClassVariable.dll", CharSet = CharSet.Unicode, EntryPoint = "?Test@qtdDllTestClassVariable@@QAEXXZ")]
public static extern void Test();
modified 1-Jun-13 15:51pm.
|
|
|
|
|
Using DLL Export you can export your C/C++ variables and functions to make them available. However, you can not just export an entire class and use it in C#.
The direct problem here is that you are accessing a member function (Test) without an instance of your test-class being created.
Probably the best way to interface in a class based manner between C++ and C# is to use COM; that is, create a COM class in C++, export it, and then use the COM class in C#.
|
|
|
|
|
Hi all,
I have been trying to write encrypt and decrypt functions whose signatures require the input and the output strings to be in 'void*' type only. The code works fine if the inputs can be specified as IBuffer^ but in the other case the source string and the encrypted->decrypted string do not match. I've googled a lot but to no good. Please help...it's urgent.
IBuffer^ byteArrayToIBufferPtr(byte *source, int size)
{
Platform::ArrayReference<uint8> blobArray(source, size);
IBuffer ^buffer = CryptographicBuffer::CreateFromByteArray(blobArray);
return buffer;
}
byte* IBufferPtrToByteArray(IBuffer ^buffer)
{
Array<unsigned char,1U> ^platArray = ref new Array<unsigned char,1U>(256);
CryptographicBuffer::CopyToByteArray(buffer,&platArray);
byte *dest = platArray->Data;
return dest;
}
int DataEncryption::encryptData(EncryptionAlgorithm algo, int keySize, void* srcData, const unsigned int srcSize,
void*& encData, unsigned int& encSize)
{
LOG_D(TAG, "encryptData()");
if(srcData == nullptr)
{
LOG_E(TAG,"");
return DataEncryption::RESULT_EMPTY_DATA_ERROR;
}
if(srcSize == 0)
{
LOG_E(TAG,"");
return DataEncryption::RESULT_SIZE_ZERO_ERROR;
}
IBuffer^ encrypted;
IBuffer^ buffer;
IBuffer^ iv = nullptr;
String^ algName;
bool cbc = false;
switch (algo)
{
case DataEncryption::ENC_DEFAULT:
algName = "AES_CBC";
cbc = true;
break;
default:
break;
}
SymmetricKeyAlgorithmProvider^ Algorithm = SymmetricKeyAlgorithmProvider::OpenAlgorithm(algName);
IBuffer^ keymaterial = CryptographicBuffer::GenerateRandom((keySize + 7) / 8);
CryptographicKey^ key;
try
{
key = Algorithm->CreateSymmetricKey(keymaterial);
}
catch(InvalidArgumentException^ e)
{
LOG_E(TAG,"encryptData(): Could not create key.");
return DataEncryption::RESULT_ERROR;
}
if (cbc)
iv = CryptographicBuffer::GenerateRandom(Algorithm->BlockLength);
IBuffer ^srcDataBuffer = byteArrayToIBufferPtr(static_cast<byte*>(srcData),256);
encrypted = CryptographicEngine::Encrypt(key, srcDataBuffer, iv);
byte *bb = IBufferPtrToByteArray(encrypted);
encData = IBufferPtrToByteArray(encrypted);
encSize = encrypted->Length;
return DataEncryption::RESULT_SUCCESS;
}
int DataEncryption::decryptData(EncryptionAlgorithm algo, int keySize, void* encData, const unsigned int encSize,
void*& decData, unsigned int& decSize)
{
LOG_D(TAG, "decryptData()");
if(encData == nullptr)
{
LOG_E(TAG,"");
return DataEncryption::RESULT_EMPTY_DATA_ERROR;
}
if(encSize == 0)
{
LOG_E(TAG,"");
return DataEncryption::RESULT_SIZE_ZERO_ERROR;
}
IBuffer^ encrypted;
IBuffer^ decrypted;
IBuffer^ iv = nullptr;
String^ algName;
bool cbc = false;
switch (algo)
{
case DataEncryption::ENC_DEFAULT:
algName = "AES_CBC";
cbc = true;
break;
default:
break;
}
SymmetricKeyAlgorithmProvider^ Algorithm = SymmetricKeyAlgorithmProvider::OpenAlgorithm(algName);
IBuffer^ keymaterial = CryptographicBuffer::GenerateRandom((keySize + 7) / 8);
CryptographicKey^ key;
try
{
key = Algorithm->CreateSymmetricKey(keymaterial);
}
catch(InvalidArgumentException^ e)
{
LOG_E(TAG,"encryptData(): Could not create key.");
return DataEncryption::RESULT_ERROR;
}
if (cbc)
iv = CryptographicBuffer::GenerateRandom(Algorithm->BlockLength);
byte *cc = static_cast<byte*>(encData);
IBuffer ^encDataBuffer = byteArrayToIBufferPtr(cc,256);
decrypted = CryptographicEngine::Decrypt(key, encDataBuffer, iv);
byte *bb = IBufferPtrToByteArray(decrypted);
decData = IBufferPtrToByteArray(decrypted);
decSize = decrypted->Length;
return DataEncryption::RESULT_SUCCESS;
}
|
|
|
|
|
You need to provide more information about the problem, what does not work, and which lines of code are giving the problem.
Use the best guess
|
|
|
|
|
Hi Richards,
Thanks for your response. I found the problem. First let me describe the issue: Suppose my source string(say 'pData') is "SampleTextSample" and I encrypt it using encryptData() which stores the encrypted string in 'encryptedData'(suppose). Then I call decryptData() with 'encryptedData' as the input and in turn decryptData() stores the decrypted string in 'decryptedData'(suppose). Now logically, pData and decryptedData should be equal. But this is not happenning in my code.
Error: Using CryptographicBuffer::GenerateRandom() for creating key and initialazation vector in both encryptData() and decryptData(). Thus I am using a different key and initialization vector in encryptData() and another key and initialization vector in decryptData(). Hence the results don't match.
Solution: Arranged to use the same key in both encryptData() and decryptData().
|
|
|
|
|
yourchandrashekhar@gmail.com wrote: and another key and initialization vector in decryptData(). Why would you expect it to work with different keys?
Use the best guess
|
|
|
|
|
I have VisualC++ Ver 5. I know it's old but I have been using it for close to 20 years.
My problem is that when running in debug mode on WinXP VC++ crashes often.
When running on Win2K it runs for hours without problems.
Is there something I should know avout running VC++ on a WinXP computer.
Bob Macklin
Seattle, Wa
|
|
|
|
|
Try to run in Windows 2000 compatibility mode. First thing that comes to mind
|
|
|
|
|
I am using Visual Studio 2008 on a Windows 7 machine to generate a utility to validate TMATS and Chapter 10 file. These are standardized files used in telemetry systems. The files begin with a text based description of the data (7 bit ASCII) followed by large amounts of telemetry data in binary format. The binary data will not be shown, but there are some validation checks to be done.
In the text based preamble there are about ten different major sections, some rather long. Each section describes some aspect of the data. The basic format is an identifier that ends with a colon, followed by text that ends with a semicolon. The next identifier follows.
My plan is a separate dialog or window for each. The user will be able to edit the data and write out to a new file.
I am unsure as to the best solution type. So far I am leaning towards an MFC application with single document support. (Only one file will be open for reading only, and a new file optionally opened for writing.) The next best option seems to be with Dialog support. Or maybe someone will suggest something else completely.
This will be open source code posted on my web site for others in the telemetry industry to use and comment on. I plan to make all the classes and code as simple as I can so it can be ported to other systems. But I will not go to extreme lengths for portability.
I am fairly good at writing code, but on the lower end of intermediate for Visual Studio.
Pleas make your suggestions.
Thanks for your time
If you work with telemetry, please check this bulletin board: http://www.bkelly.ws/irig_106/
|
|
|
|
|
bkelly13 wrote: classes and code as simple as I can so it can be ported to other systems
hmm, I think that rules out MFC ..
Seriously .. I would first abstract out what you need to do with a file, to get your sections etc - this might be one class or dll ..then I'd look at the UI - why dont you grab a copy of balsamiq for example and mock up possible UI's - or even resort to plain pencil and paper sketches
Once you've got the abstraction/logical stuff on paper, then worry about what you're going to build it in
'g'
|
|
|
|
|
Hello Garth,
Yes, I have a pretty darn good idea of how I want the data displayed. I have done a lot of thinking on this project. If you think the desire for portability rules out MFC, then what does it rule in?
Thanks for your time
If you work with telemetry, please check this bulletin board: http://www.bkelly.ws/irig_106/
|
|
|
|
|
well, depends on 'how much portability' - I thought of 'Qt' and C#/Mono first off .. if you go the C#/Mono route I think that gives you winforms on linux (Mono)
'g'
|
|
|
|
|
I have visual studio and home and at work, but neither of the suggestions you made. What would you recommend within VS?
Thanks for your time
If you work with telemetry, please check this bulletin board: http://www.bkelly.ws/irig_106/
|
|
|
|
|
|
VS for Visual Studio
We have only Windows where I work. I do not expect the code to simply compile and run on other operating systems. I just want to ease the task a bit for someone that might want to do that.
So which Visual Studio Template do you suggest for this project?
Thanks for your time
If you work with telemetry, please check this bulletin board: http://www.bkelly.ws/irig_106/
|
|
|
|
|
nooo .. you dont say
I think if you stick with a pure VS/Microsoft environment, your portability options are limited, again, depending on 'what portability' you want .. what I was thinking of with the Mono stuff is, and I'd need to check, it allows you to have pretty well one code-base - you'd just have to compile it for mono on the Linux platform
Why not write it in VS/MFC now, the core functionality (ie, not the display stuff) can be separated out into its own layer, and then consider where else/what else (if ??)you need it to run on...
There are 'Open IDE's for c, c++ iirc, that work with VS compiler, GCC etc (although the name of one eludes me right at this second)
|
|
|
|
|
Re: nooo ... you dont say.
Re: Re: not sure about the 'within vs'
That sounded to me like you did not know what I intended with "vs." I did not mean to be sarcastic or anything.
Within MFC: I read about the various options: multi document, single document, and dialog in the help file, but it was really not very informative. Single document and multi document both provide a window with File open menus and the such already added. Dialog does not have that, but it "appears to be" a much simpler project. I only need to have one document open at a time.
Keeping this simple: There are about ten sections to a TMATS header. To make it simple for the reader I want to put the data for each major section in a separate dialog/window/(or some silly entity).
So which MFC option would you take?
Thanks for your time
If you work with telemetry, please check this bulletin board: http://www.bkelly.ws/irig_106/
|
|
|
|
|
I would probably go Dialog, or Single document,
thought 1 : a tab bar, each tab being a section/TMATS header
thought 2 : 2 'panes' - left hand 'pane' is a tree structure (or listbox ?) of the file sections, when clicked upon, the TMATS header is displayed in detail on the right hand 'pane'
|
|
|
|
|
This is really helpful for me. I would not have thought of either one. If I google each will I find a good description?
I think the multiple tabs would be easier, but the split pane concept (kind of like Windows Explorer?) would also be cool. What is the approximate work effort for each? Maybe on a one to ten scale? I don't really care what the ten on that scale really means, just a comparison between the two. Maybe assign ten to the more difficult one and assign something less than ten to the easier one.
Thanks for your time
If you work with telemetry, please check this bulletin board: http://www.bkelly.ws/irig_106/
|
|
|
|