| Thread overview | |||||||||
|---|---|---|---|---|---|---|---|---|---|
|
January 07, 2015 Conditional Compilation for Specific Windows | ||||
|---|---|---|---|---|
| ||||
I'm looking at the Windows multicast API. It has different socket options depending on if you are on Windows XP or Windows Vista (and later). Is there a way to tell at runtime which version of windows you are on? Note: I'm specifically talking about runtime because I want the same binary to run on all windows versions so I have to support both and determine which one I am running on at runtime. | ||||
January 07, 2015 Re: Conditional Compilation for Specific Windows | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Jonathan Marler | On 2015-01-07 19:27, Jonathan Marler wrote: > I'm looking at the Windows multicast API. It has different socket > options depending on if you are on Windows XP or Windows Vista (and > later). Is there a way to tell at runtime which version of windows you > are on? Note: I'm specifically talking about runtime because I want the > same binary to run on all windows versions so I have to support both and > determine which one I am running on at runtime. Use the regular system API's as you would in C. Should be easy to find if you search the web. -- /Jacob Carlborg | |||
January 07, 2015 Re: Conditional Compilation for Specific Windows | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Jacob Carlborg | On Wednesday, 7 January 2015 at 18:50:40 UTC, Jacob Carlborg wrote: > On 2015-01-07 19:27, Jonathan Marler wrote: >> I'm looking at the Windows multicast API. It has different socket >> options depending on if you are on Windows XP or Windows Vista (and >> later). Is there a way to tell at runtime which version of windows you >> are on? Note: I'm specifically talking about runtime because I want the >> same binary to run on all windows versions so I have to support both and >> determine which one I am running on at runtime. > > Use the regular system API's as you would in C. Should be easy to find if you search the web. They are the regular system APIs. They change depending on which version of windows you are on (http://msdn.microsoft.com/en-us/library/windows/desktop/ms738558(v=vs.85).aspx). Again, how do I determine which version of windows I am on? My code will default to using the new API (because it is the most efficient), but then will fall back to using the old API if it can detect that the current version of Windows does not support the new API. | |||
January 07, 2015 Re: Conditional Compilation for Specific Windows | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Jacob Carlborg | On Wednesday, 7 January 2015 at 18:50:40 UTC, Jacob Carlborg wrote:
> On 2015-01-07 19:27, Jonathan Marler wrote:
>> I'm looking at the Windows multicast API. It has different socket
>> options depending on if you are on Windows XP or Windows Vista (and
>> later). Is there a way to tell at runtime which version of windows you
>> are on? Note: I'm specifically talking about runtime because I want the
>> same binary to run on all windows versions so I have to support both and
>> determine which one I am running on at runtime.
>
> Use the regular system API's as you would in C. Should be easy to find if you search the web.
Oh wait a second, I misunderstood you. You were talking about using the regular Windows APIs to determine which version of windows I am running on. I was going to do that but I wanted to check if D has created a wrapping for that or uses a particular convention.
| |||
January 07, 2015 Re: Conditional Compilation for Specific Windows | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Jacob Carlborg | On Wednesday, 7 January 2015 at 18:50:40 UTC, Jacob Carlborg wrote: > On 2015-01-07 19:27, Jonathan Marler wrote: >> I'm looking at the Windows multicast API. It has different socket >> options depending on if you are on Windows XP or Windows Vista (and >> later). Is there a way to tell at runtime which version of windows you >> are on? Note: I'm specifically talking about runtime because I want the >> same binary to run on all windows versions so I have to support both and >> determine which one I am running on at runtime. > > Use the regular system API's as you would in C. Should be easy to find if you search the web. I've looked up the windows version helper functions (http://msdn.microsoft.com/en-us/library/windows/desktop/dn424972(v=vs.85).aspx). The problem is that these functions are not defined in DMD's user32.lib. I could use the operating system's user32.lib but it is in COFF format, so I would have to convert my D object files to COFF and then compile using MSVC or GNU GCC for windows (or I could try converting the OS user32.lib to OMF). Or, I could add the functions to DMD's user32.lib but as far as I know this is a private binary managed by Digital Mars that I can't contribute to? Am I wrong? Does anyone else have a solution or an idea on this? Note: I've wanted to use other windows function in the past that were missing from DMD's user32.lib file. A solution to solve this for multiple functions would be ideal, thanks. | |||
January 07, 2015 Re: Conditional Compilation for Specific Windows | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Jonathan Marler | On Wednesday, 7 January 2015 at 19:48:16 UTC, Jonathan Marler wrote: > On Wednesday, 7 January 2015 at 18:50:40 UTC, Jacob Carlborg wrote: >> On 2015-01-07 19:27, Jonathan Marler wrote: >>> I'm looking at the Windows multicast API. It has different socket >>> options depending on if you are on Windows XP or Windows Vista (and >>> later). Is there a way to tell at runtime which version of windows you >>> are on? Note: I'm specifically talking about runtime because I want the >>> same binary to run on all windows versions so I have to support both and >>> determine which one I am running on at runtime. >> >> Use the regular system API's as you would in C. Should be easy to find if you search the web. > > I've looked up the windows version helper functions (http://msdn.microsoft.com/en-us/library/windows/desktop/dn424972(v=vs.85).aspx). > The problem is that these functions are not defined in DMD's user32.lib. I could use the operating system's user32.lib but it is in COFF format, so I would have to convert my D object files to COFF and then compile using MSVC or GNU GCC for windows (or I could try converting the OS user32.lib to OMF). Or, I could add the functions to DMD's user32.lib but as far as I know this is a private binary managed by Digital Mars that I can't contribute to? Am I wrong? Does anyone else have a solution or an idea on this? > > Note: I've wanted to use other windows function in the past that were missing from DMD's user32.lib file. A solution to solve this for multiple functions would be ideal, thanks. You could bypass user32.lib by using directly user32.dll via LoadLibrary()/GetProcAddress(). -- Paulo | |||
January 08, 2015 Re: Conditional Compilation for Specific Windows | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Jonathan Marler | On 2015-01-07 20:48, Jonathan Marler wrote: > I've looked up the windows version helper functions > (http://msdn.microsoft.com/en-us/library/windows/desktop/dn424972(v=vs.85).aspx). > The problem is that these functions are not defined in DMD's > user32.lib. I could use the operating system's user32.lib but it is in > COFF format, so I would have to convert my D object files to COFF and > then compile using MSVC or GNU GCC for windows (or I could try > converting the OS user32.lib to OMF). Or, I could add the functions to > DMD's user32.lib but as far as I know this is a private binary managed > by Digital Mars that I can't contribute to? Am I wrong? Does anyone > else have a solution or an idea on this? > > Note: I've wanted to use other windows function in the past that were > missing from DMD's user32.lib file. A solution to solve this for > multiple functions would be ideal, thanks. You can either: 1. Convert an up to date user32.lib to OMF 2. Create your own user32.lib from the DLL 3. Compile using the COFF format and use the Visual Studio runtime instead. This has been recently added (I'm not sure if it's released yet) and requires using a flag -- /Jacob Carlborg | |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply