Click here to Skip to main content
15,912,578 members
Home / Discussions / C#
   

C#

 
GeneralRe: Sharepoint Development - Where to Start? Pin
rkajal17-Feb-09 6:40
rkajal17-Feb-09 6:40 
GeneralRe: Sharepoint Development - Where to Start? Pin
ToddHileHoffer17-Feb-09 6:58
ToddHileHoffer17-Feb-09 6:58 
GeneralRe: Sharepoint Development - Where to Start? Pin
led mike17-Feb-09 7:08
led mike17-Feb-09 7:08 
GeneralRe: Sharepoint Development - Where to Start? Pin
rkajal17-Feb-09 10:11
rkajal17-Feb-09 10:11 
GeneralRe: Sharepoint Development - Where to Start? Pin
led mike17-Feb-09 11:04
led mike17-Feb-09 11:04 
GeneralRe: Sharepoint Development - Where to Start? Pin
rkajal17-Feb-09 10:13
rkajal17-Feb-09 10:13 
QuestionDllImport Pin
Alessio Granzotto17-Feb-09 5:44
Alessio Granzotto17-Feb-09 5:44 
AnswerRe: DllImport Pin
Luc Pattyn17-Feb-09 6:16
sitebuilderLuc Pattyn17-Feb-09 6:16 
Hi,

I would try that differently:

1.
in this situation there is no need for pointers and unsafe keyword, just use the IntPtr class (it takes 4 or 8 bytes depending on Win32/Win64).

2.
read-only strings can be passed to a char* as is; a StringBuilder is required only if the native code needs to provide or modify the string value (use a StringBuilder.ToString when done).

3.
an output parameter needs the out (or ref) keyword; that basically takes care of the indirection,
i.e. the variable gets then passed by reference automatically.

4.
warning: in C# long takes 8 bytes, in the native world long usually is 4 B.


So I would try this:

[DllImport("xxx.dll")]
public static extern long ImageFileOpen(out IntPtr hImageFile, string szFileName, bool bWrite);

[DllImport("xxx.dll")]
public static extern long ImageFileRead(IntPtr hImageFile, out IntPtr hImage);

IntPtr hImageFile;
IntPtr hImage;

rc = ImageFileOpen(out hImageFile, fullname, false);
if (rc...) ...
rc = ImageFileRead(hImageFile, out hImage);


Now the tricky part could be what comes next: how will managed code access the content of the image?

Smile | :)
Luc Pattyn [Forum Guidelines] [My Articles]

- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets


modified on Sunday, June 12, 2011 8:15 AM

GeneralRe: DllImport Pin
Alessio Granzotto17-Feb-09 6:30
Alessio Granzotto17-Feb-09 6:30 
GeneralRe: DllImport Pin
Mirko198018-Feb-09 3:32
Mirko198018-Feb-09 3:32 
AnswerRe: DllImport Pin
Luc Pattyn18-Feb-09 3:45
sitebuilderLuc Pattyn18-Feb-09 3:45 
QuestionMasked Textbox Prompt Pin
Lodeclaw17-Feb-09 5:38
Lodeclaw17-Feb-09 5:38 
AnswerRe: Masked Textbox Prompt Pin
Nagy Vilmos17-Feb-09 5:58
professionalNagy Vilmos17-Feb-09 5:58 
GeneralRe: Masked Textbox Prompt Pin
Lodeclaw17-Feb-09 6:01
Lodeclaw17-Feb-09 6:01 
GeneralRe: Masked Textbox Prompt Pin
Nagy Vilmos17-Feb-09 6:14
professionalNagy Vilmos17-Feb-09 6:14 
GeneralRe: Masked Textbox Prompt Pin
Lodeclaw17-Feb-09 6:29
Lodeclaw17-Feb-09 6:29 
GeneralRe: Masked Textbox Prompt Pin
Nagy Vilmos17-Feb-09 23:19
professionalNagy Vilmos17-Feb-09 23:19 
QuestionThread.Sleep(0) action? Pin
Bruce Coward17-Feb-09 5:25
Bruce Coward17-Feb-09 5:25 
AnswerRe: Thread.Sleep(0) action? Pin
Nuri Ismail17-Feb-09 5:31
Nuri Ismail17-Feb-09 5:31 
GeneralRe: Thread.Sleep(0) action? Pin
Bruce Coward17-Feb-09 5:51
Bruce Coward17-Feb-09 5:51 
AnswerRe: Thread.Sleep(0) action? Pin
Luc Pattyn17-Feb-09 6:24
sitebuilderLuc Pattyn17-Feb-09 6:24 
GeneralRe: Thread.Sleep(0) action? Pin
PIEBALDconsult17-Feb-09 6:33
mvePIEBALDconsult17-Feb-09 6:33 
AnswerRe: Thread.Sleep(0) action? Pin
Luc Pattyn17-Feb-09 6:48
sitebuilderLuc Pattyn17-Feb-09 6:48 
GeneralRe: Thread.Sleep(0) action? Pin
PIEBALDconsult17-Feb-09 6:52
mvePIEBALDconsult17-Feb-09 6:52 
GeneralRe: Thread.Sleep(0) action? Pin
Bruce Coward17-Feb-09 6:44
Bruce Coward17-Feb-09 6:44 

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.