|
Then just call into and retrieve the computation results from the C modules from C++.NET, and display the results in C++.NET as stated above. No need to "retrofit" the C. Just make sure the C prototypes are visible to the C++ portions and away you go.
|
|
|
|
|
That should be the case but I am getting a link-time error from the C object module that SHOWME (called from C but coded as function in cpp) is an unresolved external.
public:
void __cdecl showme(int thenum)
{
MessageBox::Show(S"abc", S"Result...");
}
Should I have declared the function differently so that C can see it?
I appreciate any help you can give.
Don
|
|
|
|
|
First, that showme should be in your C++ and doesn't need the __cdecl . Second, you have to declare the prototype for the C function you'll be calling to get that int result from.
|
|
|
|
|
I've gotten past this problem.
Thanks to all
Don
|
|
|
|
|
Hi all,
I have created a DLL from some C++ code (to call from my C# app).
The DLL creates and writes to a couple of files.
However, it writes them to the folder last used by the C# app.
1. Why? (Less important)
2. How do I specify where to write the file, relative to the DLL file. (More Important)
Thanks in advance for any suggestions/hints.
J
---
|
|
|
|
|
It'll write to a relative path to the EntryAssembly's Working Folder. To find out what that is, use Environment.CurrentDirectory Property. If you want the path relative to the DLL itself (excuse the C# throughout, it was faster to type -- the C++ is very similar):
string baseDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
If you have a bare file name/relative path, relativeFileName , you can construct a full path to the file with the above baseDirectory thus:
string filePath = Path.Combine(baseDirectory, relativeFileName);
|
|
|
|
|
Thanks Ian,
I'm just setting the directory using
Environment.CurrentDirectory and string filePath = Path.Combine(baseDirectory, relativeFileName);
before I run the DLL - saves me from editing the DLL, and is easier to keep track of.
Thanks again, J
---
|
|
|
|
|
I need to implement a timer, so I copied the example from the help screen, and pasted it into a new .net console application. When I try to build it I get the following error message:
.....\mytimer.cpp(22): error C2061: syntax error : identifier 'ElapsedEventArgs'
What am I missing???
// This is the main project file for VC++ application project
// generated using an Application Wizard.
#include "stdafx.h"
#using <mscorlib.dll>
using namespace System;
// the following is from sdk help
__gc class Timer1
{
public:
static void Main() {
System::Timers::Timer* aTimer = new System::Timers::Timer;
aTimer->Elapsed += new ElapsedEventHandler(0, Timer1::OnTimedEvent);
// Set the Interval to 5 seconds.
aTimer->Interval=5000;
aTimer->Enabled=true;
}
private:
// Specify what you want to happen when the Elapsed event is raised.
static void OnTimedEvent(Object* source, ElapsedEventArgs* e)
{
Console::WriteLine(S"Hello World!");
// aTimer->Enabled=true;
}
};
int _tmain()
{
Timer1::Main();
Console::WriteLine(S"Press \'q\' to quit the sample.");
while(Console::Read()!='q');
return 0;
}
|
|
|
|
|
on the line with #using..., the code has #using mscorlib.dll, but somehow didn't paste correct...
|
|
|
|
|
Hello guys,
I'm a newbee in .NET programming. Haven spent the last 4 months working with C#.NET. I want to have a feel of Managed C++ like the big boys do. Links to "very good" free e-books will be highly appreciated.
Thanks 4 always being there sirs.
...the mind is not a vessel to be filled but a fire to ignited
|
|
|
|
|
try to use eMule and search for Thinking in C++. There are few pdfs available. Autor was invertor of C++.
Pain is a weakness living the body
|
|
|
|
|
How to write the blinking word in colour?
for e.g Invalid Password in yellow bold + blinking.
thanks
|
|
|
|
|
Setup a timer and enable it if the password is invalid -- and when it's Tick event fires, change the foreground color appropriately
|
|
|
|
|
how to write code like that? i have no idea what to write...
|
|
|
|
|
Check out the System.Windows.Forms.Timer class.
Basically, you'd set up a handler for the Tick event to do the foreground color switching for you.
Set a decent Interval, like 1000 for one second, on the Timer.
When you need to blink, call Start. When you're done blinking, call Stop.
|
|
|
|
|
I would like to have a function return a reference to a managed array. I would also like to be able to supply it as a parameter to another function. Is this possible? Something like this:
<code>
int anArray __gc[];
int getArray () __gc[];
int getArray () __gc[]
{
return anArray;
}
void processArray( int arrayRef __gc[] )
{
// do something to anArray through arrayRef
}
...
processArray( getArray() );
</code>
|
|
|
|
|
Ok, here is something more specific...
I have a class, class1, that contains 2 arrays. Let's call them array1 and array2. I am instantiating 3 objects of another class, class2, from class1. To the first two, I am passing array1 to the constructor, and to the third, I am passing array2. I would like to have these three new objects hold a reference to the arrays in the main class instead of holding their own copy. So in the constructor I'd like to do something like:
Class2( int arrayRef __gc[] ) {
this->arrayRef= &arrayRef;
}
or maybe:
Class2( int (*arrayRef) __gc[] ) {
this->arrayRef= arrayRef;
}
Either way, when I try to declare an array pointer in the header file of class2 like:
int (*arrayRef) __gc[];
I get the following compile error:
"cannot declare interior __gc pointer or reference as a member of class2"
So, I'm thinking it is not even possible to have a class hold a private reference to an array of another class. Is there some way to do this?
|
|
|
|
|
If you want to have an array of integers in a managed class, you would normally do something like this:
__gc class MyClass
{
private:
int myArray[];
public:
int* getArray()
{
return myArray;
}
};
You don't need to specify everything as __gc. If your class is already managed, its members are managed automatically.
|
|
|
|
|
hi there,
just a simple, maybe stupid, question:
is there a way i can convert a managed C++ project to an unmanaged /native one? like making something using Windows.Forms and then converting it to the winapi form? i guess there isnt as the managed project as to call the methods from assemblies, but im asking anyway.
the reason for this is that building managed applications is great as it reduces the production time and increases produtivity, but not everybody as the .NET framework installed so its hard to distribuit the application.
thanks a lot, and sorry for the poor english.
|
|
|
|
|
Hi there!
I would like to make a dll that will make the bridge with an traditional dll. The idea is to produce a new object (managed one) that makes the intrepretation from .net to old vc++ and back to .net.
I'm completly new to this things, so I would like to know where can I look to see samples, or to get the start knowledge to do this task.
Thanks in advance.
António
|
|
|
|
|
Check out Consuming Unmanaged DLL Functions.
Basically, you'd write a managed wrapper to the unmanaged old VC++ dll, which calls the unmanaged functions via Interop on behalf of the managed code consuming your wrapper.
|
|
|
|
|
Hi!
Let me thank you for your time - first things first
For what I've seen, I'll have to use the old dll via dll functions. Is that so?
Because, the dll is an MFC extension dll, and it has only classes, not a single direct function...
I'm just asking before start the hard work...
Thanks again!
António
|
|
|
|
|
Alas, you may only be able to consume unmanaged classes that are exposed via COM, unless you write a secondary wrapper DLL which contains unmanaged functions that instantiate and call the unmanaged classes for you.
You can pass fixed layout structures back and forth, but I don't believe you can pass classes themselves and be able to call methods on them, unless they're exposed by COM. (Someone correct me if I'm wrong!)
|
|
|
|
|
I was doin a reserach on LCE in enterprise services. Actually it's a great feature. One of the key areas I researched was the threading modal, when executing the LCE components. What i noticed was, when a publisher component invokes a method in the eventclass, the subscribers implementation is called by the same thread as the publisher's thread. What do you think if we can do an enhansment to the COM+ event system to queue the request to the thread pool. So it will not block the publisher if he has any subscribers. Give me your ideas please...
|
|
|
|
|
how do i write a code for maintaining a linked list of geometrical shapes i. e. circle ,point ,line, curve, etc.
shekhar
|
|
|
|