Click here to Skip to main content
15,913,934 members
Home / Discussions / C#
   

C#

 
AnswerRe: Create an SQL DB file on demand Pin
musefan11-Nov-10 4:00
musefan11-Nov-10 4:00 
Questionvalidation in datagridview Pin
varsh1210-Nov-10 0:58
varsh1210-Nov-10 0:58 
AnswerRe: validation in datagridview Pin
OriginalGriff10-Nov-10 3:42
mveOriginalGriff10-Nov-10 3:42 
AnswerRe: validation in datagridview Pin
Henry Minute10-Nov-10 4:29
Henry Minute10-Nov-10 4:29 
QuestionSend String to another application(Un-managed) using C# Pin
ShafiqA10-Nov-10 0:31
ShafiqA10-Nov-10 0:31 
AnswerRe: Send String to another application(Un-managed) using C# Pin
_Erik_10-Nov-10 3:03
_Erik_10-Nov-10 3:03 
GeneralRe: Send String to another application(Un-managed) using C# Pin
ShafiqA10-Nov-10 19:01
ShafiqA10-Nov-10 19:01 
GeneralRe: Send String to another application(Un-managed) using C# Pin
_Erik_10-Nov-10 23:19
_Erik_10-Nov-10 23:19 
Ok. I think the problem is with your COPYDATASTRUCT. This is how it is declared in winuser.h:

typedef struct tagCOPYDATASTRUCT {
  ULONG_PTR dwData;
  DWORD     cbData;
  PVOID     lpData;
} COPYDATASTRUCT, *PCOPYDATASTRUCT;


And these are the lines which declare ULONG_PTR and DWORD data types:

typedef unsigned __int3264 ULONG_PTR;
typedef unsigned long DWORD, *PDWORD, *LPDWORD;


So ULONG_PTR is like a 32 bit unsigned integer in a 32 bit platform and a 64 bit unsigned integer in a 64 bit platform, and DWORD is always a 32 bit unsigned integer. Nevertheless, you are using the int type and MarshalAs.UnmanagedType.I4 for both of them in your C# declaration, I mean, you treat both of them as 32 bit signed integer. It will usually work in a 32 bit platform (though it could fail), but it will usually fail in a 64 bit platform. In a 64 bit platform you should change the COPYDATASTRUCT declaration in your C# application like this:

StructLayout(LayoutKind.Sequential)]
public struct COPYDATASTRUCT
{
    [MarshalAs(UnmanagedType.U8)]
    public ulong dwData;
    [MarshalAs(UnmanagedType.U4)]
    public uint cbData;
    [MarshalAs(UnmanagedType.LPStr)]
    public string lpData;
}


I am not sure if it would work in a 32 bit platform becouse I don't know if dwData value would be appropiately truncated. You can try and if it does not work on a 32 bit platform you will have to make two versions of the struct. In this case, the 32 bit version of the struct should be like this:

StructLayout(LayoutKind.Sequential)]
public struct COPYDATASTRUCT32
{
    [MarshalAs(UnmanagedType.U4)]
    public uint dwData;
    [MarshalAs(UnmanagedType.U4)]
    public uint cbData;
    [MarshalAs(UnmanagedType.LPStr)]
    public string lpData;
}


You have the System.Environment class to know which platform you are using. If you are using 4.0 version of .NET you can use System.Environment.Is64BitOperatingSystem, and if you are using a previous version of .NET you will have to go a little deeper into System.Environment (OSVersion, Platform, etc.).
GeneralRe: Send String to another application(Un-managed) using C# Pin
ShafiqA11-Nov-10 0:36
ShafiqA11-Nov-10 0:36 
AnswerRe: Send String to another application(Un-managed) using C# Pin
Vitaly Tomilov28-Nov-10 0:01
Vitaly Tomilov28-Nov-10 0:01 
QuestionComputer name Pin
peropata9-Nov-10 23:07
peropata9-Nov-10 23:07 
AnswerRe: Computer name PinPopular
Pete O'Hanlon9-Nov-10 23:35
mvePete O'Hanlon9-Nov-10 23:35 
AnswerRe: Computer name Pin
Ankur\m/9-Nov-10 23:43
professionalAnkur\m/9-Nov-10 23:43 
GeneralRe: Computer name Pin
RaviRanjanKr9-Nov-10 23:53
professionalRaviRanjanKr9-Nov-10 23:53 
GeneralRe: Computer name Pin
Ankur\m/10-Nov-10 0:06
professionalAnkur\m/10-Nov-10 0:06 
GeneralRe: Computer name Pin
fjdiewornncalwe10-Nov-10 2:28
professionalfjdiewornncalwe10-Nov-10 2:28 
GeneralRe: Computer name Pin
Ankur\m/10-Nov-10 2:41
professionalAnkur\m/10-Nov-10 2:41 
GeneralRe: Computer name Pin
fjdiewornncalwe10-Nov-10 3:51
professionalfjdiewornncalwe10-Nov-10 3:51 
GeneralRe: Computer name Pin
Ankur\m/10-Nov-10 4:04
professionalAnkur\m/10-Nov-10 4:04 
QuestionGet Text From an Image File Pin
Anubhava Dimri9-Nov-10 17:24
Anubhava Dimri9-Nov-10 17:24 
AnswerRe: Get Text From an Image File Pin
Rajesh Anuhya9-Nov-10 18:08
professionalRajesh Anuhya9-Nov-10 18:08 
AnswerRe: Get Text From an Image File Pin
vamyip9-Nov-10 18:47
vamyip9-Nov-10 18:47 
GeneralRe: Get Text From an Image File Pin
Anubhava Dimri10-Nov-10 0:49
Anubhava Dimri10-Nov-10 0:49 
GeneralRe: Get Text From an Image File Pin
88Rocker10-Nov-10 1:43
88Rocker10-Nov-10 1:43 
Questioncomparing integers [modified] Pin
pancakeleh9-Nov-10 16:27
pancakeleh9-Nov-10 16:27 

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.