|
The array class represents an array. A dynamic array would be the List class in .NET 2.0, or ArrayList in 1.1.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
That REALLY does not answer my question ... at all.
You CAN resize an array; my question is why System::Array provides 64-bit indexing even though the array size is limited to 32-bit?
|
|
|
|
|
You can ? OK, well that seems redundant to me, it obviously needs to create a new array for larger sizes anyhow.
I see what you're asking now, but it looks to me like you've found an error in the class, obviously if you can't size it to 64 bit, then the fact that the index is 64 bit is irrelevant, no two ways about it.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
You can't resize it with an Int64, but you can create one with an Int64 initially:
long size = (long)uint.MaxValue + 10;
byte[] buffer = new byte[size];
Console.WriteLine(buffer.LongLength);
It will crash because it runs out of memory in a 32bit process, but on the 64bit version of the .NET Framework it should run correctly.
|
|
|
|
|
In C++/CLI:
<br />
Int64 big = Int64(0x7FFFffffFFFF);<br />
<br />
array<String^>^ anArray = gcnew array<String^>(big);<br />
the compiler issues the following warning:
<br />
.\Main.cxx(37) : warning C4244: 'initializing' : conversion from '__int64' to 'int', possible loss of data<br />
for the line containing the gcnew statement.
|
|
|
|
|
Who knows the link to source code of matching string , such as: morris pratt, Brute force...thanks.
|
|
|
|
|
Few days ago I asked a similar question, but it seems I wasn't clear about the problem. I'll try to rephrase question in hope that it will be more clear.
I have a managed code that I would like to call from unmanaged application. This is the sample that explains the problem that I stumbled upon.
Here is a C++ dll that I would like to call:
using namespace System::Windows::Forms;
extern "C" DLL2005_API int fnDll2005(void)
{
// unmanaged Message box
::MessageBoxA(0, "unmanaged text", "unmanaged caption", 0);
// Managed message box
System::Windows::Forms::MessageBox::Show("managed text", "managed caption");
return 42;
}
--------
I am trying to call this DLL from a sample console application written in VC6:
extern "C" __declspec(dllexport) int fnDll2005(void);
int main(int argc, char* argv[])
{
fnDll2005();
return 0;
}
so far so good, everything works fine, console application calls dll and both
dialog boxes are shown, unmanaged and managed one.
Problem arises when C++ function tries to call another managed method written
in C#. Here is the C# code:
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
namespace ClassLibrary1
{
public class Class1
{
public static int ShowDialog(string sText, string sCaption)
{
System.Windows.Forms.MessageBox.Show(sText, sCaption);
return 0;
}
}
}
nothing special, a simple C# assembly, and here is the modified C++ function
that should call C# method:
using namespace System::Windows::Forms;
using namespace ClassLibrary1;
extern "C" DLL2005_API int fnDll2005(void)
{
::MessageBoxA(0, "unmanaged text", "unmanaged caption", 0);
System::Windows::Forms::MessageBox::Show("managed text", "managed caption");
ClassLibrary1::Class1::ShowDialog("class library text", "class library caption");
return 42;
}
and here's the problem. The moment that console application tries to call fnDll2005 function the program breaks with message "unhandled exception in console1.exe (KERNEL32.DLL)..."
If I compile console program with VS2005 everything works fine. I don't understand why the program breaks when I call C# code when in the first example obviously CLR was started when I called it from C++ code. Since I'm a newbie in managed world I don't know if what I am trying to do is possible at all? Is there a way to call unmanaged function (from a program written in VC6) in a DLL that would later call managed code?
Tnx in advance
Dragan
|
|
|
|
|
Im not sure but I suspect your problem is related to the cpp runtime. The cpp runtime in VS2005 is not compatible with the cpp runtime in VC6 or 2003.
Are all your c++ projects dynamically linked to the runtime library? and are both using single or multi threaded version?
Try using the dependency walker to determine which libraries are being used by each dll or exe
|
|
|
|
|
:->
CV_INLINE void* cvAlignPtr( const void* ptr, int align=32 )
{
assert( (align & (align-1)) == 0 );
return (void*)( ((size_t)ptr + align - 1) & ~(size_t)(align-1) );
}
CV_INLINE int cvAlign( int size, int align )
{
assert( (align & (align-1)) == 0 && size < INT_MAX );
return (size + align - 1) & -align;
}
|
|
|
|
|
Well, I guess the first point to make is that this is not managed C++ code.
I could explain what it's doing, but I'm not sure how much that would help. Where has the code come from ? Do you know what operators like & and ~ do ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Can someone please direct me to a tutorial and/or samples on the use of the String.Split method? (I seem to have problems translating C# help info for use with C++.)
LudwigKeck
|
|
|
|
|
String *limiter = S","; // --> The Limiter will be ,
Char delimiter[] = limiter->ToCharArray(); // --> Split-Method awaites a Char-Array
String* parts[] = 0; // --> Receives all parts
parts = line->Split(delimiter);
if line is "one,two,three" so the parts are
part[0] = "one"
part[1] = "two"
part[2] = "three"
The answer is very late, but i'm a newbie @ Code-Project ( since yesterday )
Regards
|
|
|
|
|
Thank you Baerten,
My problem was in C++, the code you show is C#. I have since worked it out the hard way (never did find any good documentation). In C++ the correct use is:
<br />
String^ data = "one,two,three";<br />
array<<Char>>^ separator = {','};<br />
array<<String^>>^ parts;<br />
parts = data->Split (separator);<br />
As you can see, C++ syntax is just a bit opaque, (there should be just single arrow symbols where I show double).
The module using this works fine for me now. However, now it causes a memory corruption in old legacy code that has worked for years. --- I'm not even sure how to describe it to forma help question. Such is life.
Thank you again, and welcome to the world inside!!
|
|
|
|
|
hi
i am looking for Wizard Control that allow to make step by step interface.cause i don't find it in the vc++ Express?
|
|
|
|
|
|
Hi everyone,
I am new here. I am using C to do simple communciations to a serial port (like opening,reading, writing to the serial port.....). I use the Dev C++ compiler for this. But the first thing I encountered is that my code doesnt compile without some headers..
1. <termios.h>
2. <bios.h> (even though its not used in the below example)
Do you guys have any idea where to get them. I searched the whole net but wasnt smart enough to find a place I can downlaod these headers.
Or are there any better header files that can be used in place of these. I am totally lost at this point. Would greatly appreciate any help.
The code is below
#include <stdio.h> /* Standard input/output definitions */
#include <string.h> /* String function definitions */
#include <unistd.h> /* UNIX standard function definitions */
#include <fcntl.h> /* File control definitions */
#include <errno.h> /* Error number definitions */
#include <termios.h> /* POSIX terminal control definitions */
#incldue <conio.h>
/*
* 'open_port()' - Open serial port 1.
*
* Returns the file descriptor on success or -1 on error.
*/
int
open_port(void)
{
int fd; /* File descriptor for the port */
fd = open("/dev/ttyS0", O_RDWR | O_NOCTTY | _NDELAY);
if (fd == -1)
{
/*
* Could not open the port.
*/
perror("open_port: Unable to open /dev/ttyS0 - ");
}
else
fcntl(fd, F_SETFL, 0);
return (fd);
}
int main ()
{ open_port();
getch();
return 0;
}
hi
|
|
|
|
|
prashw wrote: #incldue
Well, this obviously won't compile.
This is a managed C++ forum, your question is about a compiler that doesn't even support managed C++. Try the other C++ forum, and try posting some explanation of your error messages.
And also check the 'Ignore HTML tags' thing below, so that we can see all of your code.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Need an alternate code for cp command run through the system api.
Need a C code which performs the same functionality as the unix cp command provides.It should also support all the options which cp command support.
Does any one have any clue about this?
|
|
|
|
|
1 - what is the cp command
2 - what does this have to do with managed C++ ?
3 - does this mean you're going to run it on a unix system, or a Windows one ?
A google tells me that cp stands for copy. C++ has no concept of file systems, and as you've invoked Unix and posted in a MC++ forum ( which makes me cautious to jump to any conclusions ), I really need to know what system you're coding for before I can offer any API calls. Either way, no way is the Windows shell going to give you the commands that the unix shell does, exactly the same and with the exact same functionality. You'd have to write a layer.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I am running my application in unix and just wants to avoid the system api call to copy files.
|
|
|
|
|
OK - standard C++ cannot help you, it knows nothing of file systems. Any calls you make will be system API calls.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi all,
I am trying to get an event in my application when the user clicks system menu of any window. I have tried to implement this using global hooks. I have made a DLL which is installing hook in the following manner:
HINSTANCE hins;
BOOL __declspec(dllexport)__stdcall installhook()
{
hkb=SetWindowsHookEx(WH_SYSMSGFILTER,(HOOKPROC)SysMsgProc,hins,0);
//hkb=SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTProc,hins,0);
return TRUE;
}
where hins takes value from:
BOOL CHookdllApp::InitInstance ()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
hins = AfxGetInstanceHandle();
return TRUE;
}
The Callback function:
LRESULT __declspec(dllexport)__stdcall CALLBACK SysMsgProc(int nCode, WPARAM wParam, LPARAM lParam)
{
if(MSGF_MENU == nCode)
{
LPMSG msg = (LPMSG)lParam;
//if(WM_MENUSELECT == msg->message)
//if(WM_MENUCOMMAND == msg->message)
if(WM_SYSCOMMAND == msg->message)
{
OutputDebugString("\n Got it!! \n");
}
}
return CallNextHookEx( hkb, nCode, wParam, lParam );
}
In this callback function, I get the event WM_MENUSELECT from all windows but I am not getting WM_SYSCOMMAND event which I need because I want the event when user clicks the system menu of any window.
I also tried using WH_CBT, the callback function for this is:
LRESULT __declspec(dllexport)__stdcall CALLBACK CBTProc(int nCode, WPARAM wParam, LPARAM lParam)
{
if(nCode < 0)
{
return CallNextHookEx( hkb, nCode, wParam, lParam );
}
else if(HCBT_SYSCOMMAND == nCode)
{
OutputDebugString("\n Got it!! \n");
}
return 0;
}
The problem with this hook is that I am getting events for the menu click from my application only and not from any other window.
Is there any way I can get these events?
Thanks in advance for yr help!
|
|
|
|
|
I'm using Visual Studio 2005 and I wrote a DLL program in C. I want to add a status window to this DLL that creates a window and dynamically updates labels each time the DLL is called. What is the best and easiest way to do this? Should I use C++ and Windows Forms or use MFC?
|
|
|
|
|
hi
i am working with Listview,and when i insert some data in it it range them in many columns,and i would like that arrange them just in one columns with vertical scrollbare to reach the other data in the bottom.
|
|
|
|
|
Ok. In VC++.Net 05, I've compiled a dll containing a namespace from one project in the solution. I'm now trying to use that namespace in another project but it is throwing up linking errors for the object it's compiled for the 2nd project. I have added the dll to the References in the Project Properties but nothing. If I say
> using namespace DllData
the compiler says that DllClass (in the dll) is not a member of DllNamespace. This makes sense as Intellisense is not picking up DllNamespace in the first place. I've tried including the headers for the dll source from the 1st project (which seems a bit counterproductive to me), which helps compiling the object code but then crashes the linker when it can't find the object code for the dll!
I know I'm doing something stupid or not doing something obvious. Please help!
|
|
|
|