0

Does anyone know how we can use Windows library functions like for example this ms link for ms api? This is given support for .Net supported languages, but is there any way to use these functions in either JavaScript or TypeScript?

For instance, when you have a Discord application installed and you use discord web it prompts you to open in Discord app so most probably it's using the GetProcess Windows library function. So how how can I implement something like that?

I thought I could create an npm package in one of .Net supported languages, but haven't tried that yet. I'm still researching.

Update: Im tyring to use systemMediacontrols in a vs code extension thats what this is for

6
  • Do you mean in a browser? (If so, no, you can't use Windows API functions.) If not, what environment are you trying to do this in? Commented Oct 15, 2022 at 8:34
  • 1
    Just to clarify: SystemMediaTransportControls is a Windows Runtime type. It is a native system API that's unrelated to .NET or C#. As far as I understand, consuming WinRT types from JavaScript is officially supported. Windows Runtime components has a few walkthroughs that should cover the basics of consuming a WinRT type from JavaScript. Commented Oct 15, 2022 at 8:47
  • @T.J.Crowder Im actually tring to build a vs code extension that i what i need this for Commented Oct 15, 2022 at 9:17
  • @IInspectable thanks for clarifying i actually didnt change the language option and thought that it is supported in c# only and thought we can use c# or f# or vb for this.. ill check more about it thanks Commented Oct 15, 2022 at 9:19
  • A bit of historic background: Back when the Windows Runtime was introduced in Windows 8 the main design goal was to provide an API that's usable by clients written in just about any programming language. First-class support for HTML/CSS/JavaScript had been touted as The major selling point. A decade later we've come to realize: Hardly anyone uses WinRT from JavaScript, and JavaScript support is a monumental road block in progressing the WinRT infrastructure. I suppose that's why you rarely (if ever) find JavaScript in the language selector dropdown of the documentation. Commented Oct 15, 2022 at 9:50

1 Answer 1

1

I think you mean in the browser environment. No, you can't use Windows API functions in the browser environment (regardless of whether you're writing in JavaScript or one of the languages supported via Wasm), it's a very thoroughly sandboxed environment for security reasons.

For instance, when you have a Discord application installed and you use discord web it prompts you to open in Discord app so most probably it's using the GetProcess Windows library function.

It isn't. On Windows, you can install custom protocol handlers so you can have links with a custom scheme like discord://somethinghere (instead of http://somethinghere). The Discord app does that. It's possible to detect whether a custom protocol has a handler from browser code, and so a web page can tell whether you have the Discord app installed (or more accurately, whether you have a protocol handler installed for the discord: scheme). No Windows API involved (from the JavaScript/TypeScript code side; naturally, the browser is using Windows API under the covers).

Sign up to request clarification or add additional context in comments.

2 Comments

oh i didnt know that thanks ... do u know if there is anyway we can use systemmediacontrols in javascript or typescript because i was trying to build a vs code extension which uses the systemmediacontrols
@Anand - I don't know, but I will note that VS Code isn't a browser, although it uses browser technologies, it's an Electron app, which is a combination of Chrome and Node.js. That means you may well be able to use things that you can't use in a browser (at least in the main process that runs in Node.js).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.