Click here to Skip to main content
15,896,606 members
Home / Discussions / C#
   

C#

 
AnswerRe: Is it possible to save EXE from Dynamic Compilation? Pin
Giorgi Dalakishvili16-Nov-07 8:20
mentorGiorgi Dalakishvili16-Nov-07 8:20 
GeneralRe: Is it possible to save EXE from Dynamic Compilation? Pin
BGearig16-Nov-07 8:32
BGearig16-Nov-07 8:32 
GeneralRe: Is it possible to save EXE from Dynamic Compilation? Pin
Giorgi Dalakishvili16-Nov-07 9:20
mentorGiorgi Dalakishvili16-Nov-07 9:20 
QuestionGenerate classes from mssql database Pin
[DK]KiloDunse16-Nov-07 8:04
[DK]KiloDunse16-Nov-07 8:04 
AnswerRe: Generate classes from mssql database Pin
Judah Gabriel Himango16-Nov-07 8:40
sponsorJudah Gabriel Himango16-Nov-07 8:40 
QuestionC# pointer to struct using C dll Pin
dfn16-Nov-07 8:00
dfn16-Nov-07 8:00 
AnswerRe: C# pointer to struct using C dll Pin
Judah Gabriel Himango16-Nov-07 9:05
sponsorJudah Gabriel Himango16-Nov-07 9:05 
GeneralRe: C# pointer to struct using C dll Pin
dfn16-Nov-07 9:14
dfn16-Nov-07 9:14 
Sorry, here it is.
C code:
#if defined(WIN32) 
# define DLL_EXPORT __declspec(dllexport)
#else
# define DLL_EXPORT /**/
#endif

#ifdef __cplusplus
extern "C" {
#endif

	struct vector
	{
		uint elem_count; /* number of items in the vector */
		uint size;		/* size of the vector */
		uint elem_size; /* element size */
		int (*cmp)(const void *, const void *);
		void *table;
	};

	typedef struct vector VECTOR;
	#define CSTATS VECTOR

	//function definition:
	DLL_EXPORT CSTATS *screate(); // returns CSTATS pointer
	...
#ifdef __cplusplus
}
#endif


C# code:
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
unsafe public delegate int cmp(IntPtr a, IntPtr b);

[StructLayout(LayoutKind.Sequential, Pack = 1)]
unsafe public struct VECTOR
{
    public uint elem_count;
    public uint size;
    public uint elem_size;
    [MarshalAs(UnmanagedType.FunctionPtr)]
    public cmp cp; //C-func: public int (*cmp)(const void *, const void *);
    public IntPtr table;
}

[UnmanagedFunctionPointer(CallingConvention.Winapi)]
unsafe public delegate VECTOR screate();

[DllImport("myTest.dll", EntryPoint = "screate", ExactSpelling = true)]
public static extern screate scrt();

QuestionHow can I fix "The Breakpoint will not currently be hit......" Pin
Khoramdin16-Nov-07 7:41
Khoramdin16-Nov-07 7:41 
AnswerRe: How can I fix "The Breakpoint will not currently be hit......" Pin
Judah Gabriel Himango16-Nov-07 9:05
sponsorJudah Gabriel Himango16-Nov-07 9:05 
GeneralRe: How can I fix "The Breakpoint will not currently be hit......" Pin
Khoramdin16-Nov-07 11:36
Khoramdin16-Nov-07 11:36 
QuestionImmediate Window - '@err' equivalent Pin
Jeffrey Walton16-Nov-07 7:16
Jeffrey Walton16-Nov-07 7:16 
AnswerRe: Immediate Window - '@err' equivalent Pin
Judah Gabriel Himango16-Nov-07 7:36
sponsorJudah Gabriel Himango16-Nov-07 7:36 
GeneralRe: Immediate Window - '@err' equivalent Pin
Jeffrey Walton16-Nov-07 8:11
Jeffrey Walton16-Nov-07 8:11 
GeneralRe: Immediate Window - '@err' equivalent Pin
Judah Gabriel Himango16-Nov-07 8:14
sponsorJudah Gabriel Himango16-Nov-07 8:14 
QuestionWPF Question - Button Control Pin
Vidvict16-Nov-07 6:49
Vidvict16-Nov-07 6:49 
QuestionService to restart system Pin
dan!sh 16-Nov-07 6:44
professional dan!sh 16-Nov-07 6:44 
AnswerRe: Service to restart system Pin
Judah Gabriel Himango16-Nov-07 6:50
sponsorJudah Gabriel Himango16-Nov-07 6:50 
GeneralRe: Service to restart system Pin
dan!sh 16-Nov-07 6:59
professional dan!sh 16-Nov-07 6:59 
GeneralRe: Service to restart system Pin
Judah Gabriel Himango16-Nov-07 7:33
sponsorJudah Gabriel Himango16-Nov-07 7:33 
GeneralRe: Service to restart system Pin
dan!sh 16-Nov-07 7:44
professional dan!sh 16-Nov-07 7:44 
GeneralRe: Service to restart system Pin
Judah Gabriel Himango16-Nov-07 7:57
sponsorJudah Gabriel Himango16-Nov-07 7:57 
QuestionDLL Injection Pin
shakeebgenii16-Nov-07 6:42
shakeebgenii16-Nov-07 6:42 
AnswerRe: DLL Injection Pin
Judah Gabriel Himango16-Nov-07 6:47
sponsorJudah Gabriel Himango16-Nov-07 6:47 
QuestionRegular Expressions Pin
tthellebuyck16-Nov-07 5:56
tthellebuyck16-Nov-07 5:56 

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.