Click here to Skip to main content
15,915,319 members
Home / Discussions / C#
   

C#

 
GeneralRe: Polymorphism Pin
PIEBALDconsult6-Sep-11 14:44
mvePIEBALDconsult6-Sep-11 14:44 
GeneralRe: Polymorphism Pin
Alan Balkany7-Sep-11 4:43
Alan Balkany7-Sep-11 4:43 
GeneralRe: Polymorphism Pin
PIEBALDconsult7-Sep-11 14:21
mvePIEBALDconsult7-Sep-11 14:21 
GeneralRe: Polymorphism Pin
Alan Balkany8-Sep-11 4:54
Alan Balkany8-Sep-11 4:54 
GeneralRe: Polymorphism Pin
PIEBALDconsult8-Sep-11 14:19
mvePIEBALDconsult8-Sep-11 14:19 
GeneralRe: Polymorphism Pin
Michael J. Eber8-Sep-11 7:41
Michael J. Eber8-Sep-11 7:41 
GeneralRe: Polymorphism Pin
PIEBALDconsult8-Sep-11 14:22
mvePIEBALDconsult8-Sep-11 14:22 
QuestionC# PSAPI_VERSION. and sevral other question [modified] [Partialy Solved] Pin
Saksida Bojan3-Sep-11 23:12
Saksida Bojan3-Sep-11 23:12 
In MSDN I found this for dll import used with PInvoke:

Kernel32.dll on Windows 7 and Windows Server 2008 R2;
Psapi.dll if PSAPI_VERSION=1 on Windows 7 and Windows Server 2008 R2;
Psapi.dll on Windows Server 2008, Windows Vista, Windows Server 2003, and Windows XP/2000

So how do i do programaticly find PSAPI_VERSION? I already Can determent windows version. But i am missing from the List Windwos 2008 and R2. I am doing the folowing way:

C#
public static EnumWinVer GetWindowsVersion()
{
            
    OperatingSystem os = Environment.OSVersion;
    Version vs = os.Version;

    // This switch is pre-NT version
    if (os.Platform == PlatformID.Win32Windows)
    {
        switch (vs.Minor)
        {
            case 0:
                return EnumWinVer.Win95;
            case 10:
                if (vs.Revision.ToString() == "2222A")
                    return EnumWinVer.Win98SE;
                else
                    return EnumWinVer.Win98;
            case 90:
                return EnumWinVer.WinME;
        }
    }
    else if (os.Platform == PlatformID.Win32NT)
    {
        switch (vs.Major)
        {
            case 3:
                return EnumWinVer.WinNT3_51;
            case 4:
                return EnumWinVer.WinNT4_0;
            case 5:
                if (vs.Minor == 0)
                    return EnumWinVer.Win2000;
                else
                    return EnumWinVer.WinXP;
            case 6:
                if (vs.Minor == 0)
                    return EnumWinVer.WinVista;
                else
                    return EnumWinVer.Win7;
            default:
                break;
        }
    }

    // This is supposed to be unreachable area.
    return EnumWinVer.Undefined;
}


I am looking into GetModuleFileNameEx. QueryFullProcessImageName also can do the job. But minimum OS is Vista.

So what would happen when Dllimport calls function that doesn't exsist on current OS. So how do i handle that.

Thanks in advance for any answers to those question.
Have a nice day

edit:
[DllImport("kernel32.dll", EntryPoint = "GetModuleFileNameEx")]
static extern int K32GetModuleFileNameEx(IntPtr hProcess, IntPtr hModule, StringBuilder lpFilename, int nSize);

[DllImport("psapi.dll", EntryPoint = "GetModuleFileNameEx")]
static extern int PSAPIGetModuleFileNameEx(IntPtr hProcess, IntPtr hModule, StringBuilder lpFilename, int nSize);


After this i will Handle System.EntryPointNotFoundExpection.

Now i only need how to detect Windows version for Windows 2008.

modified on Sunday, September 4, 2011 6:02 AM

AnswerRe: C# PSAPI_VERSION. and sevral other question [modified] [Partialy Solved] Pin
BobJanova4-Sep-11 23:11
BobJanova4-Sep-11 23:11 
GeneralRe: C# PSAPI_VERSION. and sevral other question [modified] [Partialy Solved] Pin
Saksida Bojan5-Sep-11 5:45
Saksida Bojan5-Sep-11 5:45 
GeneralRe: C# PSAPI_VERSION. and sevral other question [modified] [Partialy Solved] Pin
BobJanova5-Sep-11 5:51
BobJanova5-Sep-11 5:51 
Question8 directional chain code for monochrome images Pin
dookeybre3-Sep-11 16:03
dookeybre3-Sep-11 16:03 
AnswerRe: 8 directional chain code for monochrome images Pin
OriginalGriff3-Sep-11 21:19
mveOriginalGriff3-Sep-11 21:19 
GeneralRe: 8 directional chain code for monochrome images Pin
dookeybre3-Sep-11 21:21
dookeybre3-Sep-11 21:21 
QuestionDiscovering and Accessing IP Cameras Pin
AmbiguousName3-Sep-11 0:58
AmbiguousName3-Sep-11 0:58 
AnswerRe: Discovering and Accessing IP Cameras Pin
Abhinav S3-Sep-11 6:00
Abhinav S3-Sep-11 6:00 
QuestionEmail Sender :the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond Pin
bigz_10002-Sep-11 21:46
bigz_10002-Sep-11 21:46 
AnswerRe: Email Sender :the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond Pin
Mehdi Gholam2-Sep-11 21:50
Mehdi Gholam2-Sep-11 21:50 
GeneralRe: Email Sender :the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond Pin
bigz_10002-Sep-11 22:04
bigz_10002-Sep-11 22:04 
GeneralRe: Email Sender :the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond Pin
Dave Kreskowiak3-Sep-11 8:40
mveDave Kreskowiak3-Sep-11 8:40 
GeneralRe: Email Sender :the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond Pin
bigz_10004-Sep-11 0:10
bigz_10004-Sep-11 0:10 
AnswerRe: Email Sender :the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond Pin
jschell3-Sep-11 10:39
jschell3-Sep-11 10:39 
GeneralRe: Email Sender :the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond Pin
bigz_10004-Sep-11 0:11
bigz_10004-Sep-11 0:11 
GeneralRe: Email Sender :the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond Pin
Michael J. Eber8-Sep-11 7:47
Michael J. Eber8-Sep-11 7:47 
QuestionC#4.0 How Connect Crystal Report [modified] Pin
Ken H1232-Sep-11 21:10
Ken H1232-Sep-11 21:10 

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.