Click here to Skip to main content
15,900,724 members
Home / Discussions / C#
   

C#

 
GeneralRe: DataGridTextBoxColumn won't word wrap Pin
Heath Stewart11-Jun-04 6:27
protectorHeath Stewart11-Jun-04 6:27 
GeneralRe: DataGridTextBoxColumn won't word wrap Pin
holt11-Jun-04 7:14
holt11-Jun-04 7:14 
GeneralC++ pointer char* in dll function - string in C# Pin
SasaTod11-Jun-04 5:46
SasaTod11-Jun-04 5:46 
GeneralRe: C++ pointer char* in dll function - string in C# Pin
Heath Stewart11-Jun-04 6:22
protectorHeath Stewart11-Jun-04 6:22 
GeneralRe: C++ pointer char* in dll function - string in C# Pin
SasaTod11-Jun-04 9:29
SasaTod11-Jun-04 9:29 
GeneralRe: C++ pointer char* in dll function - string in C# Pin
Heath Stewart11-Jun-04 10:40
protectorHeath Stewart11-Jun-04 10:40 
GeneralRe: C++ pointer char* in dll function - string in C# Pin
SasaTod12-Jun-04 3:25
SasaTod12-Jun-04 3:25 
GeneralRe: C++ pointer char* in dll function - string in C# Pin
Heath Stewart12-Jun-04 4:31
protectorHeath Stewart12-Jun-04 4:31 
You have that all wrong. The character set should be CharSet.Auto (since, like I said before, the string is LPTSTR), and the second parameter is documented as [in, out], which means you should use ref because you MUST pass the size of the string buffer, which is probably why you're getting the error (not to mention the wrong character set when using Windows NT (4.0, 2000, XP, 2003). The property signature is:
[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern bool GetComputerName(string name, ref uint size);
 
// To call it...
uint size = 16; // MAX_COMPUTERNAME_LENGTH + 1
string name = new string('\0', (int)size);
GetComputerName(name, ref size);
You know what, though? You should browse the class library documentation and learn what's there. This P/Invocation is not necessary. Just use the Environment.MachineName property.

 

Microsoft MVP, Visual C#
My Articles
GeneralRe: Delete child in XML document while running an C# Application! Pin
Heath Stewart11-Jun-04 5:29
protectorHeath Stewart11-Jun-04 5:29 
GeneralRe: Delete child in XML document while running an C# Application! Pin
QzRz11-Jun-04 5:34
QzRz11-Jun-04 5:34 
GeneralRe: Delete child in XML document while running an C# Application! Pin
Heath Stewart11-Jun-04 5:43
protectorHeath Stewart11-Jun-04 5:43 
GeneralRe: Delete child in XML document while running an C# Application! Pin
QzRz11-Jun-04 5:48
QzRz11-Jun-04 5:48 
GeneralSurely this is an Easy Question... Pin
Adam °Wimsatt11-Jun-04 4:56
Adam °Wimsatt11-Jun-04 4:56 
GeneralRe: Surely this is an Easy Question... Pin
Heath Stewart11-Jun-04 5:28
protectorHeath Stewart11-Jun-04 5:28 
GeneralAssembly Class Locking Issue Pin
Daniel M. Edwards11-Jun-04 4:49
Daniel M. Edwards11-Jun-04 4:49 
GeneralRe: Assembly Class Locking Issue Pin
Heath Stewart11-Jun-04 5:25
protectorHeath Stewart11-Jun-04 5:25 
GeneralRe: Assembly Class Locking Issue Pin
Daniel M. Edwards11-Jun-04 6:01
Daniel M. Edwards11-Jun-04 6:01 
GeneralPDA PC communication , IIS Pin
apenon11-Jun-04 4:25
apenon11-Jun-04 4:25 
GeneralDesign Question: Correct way to show data from mutliple DB tables Pin
James Spibey11-Jun-04 4:10
James Spibey11-Jun-04 4:10 
GeneralRe: Design Question: Correct way to show data from mutliple DB tables Pin
Michael Potter11-Jun-04 5:01
Michael Potter11-Jun-04 5:01 
GeneralRe: Design Question: Correct way to show data from mutliple DB tables Pin
James Spibey11-Jun-04 5:52
James Spibey11-Jun-04 5:52 
GeneralMicrosoft Excel Plugin Help Pin
Asad Hussain11-Jun-04 3:41
Asad Hussain11-Jun-04 3:41 
Generaltabpage events Pin
robmays11-Jun-04 2:07
robmays11-Jun-04 2:07 
GeneralRe: tabpage events Pin
Corinna John11-Jun-04 2:20
Corinna John11-Jun-04 2:20 
GeneralRe: tabpage events Pin
robmays11-Jun-04 20:45
robmays11-Jun-04 20:45 

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.