Reading INI file: Get Private Profile String : Native Windows Function « Windows « C# / CSharp Tutorial

C# / CSharp Tutorial
1. Language Basics
2. Data Type
3. Operator
4. Statement
5. String
6. struct
7. Class
8. Operator Overload
9. delegate
10. Attribute
11. Data Structure
12. Assembly
13. Date Time
14. Development
15. File Directory Stream
16. Preprocessing Directives
17. Regular Expression
18. Generic
19. Reflection
20. Thread
21. I18N Internationalization
22. GUI Windows Forms
23. 2D
24. Design Patterns
25. Windows
26. XML
27. ADO.Net
28. Network
29. Directory Services
30. Security
31. unsafe
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorial
C# / C Sharp
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
C# / CSharp Tutorial » Windows » Native Windows Function 
25. 10. 11. Reading INI file: Get Private Profile String
using System;
using System.Runtime.InteropServices;
using System.Text;

class MainClass
{
    // Declare the unmanaged functions.
    [DllImport("kernel32.dll", EntryPoint = "GetPrivateProfileString")]
    private static extern int GetPrivateProfileString(string lpAppName, string lpKeyName, string lpDefault, StringBuilder lpReturnedString, int nSize, string lpFileName);


    static void Main(string[] args)
    {
        string section = "SampleSection"
        string key = "Key1";
        string filename = "\\initest.ini";

        int chars = 256;
        StringBuilder buffer = new StringBuilder(chars);
        string sDefault = "";
        if (GetPrivateProfileString(section, key, sDefault, buffer, chars, filename!= 0)
        {
            Console.WriteLine("Value of Key1 in [SampleSection] is: " + buffer.ToString());
        }
        else
        {
            Console.WriteLine("Value of Key1 in [SampleSection] is: " null);
        }
    }
}
25. 10. Native Windows Function
25. 10. 1. Calling Native DLL Functions
25. 10. 2. Calling a Function with a Structure Parameter
25. 10. 3. Enumerate Display Monitors
25. 10. 4. Get Workstation information
25. 10. 5. Get Computer name (char * parameter)
25. 10. 6. Get free disk space
25. 10. 7. Use native windows function to read file
25. 10. 8. The windows version information
25. 10. 9. Get current Active Window
25. 10. 10. Writing INI file: Write Private Profile String
25. 10. 11. Reading INI file: Get Private Profile String
25. 10. 12. GetVersionEx by using kernel32.dll
25. 10. 13. Get computer name (StringBuilder parameter)
25. 10. 14. Lock work station
25. 10. 15. Get Monitor Information
w___ww___.j__a__va2___s___.__c__om_ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.