C Board  

Go Back   C Board > General Programming Boards > C# Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 04-01-2005, 09:07 AM   #1
Registered User
 
Join Date: Mar 2005
Location: Mountaintop, Pa
Posts: 1,059
Using c library in C#

First of all, I'm an absolute C# newbie. But I want to start using the language for development. My question is, Can I use a library written for C in C#? If so, can someone provide a simple example on how to do this?

Thanx

Bob
BobS0327 is offline   Reply With Quote
Old 04-01-2005, 10:40 AM   #2
BMJ
Registered User
 
Join Date: Aug 2002
Posts: 1,330
http://msdn.microsoft.com/library/de...ClassTopic.asp

Example:
Code:
using System;
using System.Runtime.InteropServices;

namespace TextColor
{
    class MainClass
    {
        [DllImport("kernel32.dll")]
        public static extern bool SetConsoleTextAttribute(IntPtr hConsoleOutput, int wAttributes);
        [DllImport("kernel32.dll")]
        public static extern IntPtr GetStdHandle(uint nStdHandle);

        public static void Main(string[] args)
        {
            uint STD_OUTPUT_HANDLE = 0xfffffff5;
            IntPtr hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
            for (int k = 1; k < 255; k++)
            {
                SetConsoleTextAttribute(hConsole, k);
                Console.WriteLine("{0:d3}  http://www.cprogramming.com", k);
            }
            SetConsoleTextAttribute(hConsole, 236);

            Console.WriteLine("Press Enter to exit ...");
            Console.Read();
        }
    }
}
BMJ is offline   Reply With Quote
Old 04-01-2005, 10:51 AM   #3
Registered User
 
Join Date: Mar 2005
Location: Mountaintop, Pa
Posts: 1,059
BMJ,

Thanx for the example

Bob
BobS0327 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
What's an import library? chiefmonkey C++ Programming 1 06-19-2009 05:00 PM
Property Set Library (PSL) - Announcement vultur_gryphus Projects and Job Recruitment 0 05-29-2008 06:04 AM
Makefile for a library sirmoreno Linux Programming 5 06-04-2006 04:52 AM
very weird .h problem royuco77 C++ Programming 1 09-11-2005 07:55 AM
better c string functions samps005 C Programming 8 11-04-2003 01:28 PM


All times are GMT -6. The time now is 09:58 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22