Hi there,
I would like to retrieve the computer name in C#, here is the piece of code
in VB:
Private Declare Function GetComputerName API Lib "kernel32" Alias
"GetComputerNam eA" (ByVal lpBuffer As String, nSize As Long) As Long
How do I translate to C#? thanks! 4 11930
[DllImport("kern el32", EntryPoint= "GetComputerNam eA")]
private static extern int GetComputerName (StringBuilder lpBuffer, ref int
nSize);
"cloudx" <cl****@discuss ions.microsoft. com> wrote in message
news:F7******** *************** ***********@mic rosoft.com... Hi there,
I would like to retrieve the computer name in C#, here is the piece of code in VB:
Private Declare Function GetComputerName API Lib "kernel32" Alias "GetComputerNam eA" (ByVal lpBuffer As String, nSize As Long) As Long
How do I translate to C#? thanks!
"cloudx" <cl****@discuss ions.microsoft. com> wrote in message
news:F7******** *************** ***********@mic rosoft.com... I would like to retrieve the computer name in C#
Hi. Use System.Environm ent.MachineName instead.
-- Alan
I believe this is the one you wanted to use
[DllImport("kern el32.dll")]
static extern bool GetComputerName (StringBuilder lpBuffer, ref uint
lpnSize); http://www.pinvoke.net/ is a great source of WinAPI - C# related
information, check it out.
"cloudx" <cl****@discuss ions.microsoft. com> wrote in message
news:F7******** *************** ***********@mic rosoft.com... Hi there,
I would like to retrieve the computer name in C#, here is the piece of
code in VB:
Private Declare Function GetComputerName API Lib "kernel32" Alias "GetComputerNam eA" (ByVal lpBuffer As String, nSize As Long) As Long
How do I translate to C#? thanks! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: b83503104 |
last post by:
Previously, when my constructor had no arguments, I used this to
declare my objects:
MyClass myObject;
Now, my constructor has arguments (MyClass::MyClass(int someVariable)),
how do I declare my objects?
I tried
MyClass myObject(100);
and
|
by: rick |
last post by:
Noob problem. I prefer to keep all my scripts in an external '.js' file.
I am currently loading the external '.js' file from the header. Problem is I
would like to declare
a global variable in the external file, but I keep getting an error about
the object does not exist.
Can someone tell me where or how to declare a global variable in an external
file that is
available after the page is loaded.
|
by: Brian Sammon |
last post by:
According to my programming textbook, "int a;" at the top level of a
file is a definition which shouldn't go in a header file.
However, I'm running into a lot of online documentation that treats that
kind of statement as a declaration that can be in a header file used in
multiple compilation units.
Which of these is correct? Is this something that has changed between
different standards?
|
by: Kobu |
last post by:
The code below isn't compiling for me (error message: conflicting types
for 'total' - pointing to the extern declaration).
Why wouldn't this work, since the types are different, the extern
declaration obviously refers to the 'long total' in total.c? Is my
compiler wrong?
total.c
|
by: **Developer** |
last post by:
Notice below I sometimes used the "A" version. I found by cut-and-try that
only the "A" version would work correctly. Anyone have a suggestion of why
the "W" version would not work correctly?
One reason is that the ByRef or ByVal does not show by InteliSence so the
"p" would help there.
------
Secondly, I'd like to be consistent with the parameter names. I'd like to
| |
by: mark.moore |
last post by:
I know this has been asked before, but I just can't find the answer in
the sea of hits...
How do you forward declare a class that is *not* paramaterized, but is
based on a template class?
Here's what I thought should work, but apparently doesn't:
class Foo;
void f1(Foo* p)
|
by: barcaroller |
last post by:
I was thinking of buying Scott Meyer's second book (More Effective C++) and
noticed that it has not been updated since 1995 (unlike his other two famous
books). Does anyone know (rumour or otherwise) if a new edition is coming
out. I would hate to spend $50 today only to see a new edition on the
shelves tomorrow.
|
by: arkmancn |
last post by:
Any comments? thanks.
Jim
|
by: Amirallia |
last post by:
Hi,
It is possible to declare the mctest.dll library without defining the
c:\Temp path in hard code.
Declare Ansi Sub pst_Test Lib "c:\temp\mctest.dll" Alias "pst_Test"
(ByVal intNomPtr As Int32, ByVal intNomLong As Int32, ByVal intNumAdrD
As Int32, ByVal intNumAdrF As Int32, ByVal intNPA As Int32)
This, is not possible :
|
by: constructor |
last post by:
Hello NG,
I'm having to use a function in an external library that returns a pointer
to an array of structs.
The function declaration according to library vendor is:
device** getList( int &count)
The returned structs:
typedef struct tag_dev
{
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |