|
Have you tried it the simple way, yet? The CLR provides marshalling capabilities for you, so you don't have to worry about calls to Marshal.StringToHGlobalAnsi() when things are set up well.
<br />
[DllImport("dll.dll", CharSet=CharSet.Ascii)]<br />
private static extern string do_READ_FROM_OPENTCPSOCKET(Int32 comdev);<br />
<br />
Give this a shot, and forget about using "unsafe" when you try it. For additionaly help in the interop area, try watching this[^].
John
"You said a whole sentence with no words in it, and I understood you!" -- my wife as she cries about slowly becoming a geek.
|
|
|
|
|
Thx, I will give it a try!
|
|
|
|
|
For some odd reason I still get a EntryPointNotFoundException when I try to invoke an unmanaged function that returns char*. Could it be something dodgy with my unmanaged dll?
|
|
|
|
|
I am attempting to write a C++ DLL function that will return a string and then call that function from C#. Looks like you have working code that does this or something very similar. Could you show what you did to make this work?
Here is the relevant portion of my code:
In C++ DLL header (.h)
extern "C" __declspec(dllexport) int addfive(int x);
extern "C" __declspec(dllexport) char* putFolderList();
In C++ DLL source (.cpp)
int addfive(int i) { return i+5 ;}
char* putFolderList(){ return "my string" ;}
In C#:
using System.Runtime.InteropServices;
[DllImport("DLLBuildTest.dll")]
static extern int addfive(int x); // VALID
static extern char* putFolderList(); // NOT Valid
Paul
|
|
|
|
|
HI all,
How one can impliment this idea using wmsdk9 series,
do u have any code which can help me.
well i have created a player object and if trying its full screen property its run only first time , but as the media file ends it comes in normal mode.
private AxMicrosoft.MediaPlayer.Interop.AxWindowsMediaPlayer axWindowsMediaPlayer1;
//axWindowsMediaPlayer1.fullScreen=true; gives error
Querry--
how can we retain in full screen mode for all play list or repeat.?
Regards,
Lalit Narayan Dubey
|
|
|
|
|
How nice of you to repost your question from your previous thread just because it dropped a few lines on your screen.
And good that you simply quoted your last statement from that thread instead of giving additional information that might help others to solve your problem.
Outstanding!
Cheers
Sid
P.S.: If you find me sarcastic, cynic or ironic - you are on the right track.
|
|
|
|
|
In .Net why is string is treated as reference type, it is a primitive datatype. All premitive datatype are value type except string why this is. Is there any spl reason.
Regards,
Chakravarthy.v
|
|
|
|
|
I'd say it's because strings can get very large. The maximum size of other primitive data types is predefined, but strings can grow to arbitrary lengths. You certainly wouldn't want to copy a 100,000 characters long string everytime you pass it to a function (by default) or put it in a collection (boxing).
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
|
System.String is a reference type and not a value type, which means each string is allocated on the heap and not the stack. System.String is peculiar in that it has a shortcut keyword associated with it (string), which is a common practice with primitive value types - System.Int32 (int), System.Char (char) etc. String references also do not require the new keyword to allocate an instance, the following line of code will allocate space on the heap, fill it with string data and assign the reference to the variable:
A string is a sequential collection of Unicode characters, typically used to represent text, while a String is a sequential collection of System.Char objects that represents a string. The value of the String is the content of the sequential collection, and the value is immutable.
The ANSI string class implements a first-class character string data type that avoids many problems associated with simple character arrays
vimsy
|
|
|
|
|
i have seen that to boost performance in a crc class, the code prefetch data in a byte[] of lets say 16384.
i've seen that
public FileStream(
string path, FileMode mode, FileAccess access, FileShare share,
int bufferSize
);
has its own buffer, so if i set the bufferSize to 16384 and use the FileStream.Readbyte
i could achieve the same performance but it is not.
What is this bufferSize for?
example code
http://www.vbaccelerator.com/home/NET/Code/Libraries/CRC32/Crc32_zip_CRC32_CRC32_cs.asp
|
|
|
|
|
Dear members,
Let me put my small issue in front of you. I have a windows form like our excel sheet (spreadsheet). The only difference is, instead of excel cells i use labels. I also have menus and toolbar like excel. Like excel workspace, i also have a work space with cells (labels) inside a panel control.
Here i use panel control to group all cells under one group.
In excel we can zoom the sprdsheet area and can view some or all details at a stretch.
I would also like to have same mechanism here in my panel area (only working area).
It would be great pleasure if you can shoot your idea or help or any url's, which will help me to get out from this problem.
Sreejith Nair
[ My Articles ]
|
|
|
|
|
Here's an oddball question. I've been reading SIGGRAPH papers until my eyes bleed, but I'm still stuck. I have a laplacian pyramid, which I got from merging pyramids on several images. Now I need to restore the image from that pyramid. Every source I can find for this requires the gaussian pyramid as well, but as I've not done anything to merge those, the question is, which pyramind do I use ?
So my question is, can I merge a laplacian pyramid into the original image without requiring a gaussian pyramid as well ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I hate to see a good question go unanswered, so I'm only answering in the hopes that a pair of ignorant eyes (mine) can ask a question that'll help you find the answer.
Not having a clue what you were asking, I did a few quick searches to discover what in the world you were talking about. From what I can tell the laplacian pyramid culls information from an image, and would therefor not have everything you need in order to regenerate the original information. Is that a correct assumption on my part? If so, that may be the answer, but then you're apparently merging in some other pyramids as well. (Do they collectively have the information you need? If so, it is probably an algorithmic question, which I clearly can't help you with in this case.)
Maybe you ought to post this in the C++ forum, too? They may be a more likely group to be working in graphical image processing algorithms.
John
"You said a whole sentence with no words in it, and I understood you!" -- my wife as she cries about slowly becoming a geek.
|
|
|
|
|
Hi group,
As this is my first mail for help.
I am developing a project in which i have to use the window media player with C# application , i am using SDK9 series.
I am facing 2 issue as
1- when the media /movie file playing finish the window comes in normal mode but i need it in fullscreen mode alwayas.
2- I am trying to loop for any file its not working
plz help asap
Regards,
Lalit Narayan Dubey
|
|
|
|
|
Lalit N Dubey wrote:
when the media /movie file playing finish the window comes in normal mode but i need it in fullscreen mode alwayas.
Instead of making it fullscreen mode, just size the window to the size of the screen
Lalit N Dubey wrote:
2- I am trying to loop for any file its not working
You can register a callback when a file ends, actually what happens is that there is a callback for state change. Write a log file of all state changes and run some files, so you get a good idea of the sequence of events. Then when the file ends, you can catch the event and start it again.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
How one can impliment this idea using wmsdk9 series,
do u have any code which can help me.
well i have created a player object and if trying its full screen property its run only first time , but as the media file ends it comes in normal mode.
private AxMicrosoft.MediaPlayer.Interop.AxWindowsMediaPlayer axWindowsMediaPlayer1;
//axWindowsMediaPlayer1.fullScreen=true; gives error
Querry--
how can we retain in full screen mode for all play list or repeat.?
Regards,
Lalit Narayan Dubey
|
|
|
|
|
Lalit N Dubey wrote:
how can we retain in full screen mode for all play list or repeat.?
To reiterate: DON'T go full screen, go on a window under your control, and make THAT full screen.
|
|
|
|
|
I have an object that I am getting from an Excel cell range. I can look at it in the debugger, its an array of arrays (of objects I think). I want to store this in a variable, but I dont know how to cast it!! I DO know the size of the array of arrays (both, i am completely aware of the dimensions of this object.)
Can somebody please help?? So you can see, here is what I have currently but it throws a cast exception:
cellR = workS.get_Range("A" + curRow, "F" + curRow);
Object theLine = cellR.get_Value(System.Type.Missing);
Object[][] theOtherLine = new object[1][];
theOtherLine = (Object[][])theLine;
It does so at runtime.
Cheers!
Jim
Did I post well? Rate it! Did I post badly? Rate that too!
|
|
|
|
|
Object[][] is a jagged array. Perhaps you need Object[,] ??
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Wow, thank you! How is that handled differtly in memory? Why do both of those exist?
Cheers,
Jim
Did I post well? Rate it! Did I post badly? Rate that too!
|
|
|
|
|
Jagged arrays is simply an array of arrays, while a multidimensional array is truly one array with multiple dimensions. Jagged arrays can have different dimensions for each row in the first dimension, for eg, whereas multidimensional arrays always have the same number of dimensions.
int [][] x = new int[2][];
x[0] = new int[5];
x[1] = new int[10];
...
int [,]x = new int[2,10];
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Hi all,
I'm having a problem using class casts. I'm storing an ArrayList inside a DataTable, and when I want to retrieve the list, I get an InvalidCastException. Here is my code:
using System;<br />
using System.Data;<br />
using System.Collections;<br />
<br />
class CastTest {<br />
const string COL = "test";<br />
static void Main() {<br />
Console.WriteLine("CastTest");<br />
ArrayList list = new ArrayList();<br />
string str = "Hello world";<br />
list.Add(str); <br />
Console.WriteLine("arrayList created"); <br />
DataTable table = new DataTable();<br />
DataRow row = table.NewRow();<br />
table.Columns.Add(COL);<br />
table.Rows.Add(row);<br />
row[COL] = list; <br />
Console.WriteLine("table created"); <br />
object resultObj = table.Rows[0][COL]; <br />
Console.WriteLine("resultObj: " + resultObj); <br />
ArrayList resultList = (ArrayList)resultObj; <br />
string resultStr = (string)resultList[0];<br />
Console.WriteLine(resultStr);<br />
}<br />
}
The second last WriteLine statement prints: "resultObj: System.Collections.ArrayList". I seem to be retrieving the ArrayList as an object, but I'm unable to cast it. Why?
Thanks in advance.
Cheers,
Michael
|
|
|
|
|
I ran the above code, and as I suspected, the arraylist is having it's 'tostring()' called as it goes into the table. You don't have an arraylist, you have a string which says 'System.Collections.ArrayList'.
I doubt you can shove arrays into a cell of a table.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
With the help of a workmate, I've resolved the issue. The quirk was in the Add method of the DataColumnCollection class (which holds the cells for the rows). The writers of the method, in their infinite wisdom, convert the input value to a string before adding it. This is default behaviour. It can be overridden by creating a custom DataColumn to hold the type of the input data. I'm including the code which now works.
using System;<br />
using System.Data;<br />
using System.Collections;<br />
class CastTest {<br />
const string COL = "test";<br />
static void Main() {<br />
Console.WriteLine("CastTest");<br />
ArrayList list = new ArrayList();<br />
string str = "Hello world";<br />
list.Add(str); <br />
Console.WriteLine("arrayList created"); <br />
DataTable table = new DataTable();<br />
DataColumn dC = new DataColumn(COL, list.GetType());<br />
table.Columns.Add(dC);<br />
DataRow row = table.NewRow();<br />
table.Rows.Add(row);<br />
row[COL] = list;<br />
Console.WriteLine("table created"); <br />
object resultObj = table.Rows[0][COL]; <br />
Console.WriteLine("resultObj type: " + resultObj.GetType()); <br />
ArrayList resultList = (ArrayList) resultObj; <br />
string resultStr = (string)resultList[0];<br />
Console.WriteLine(resultStr);<br />
}<br />
}
I guess I should be reading the documentation more closely so that I would be more aware of "features" like this
Thanks for the replies. Regards,
Michael
|
|
|
|