Creating application compatibility shims for Windows [duplicate] - c

This question already has answers here:
Windows: How to create custom appcompat shims (Application Fixes)?
(5 answers)
Closed 9 years ago.
This blog post mentions how to create your own shims.
What I don't understand is:
When a newer version of a DLL comes out (with more exported functions), wouldn't this technique break?
i.e. If you completely override the target DLL with a shim DLL, then what do you do about functions that you didn't/couldn't implement a redirection for?

This isn't the only way to do it.
The easiest solution is probably to use Detours, though the free version is 32-bit only and for non-commercial use, and the paid version is seriously expensive.
This article describes a bunch of methods of doing it yourself.

Related

Is there a single official C compiler, and how do I install it? [duplicate]

This question already has answers here:
Has Windows an integrated built-in C/C++ compiler package?
(6 answers)
Closed 2 years ago.
I'm trying to install the C compiler onto my Windows 10 machine to be able to learn to develop in C. After looking around I found this mirror page linked by this official looking site, and downloaded and uncompressed the folder. I also tried git cloneing linked from this page.
Both folders look identical, and I can't find any executables in either. My hunch is that the actual compiler needs to be generated or compiled with the files found in the folders.
After looking at online tutorials most of them install third-party package managers to then install gcc from there, but I'd rather just install it directly (if thats possible in the first place). I'm not really sure if there is a single true C compiler because of this.
Could someone please clarify how this system works, and what I need to do to get it working. Thanks! :D
"Is there a single official C compiler, and how do I install it?"
No, there is no compiler provided by the C standard and thus no way to install it.
You have to use a third-party compiler. The most common for Linux and macOS are called GCC (GNU Compiler Collection) and Clang.
Since you ask for Windows, there are several C compilers available.
Take a look at the answers and comments to this question of mine a while ago:
Has Windows an integrated built-in C/C++ compiler package?
There you can find the at least many options.
The way to install you can find in the respective documentations and isn't object to be defined here as this would explode the frame.
My personal recommendation is GCC with the MingW_64 package. How you install it, you can find, as said, in the documentation.
Is there a single official C compiler? No.
Are you sure that you insist on the "official" one (which is not even clearly defined as the other comment pointed out)?
In your situation I would look for a "convenient" installation.
This more or less leads to the answer to "How to install it?"
The selection and indirectly the way to install it, is most wisely based on asking your friends/colleagues/fellows, because you will have questions and they are primarily best answered by any human you can directly ask. StackOverflow is only second place.
If that does not help you selecting one, I recommend to use yoru favorite search engine on "install gcc". In mine, the 10th result is my favorite.
Maybe go one step further towards "convenient" and search for "free IDE C" my favorite is the 6th result.
But of course this is not to tell you my favorite in a hidden way. You just look at the results, check the first few out and decide based on what you like best.
There's no official C compiler on any platform, and gcc is not a Windows program. The two main toolkits which provide C a compiler on Windows are MinGW and Cygwin. Both include a port of gcc, and after installing either one, you can use the gcc command to compile your C code.
Microsoft does not make a C compiler. They produce Visual Studio, which contains a C++ compiler that will compile a large subset of C programs, but they have made it clear that they have no intention of keeping up with the latest C standards.
The most popular C compilers on most platforms (Windows included) are GCC and CLANG/LLVM.

How to make a library of extension methods do double duty - SL4 and .NET4 [duplicate]

This question already has answers here:
Sharing C# code between Windows and Silverlight class libraries
(6 answers)
Closed 8 years ago.
I have some utilities and extension methods that I would like to leverage in an SL4 app. I know that to reference an assembly the project type has to be SL4 class library. I also understand that SL is a subset of the .NET framework. Therefore not all functionality is portable. So assume all the code I want to leverage in my SL4 app is portable to SL4.
What is the easiest way to expose an existing project/plain-old-CLR-library to SL4? I am looking for a maintainable workflow. As I develop against the library I want to leverage the new features in my SL4 app without having to rewrite the code in an SL4 class library.
Surley there is an easy way that I am completely missing...
Sounds like you want Sharing C# code between Windows and Silverlight class libraries
Another way you can do it is to just share(link) classes between your .NET library and your Silverlight library. An easy way to do this is to use the ProjectLinker tool.

How can I do GUI programming in C? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I want to do Graphics programming in C. I had searched a lot about the compiler that provides a rich set of functions for doing GUI programming in C, but I couldn't find anything.
Basically I want to draw buttons and then accept the choice from the user and take an appropriate action. It would be helpful if you can suggest a C compiler, or a library that I can add to my compiler. I am working on the Windows operating system.
Presently, I am using TURBO C compiler that does not support direct methods for creating buttons. Any help would be appreciated.
This is guaranteed to have nothing to do with the compiler. All compilers do is compile the code that they are given. What you're looking for is a GUI library, which you can write code against using any compiler that you want.
Of course, that being said, your first order of business should be to ditch Turbo C. That compiler is about 20 years old and continuing to use it isn't doing you any favors. You can't write modern GUI applications, as it will only produce 16-bit code. All modern operating systems are 32-bit, and many are now 64-bit. It's also worth noting that 64-bit editions of Windows will not run 16-bit applications natively. You'll need an emulator for that; it's not really going to engender much feeling of accomplishment if you can only write apps that work in a DOS emulator. :-)
Microsoft's Visual Studio Express C++ is available as a free download. It includes the same compiler available in the full version of the suite. The C++ package also compiles pure C code.
And since you're working in Windows, the Windows API is a natural choice. It allows you to write native Windows applications that have access to the full set of GUI controls. You'll find a nice tutorial here on writing WinAPI applications in C. If you choose to go with Visual Studio, it also includes boilerplate code for a blank WinAPI application that will get you up and running quickly.
If you really care about learning to do this, Charles Petzold's Programming Windows is the canonical resource of the subject, and definitely worth a read. The entire Windows API was written in C, and it's entirely possible to write full-featured Windows applications in C. You don't need no stinkin' C++.
That's the way I'd do it, at least. As the other answers suggest, GTK is also an option. But the applications it generates are just downright horrible-looking on Windows.
EDIT: It looks like you're not alone in wanting to write "GUI" applications using an antiquated compiler. A Google search turns up the following library: TurboGUI: A GUI Framework for Turbo C/C++:
 
If you're required use Turbo C, this might be an option.
The most famous library to create some GUI in C language is certainly GTK.
With this library you can easily create some buttons (for your example). When a user clicks on the button, a signal is emitted and you can write a handler to do some actions.
Use win APIs in your main function:
RegisterClassEx() note: you have to provide a pointer to a function (usually called WndProc) which handles windows messages such as WM_CREATE, WM_COMMAND etc
CreateWindowEx()
ShowWindow()
UpdateWindow()
Then write another function which handles win's messages (mentioned in #1). When you receive the message WM_CREATE you have to call CreateWindow(). The class is what control is that window, for example "edit" is a text box and "button" is a.. button :). You have to specify an ID for each control (of your choice but unique among all). CreateWindow() returns a handle to that control, which needs to be memorized. When the user clicks on a control you receive the WM_COMMAND message with the ID of that control. Here you can handle that event. You might find useful SetWindowText() and GetWindowText() which allows you to set/get the text of any control.
You will need only the win32 SDK. You can get it here.
C is more of a hardware programming language, there are easy GUI builders for C, GTK, Glade, etc. The problem is making a program in C that is the easy part, making a GUI that is a easy part, the hard part is to combine both, to interface between your program and the GUI is a headache, and different GUI use different ways, some threw global variables, some use slots. It would be nice to have a GUI builder that would bind easily your C program variables, and outputs. CLI programming is easy when you overcome memory allocation and pointers, GUI you can use a IDE that uses drag and drop. But all around I think it could be simpler.
A C compiler itself won't provide you with GUI functionality, but there are plenty of libraries for that sort of thing. The most popular is probably GTK+, but it may be a little too complicated if you are just starting out and want to quickly get a GUI up and running.
For something a little simpler, I would recommend IUP. With it, you can use a simple GUI definition language called LED to layout controls (but you can do it with pure C, if you want to).
Windows API and Windows SDK if you want to build everything yourself (or) Windows API and Visual C Express. Get the 2008 edition. This is a full blown IDE and a remarkable piece of software by Microsoft for Windows development.
All operating systems are written in C. So, any application, console/GUI you write in C is the standard way of writing for the operating system.

