Click here to Skip to main content
15,912,329 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: C Functions and Macros Pin
Software_Developer17-Aug-12 7:10
Software_Developer17-Aug-12 7:10 
QuestionExceptions handler question Pin
ForNow16-Aug-12 3:07
ForNow16-Aug-12 3:07 
AnswerRe: Exceptions handler question Pin
Richard MacCutchan16-Aug-12 6:59
mveRichard MacCutchan16-Aug-12 6:59 
GeneralRe: Exceptions handler question Pin
ForNow17-Aug-12 3:44
ForNow17-Aug-12 3:44 
GeneralRe: Exceptions handler question Pin
Richard MacCutchan17-Aug-12 4:53
mveRichard MacCutchan17-Aug-12 4:53 
GeneralRe: Exceptions handler question Pin
Eugen Podsypalnikov17-Aug-12 5:01
Eugen Podsypalnikov17-Aug-12 5:01 
AnswerRe: Exceptions handler question Pin
JackDingler16-Aug-12 7:59
JackDingler16-Aug-12 7:59 
QuestionCreateInstance(__uuidof(MYClass)); Pin
KeithF16-Aug-12 2:23
KeithF16-Aug-12 2:23 
Folks Quick Question:

I have a dll developed in c#, which does some interactions with a web service, this all seems to be fine. I have made the dll visible to COM. I then register the dll using regasm passing it a /codebase /tlb argument. Again all this works fine. I now get a tlb file. From here i reference the tlb in my VC6 project like so:

C++
// Import the type library.
#import "C:\\epos\\MyInterface.tlb" raw_interfaces_only
using namespace MyInterface;


Once i compile the VC++ project i get a tlh file generated, which has the following contents (edited there is much more in this file just showing what is needed here):

.tlh File generated by VC6
C++
#pragma once
#pragma pack(push, 8)

#include <comdef.h>

namespace MyInterface {
>struct __declspec(uuid("2172ffe3-3177-3e81-ac7a-9d27e11be389"))
/* dual interface */ IMyLink;
struct /* coclass */ CMyLink;

_COM_SMARTPTR_TYPEDEF(IMyLink, __uuidof(IMyLink));


I create COM earlier in the program so i have not included it in the code below.
Then i Create an instance of the c# class, to call the methods i need. Now this all works fine and i can call these methods and they work correctly.

Code in my Main.c file
C++
IMyLinkPtr iPtrMyLink; //Global Variable
IChVRspPtr iPtrCheckVRsp;	//Create the Interface to The CheckVoucher Response

void main()
{
    short blnRetVal = 0; //Set to False Initially, return value from dll

    IChVReqPtr iPtrCheckV(__uuidof(CChVReq)); //Create the Interface to The Method1 Class. This is another class in the dll

    HRESULT hrRetval= E_FAIL;
    hrRetval = iPtrMyLink.CreateInstance(__uuidof(CMyLink)); //This is the main class in the dll, a wrapper to call methods from.

//    Pass to the method the request class, a reference to the response class and a reference to the return value.
    iPtrMyLink->CallMethod1(iPtrCheckV, &iPtrCheckVRsp, &blnRetVal);
}


The problem i am having is that my program crashes after some time where the memory has grown to 32mb, which to me is quite low. The crash occurs on a CreateInstance line, not necessarily the one above but some other method i have to another .net dll. My main question is about memory, before calling this line:

C++
hrRetval = iPtrMyLink.CreateInstance(__uuidof(CMyLink));


The memory in the VC6 app is 12mb, once this line is called the memory jumps to 24mb. Is this down to loading the .net Framework and if i have another dll that does the same the memory will jump to 32mb and will crash shortly after when attempting to create an instance again. I am releasing the objects so im not sure what is going on here.

Any ideas appreciated?
AnswerRe: CreateInstance(__uuidof(MYClass)); Pin
KeithF20-Aug-12 6:06
KeithF20-Aug-12 6:06 
QuestionTreeCtrl edge not drawing when resized as part of CControlBar Pin
Phil Outram16-Aug-12 0:48
Phil Outram16-Aug-12 0:48 
AnswerSOLUTION!! Pin
Phil Outram16-Aug-12 2:06
Phil Outram16-Aug-12 2:06 
QuestionEnumprocessmodule fails Pin
Member 450808315-Aug-12 23:35
Member 450808315-Aug-12 23:35 
AnswerRe: Enumprocessmodule fails Pin
pasztorpisti15-Aug-12 23:39
pasztorpisti15-Aug-12 23:39 
AnswerRe: Enumprocessmodule fails Pin
David Crow16-Aug-12 3:59
David Crow16-Aug-12 3:59 
AnswerRe: Enumprocessmodule fails Pin
Software_Developer16-Aug-12 4:52
Software_Developer16-Aug-12 4:52 
QuestionHow can i calculate seconds value here? Pin
Le@rner15-Aug-12 21:35
Le@rner15-Aug-12 21:35 
QuestionRe: How can i calculate seconds value here? Pin
pasztorpisti15-Aug-12 22:18
pasztorpisti15-Aug-12 22:18 
AnswerRe: How can i calculate seconds value here? Pin
Le@rner15-Aug-12 22:25
Le@rner15-Aug-12 22:25 
SuggestionRe: How can i calculate seconds value here? Pin
pasztorpisti15-Aug-12 22:32
pasztorpisti15-Aug-12 22:32 
AnswerRe: How can i calculate seconds value here? Pin
Jochen Arndt16-Aug-12 1:43
professionalJochen Arndt16-Aug-12 1:43 
GeneralRe: How can i calculate seconds value here? Pin
pasztorpisti16-Aug-12 1:52
pasztorpisti16-Aug-12 1:52 
AnswerRe: How can i calculate seconds value here? Pin
Richard MacCutchan15-Aug-12 22:23
mveRichard MacCutchan15-Aug-12 22:23 
AnswerRe: How can i calculate seconds value here? Pin
pasztorpisti15-Aug-12 22:38
pasztorpisti15-Aug-12 22:38 
AnswerRe: How can i calculate seconds value here? Pin
Jochen Arndt15-Aug-12 22:49
professionalJochen Arndt15-Aug-12 22:49 
GeneralRe: How can i calculate seconds value here? Pin
Le@rner15-Aug-12 23:27
Le@rner15-Aug-12 23:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.