|
FYI: Going forward Please Post all C++/CLI/Managed C++ queries under "(Managed) C++/CLI" forum. This is not a .Net forum.
Hope your C# module is an assebly/dll and not an exe/application.
If it is an assembly then you can use #using to include the C# dll into your code.
Then use the namespace declaration and create the class instance.
declaration part:
<br />
#using <csharpassebly.dll> <br />
using namespace csharpassebly::mycomponents; class instantiation:
CMyCSharpClass* objCMyCSharpClass = gcnew CMyCSharpClass();<br />
objCMyCSharpClass->method1();
If you c# module is an exe/application, then it is a diffrent story: use System.Diagnostic.Process class to invoke the process.
cheers...milton.
|
|
|
|
|
Thanks Milton
Mine was a .EXE and i could get that application in .net by creating the process using System.Diagnostic.Process.
can you tell me the way to creat a DLL for the existing vc++ application?
Thanks and regards
|
|
|
|
|
I am trying to convert an old application (VB3, NT4, RDM4.5) to C++2005, Win2003Server and RDM7.dll(programmed with native C++). I can export the DB functions and data without problems but trying to access the data with a key, I get errors. I have been using
#include "stdio.h"
#include "vcclr.h"
using namespace System::Runtime::InteropServices;
- - - - -
[DllImport("rdm7.dll", EntryPoint = "d_keyfind", CharSet = CharSet::Ansi)...]
extern "C" int d_keyfind(long, const void *, DB_TASK *, int);
- - - - -
String ^crpt = Currtmp.ToString();
pin_ptr<const wchar_t=""> tnoptr = PtrToStringChars(crpt);
- - - - -
d_keyfind(..., tnoptr, ...)
the program compiles without errors, runs other functions correctly, but with this d-keyfind I receive a KEY_NOT_FOUND error allthough Currtmp(long) is read with other functions from a real and existing record in the data base and although the direct access facility program (programmed in native code) reads the key value correctly and returns correct data.
Could anyone perhaps see what is my error here?
Thank you in advance!
I wonder if you can easily see an error here.
Ilkka Pitkänen
|
|
|
|
|
FYI: This query is a C++/CLI category. Going forward Please Post all C++/CLI/Managed C++ queries under "(Managed) C++/CLI" forum. This is not a .Net forum.
One thing I noted is the tnoptr you are passing. If your d_keyfind is expecting an ansi char instead of a wide char, then your code needs to bechnaged. Because PtrToStringChars returns a wchar_t. If that is the case you can try the following code:
char __nogc* szCurrtmp = static_cast<char *>(Marshal::StringToHGlobalAnsi(crpt).ToPointer());<br />
d_keyfind(..., (void*)szCurrtmp, ...);<br />
Marshal::FreeHGlobal( IntPtr((void*)szCurrtmp) );<br />
return bRtn;
rgds...mil10
|
|
|
|
|
Thanks for your reply Milton!
The program obviously needs ansi as in Extern C Marshalling the entry point for d_keyfind could only be found in the DLL with charset::ansi. Up till now I did not use any unmanaged code in the test program, so I have to spend a little time with __nogc and CLR linker options.
I let you know when I have tested your code sample.
Thank you!
Ilkka Pitkänen
|
|
|
|
|
Hi!
Have done some testing now which takes me to new, maybe trivial, situation. I have two questions:
1) As I amworking with CLI managed code, compiling the definition __nogc needs the /clr::oldsyntax switch for compiling. Maybe this could be given on the command line but as I am in the beginning of programming this application I wouldn't like to do that all the time when I make small changes to the code but instead would like to use build or F7 available in the main window of VS. Now I tried to change the project properties with ' project->properties->Configuration properties->General->Common Language Runtime support ' and changing the switch to "Common Language Runtime Support, Old Syntax (/clr:oldSyntax)". Having done this and back in building the code, I receive a lot of errors like with the first managed code class definition:
: error C2470: 'ref' : looks like a function definition, but there is no parameter list; skipping apparent body
Is there not a way to accept both /clr and /clr::oldsyntax together or do I need to compile the code separately which of course would be sad for the future development of the application.
2) This brings me to the apparent next question. You used static_cast for converting the pointer to a base class to a pointer of a derived class, if I get it right. As this type of conversion is quite new for me, I wonder could there be a possibility of using dynamic_cast, which (I think) would at the same time eliminate the need for clr::oldsyntax. Is there a way of using MarshalAsAttribute leading to AnsiBStr, I tried something but with no luck.
Thankful for any answer!
|
|
|
|
|
what is the maximum length that a CString can take? Doest is have any upper limits??
|
|
|
|
|
The maximum length of CString object is INT_MAX (2147483647) .
The secret of life is not enjoyment
but education through experience.
- Swami Vivekananda.
|
|
|
|
|
namaskaaram wrote: what is the maximum length that a CString can take? Doest is have any upper limits??
around 2GB
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Hi
Please suggest HTML supporting available in Visual C/C++
thanx in advance
by
KK
KK
|
|
|
|
|
Can you be more specific
you can use CDHtmlDialog class
or ChtmlView
|
|
|
|
|
kk.in wrote: Please suggest HTML supporting available in Visual C/C++
look for IHTML* interface
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
TO understand we create a sink to html element events and 'advise' it as follows:
bool Cembrowsersink::ConnectEvents(IHTMLElement* pElem)
{
HRESULT hr;
USES_CONVERSION;
IConnectionPointContainer* pCPC = NULL;
IConnectionPoint* pCP = NULL;
DWORD dwCookie;
IUnknown* pUnk =NULL;
// Check that this is a connectable object.
AtlTrace(_T("\nCheck that this is a connectable object."));
hr = pElem->QueryInterface(IID_IConnectionPointContainer, (void**)&pCPC);
if (SUCCEEDED(hr))
{
//AtlTrace(_T("Find the connection point."));
hr = pCPC->FindConnectionPoint(DIID_HTMLElementEvents2, &pCP);
if (SUCCEEDED(hr))
{
//AtlTrace(_T("create the instance of the element sink."));
hr=m_selem->QueryInterface(IID_IUnknown,(void**)&pUnk);
if(SUCCEEDED(hr))
{
//AtlTrace(_T("Advise the connection point."));
hr = pCP->Advise(pUnk, &m_dwCookie);
if (SUCCEEDED(hr))
{
AtlTrace(_T("Successfully advised"));
}
}
pCP->Release();
}
pCPC->Release();
}
return false;
}
When we run it against the htlml element collection on GOOGLE home page ,we find that there are certain HTML elements aganst which the sink could be hooked (HTML,HEAD,TITLE,,META,,CENTER,,TBODY) while others against which no connection point interface is found like STYLE,SCRIPT,BODY,TABLE,TR,FORM,INPUT.
What's the reason?
If I want to subscribe only to the events of the 'INPUT' html elements ,how do then i do it?
|
|
|
|
|
Your code could be simplified a little by using the ATL helper functions AtlAdvise and AtlUnadvise . Also, you can use the IEnumConnectionPoints interface to get a list of all connection points supported by an object; this has saved me a few times in the past when attempting to sink events in IE.
Steve
|
|
|
|
|
Thanks.But why do the 'INPUT' elements not report any connection point interface implemented?Is it a mistake on my part of there is some reason behind it.
Do not all the HTML elements publish connection points for event notifications?
|
|
|
|
|
Perhaps it does (implement a connection point) but you're just using the wrong value in the riid argument in your call to IConnectionPointContainer::FindConnectionPoint for the element in question - this has happened to me before. Use code something like this:
void LogConnectionPoints(IUnknown *pUnk)
{
CComQIPtr<IConnectionPointContainer> spCPC(pUnk);
if (!spCPC)
{
return;
}
CComPtr<IEnumConnectionPoints> spEnumCP;
HRESULT hr = spCPC->EnumConnectionPoints(&spEnumCP);
if ( FAILED(hr) )
{
return;
}
ULONG fetched;
CComPtr<IConnectionPoint> spCP;
while ( spEnumCP->Next(1, &spCP, &fetched) == S_OK )
{
IID iid;
hr = spCP->GetConnectionInterface(&iid);
if ( SUCCEEDED(hr) )
{
}
spCP.Release();
}
}
I may have made some syntax errors: I have used code like this before with IE and it has worked but this specific piece of code is off the top of my head and not tested. Once you log all the "iid"s supported for the element in question you can try every one and see which ones work and look them up in "mshtml.idl" to get their names.
Steve
|
|
|
|
|
Hi all,
I want to save each frame from a video file(.cam).I wrote the following coding to get the image.
<br />
CFile cf;<br />
CString filename;<br />
int xu_flag;<br />
BITMAPFILEHEADER xufileheader;<br />
char * xu_sp;<br />
long outputlen;<br />
<br />
<br />
filename = "c:\\temp\\test.jpg";<br />
xufileheader.bfOffBits = 54;<br />
xufileheader.bfSize = xu_newwidth * xu_newheight * 3 + sizeof(BITMAPINFOHEADER) +sizeof(BITMAPFILEHEADER);<br />
xufileheader.bfType = 0x4d42;<br />
xu_sp = new char [xu_newwidth * xu_newheight * 3+ sizeof(BITMAPINFOHEADER) + sizeof(BITMAPFILEHEADER)];<br />
outputlen = xu_newwidth * xu_newheight * 3 + sizeof(BITMAPINFOHEADER) + sizeof(BITMAPFILEHEADER);<br />
memcpy(xu_sp, &xufileheader, sizeof(BITMAPFILEHEADER));<br />
memcpy(xu_sp + sizeof(BITMAPFILEHEADER), xu_buff, <br />
(xu_newwidth * xu_newheight * 3 + sizeof(BITMAPINFOHEADER)));<br />
xu_flag = cf.Open(filename, CFile::modeCreate | CFile::modeWrite);<br />
cf.WriteHuge(xu_sp, outputlen); <br />
cf.Close();
But my problem is,I can able to catch only one frame at a time.But i need to save all the frames.
How do i acheive this?
help me please
sunita ramesh
|
|
|
|
|
Hi Sunita
Examples on Video available in MSDN CD at \SDK\GRAPHICS\VIDEO
Try
KK
|
|
|
|
|
Maybe I'm missing something here, but jpg files aren't made to store movies. The jpg file format is only able to store one frame of image data.
You need to use another format, AVI, WMF, Quicktime, Realvideo, Tiff...if you want to store multiple frames.
On the other hand, if you save each frame to a separate jpg file then it will work, but then you'll have to deal with all those jpg's and find or make a player that can play them back in sequence.
|
|
|
|
|
Hi all,
#include <stdio.h>
void fun(void)
{
int a[2];
a[3] +=7;
}
void main()
{
int i = 5;
printf("\t %d \n\t",i);
fun();
i = 10;
printf(" %d \n\t",i);
}
Output of above program is
5
5
Why output is like this?
And it is giving Run-Time error when I use " a[2] +=7; " in the function.
Why like this?
Thanks in advance.
Aniket.
|
|
|
|
|
Aniket Salunkhe wrote: int a[2];
You are declaring an array of size 2 (int a[2]).
So it will have a zero based index i.e. 0 to 1.
This means you cannot access a[2] as that does not belong to you. You only have right to modify positions from a[0] to a[1](inclusive).
Modify anything beyond this range could lead to runtime errors and other crashes. Of course you can make the array bigger.
Nibu thomas
Software Developer
Faqs by Michael dunn
|
|
|
|
|
Hi,
I know about array size. But when I debug the code, it is skipping the next statement followed by the function call & not giving error. So I am asking that why this is happening? Why it is not showing error?
Thanks for reply.
Aniket.
|
|
|
|
|
what is it a[0]...//used without being defined
int a[3];
a[0]=a[1]=a[2]=0;
a[2] +=7;
and then output is 5 and 10
|
|
|
|
|
Hi,
If I write same Program as,
#include <stdio.h>
void main()
{
int i = 5;
printf("\t %d \n\t",i);
int a[2];
a[3] +=7;
i = 10;
printf(" %d \n\t",i);
}
Than Output is,
5
10
Why? So what is problem in that Program?
Thanks,
Aniket.
|
|
|
|
|
You are breaking the rules. Do not do this.
You say you understand arrays and indexes...then why do you insist on using a[3]?
a[3] is pointing to an area of memory that is being used by another part of the program. It might point to the actual memory being used by int i, it might be pointing to something else. It all depends on how the compiler allocates memory on the stack and in what order you have declared your variables and it's going to change everytime you edit your program.
You are not supposed to be using a[3] so don't use it!
if you create your array:
int a[2];
then you can go use a[0] and a[1], and that's it. Period, exclamation point.
|
|
|
|