Is there any crossplatform GUI library for C language? [duplicate]

This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
Cross Platform C library for GUI Apps?
Is there any crossplatform GUI library for C language? (I mean at least win mac lin) If there is any XML-like GUI editing model, any GUI editing crossplatform visual programms it'l be grate!)
Take a look at the IUP Toolkit. It is written largely in C, and is also easily bound to Lua.
I use Gtk a lot it is consistent and nice to use. It was formerly used as a common platform for Gimp but became widely used and is the base toolkit for the Gnome desktop under Linux.
The GUI editor I use is Glade under Linux. The code generated can be recompiled without change under Windows. GLib is an underlying library that abstracts files, network, provides basic types and collections. As long as you use Glib, you are mostly OS independent.
I forgot to mention that glade stores the user interface in XML and generates code out of it. On the glade page I saw there is a windows version there but I cannot tell much about its behaviour. Under Linux it's fairly OK to use and quite stable.
Tk is a GUI library written in C. It comes with a scripting language named Tcl. These can be embedded in your C program. They are very mature and relatively lightweight. You can call the GUI toolkit from C, though it's much easier to do your GUI in Tcl and import it into your C program.
Applications written in Tcl, Tk and C are highly portable, and easy to distribute. The language is BSD style, which is a lot more liberal than GNU licenses.
On the Mac and Windows, Tk uses native widgets whenever possible, making your apps look right for each of those platforms.
GTK is a cross-platform GUI for C (not C++, though there are wrappers for it and many languages).

Mono on a Mac - what database to use? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I am getting started doing ASP.NET on my Mac using Mono, and I'm wondering which databases people have used in this setup. I'd be looking for something that is easy to set up, as this is just for fun and for continued learning of ASP.NET.
For your purposes, the SQLite version that comes with Mono (see here) seems perfect, no much how wonderful PostgreSQL (or, I guess, even MySQL;-) might be;-).
SQLite is everywhere (in .NET, in iPhones, comes with Mono, comes with Python, it's in Android, etc, etc), so getting familiar with it can hardly hurt anyway!-)
You could use MySQL - it's well documented and has .Net drivers. See http://www.mono-project.com/Database_Access for a comprehensive list with driver info.
Postgresql via MacPorts. Npgsql as the .Net driver.
Whoa... SQLite isn't installed with Mono, I don't believe; just the connector is. From the same URL the accepted answer uses to say it's there already...
Prerequisites
If you do not have SQLite, download it. There are binaries for Windows and Linux. You can put the .dll or .so along side your application binaries, or in a system-wide library path.
If you want a database that works on OS X (and elsewhere) without change or prereqs other than a recompile, C#-SQLite, an unofficial, line-by-line port of SQLite to C#, might be worth a look. There are issues with compilation (one example here from May of last year), but with some research it apparently does okay (initially it had some P/Invokes that prevented compilation on OS X (and also Silverlight) which have been removed).
Better example of compilation problems as well as some reason for optimism here:
What steps will reproduce the problem?
Compile database and SqliteClient and SqliteClientTests (works fine)
Run Test No. 1 using command "mono SqliteClientTests.exe"
Cry!
...
Comment 1 by project member market.n...#gmail.com, Sep 15, 2011 Have
you contacted Miguel de Icaza at mono about this? I forget the
details, but there were some compiler flags he set to get it working.
He told me last March that it was working. Maybe the 3.7.7.1 code set
broke some things. Did you try the 3.7.5 or 3.7.6 versions?
So do your homework, but I think once you get a good build, this might be your answer.
I've used: Firebird, MySql, SQLite, Oracle and even Postgres long long ago.

Resources