Skip to content
View in the app

A better way to browse. Learn more.

The AVSIM Community

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

C# Reading FileName from SimConnect

Featured Replies

This doesn't work. Can aynone help?using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using Microsoft.FlightSimulator.SimConnect;using System.Runtime.InteropServices;namespace SimConnectFileNameReader_T1{ public partial class Form1 : Form { SimConnect simconnect; const int WM_USER_SIMCONNECT = 0x0402; public Form1() { InitializeComponent(); } enum DEFINITIONS { Struct1, } enum DATA_REQUESTS { REQUEST_1, }; [structLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)] struct Struct1 { // this is how you declare a fixed size string [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] public String szFileName; public uint dwFlags; }; private void button_Connect_Click(object sender, EventArgs e) { try { simconnect = new SimConnect("SimConnectFileNameTest1", this.Handle, WM_USER_SIMCONNECT, null, 0); textbox_Connect.Text = "Connected to FSX."; simconnect.AddToDataDefinition(DEFINITIONS.Struct1, "szFileName", null, SIMCONNECT_DATATYPE.STRING256, 0.0f, SimConnect.SIMCONNECT_UNUSED); simconnect.RegisterDataDefineStruct(DEFINITIONS.Struct1); simconnect.OnRecvEventFilename += new SimConnect.RecvEventFilenameEventHandler(simconnect_OnRecvEventFilename); } catch (COMException ex) { textbox_Connect.Text = "Error connecting to FSX."; } } void simconnect_OnRecvEventFilename(SimConnect sender, SIMCONNECT_RECV_EVENT_FILENAME data) { switch ((DATA_REQUESTS)data.uEventID) { case DATA_REQUESTS.REQUEST_1: textBox_FileName.Text = data.szFileName; break; } } protected override void DefWndProc(ref Message m) { if (m.Msg == WM_USER_SIMCONNECT) { if (simconnect != null) { simconnect.ReceiveMessage(); } } else { base.DefWndProc(ref m); } } }}Thank you very much!

Sorry that I saw this so late tonight, I'll take a look tomorrow morning and see what's up.

I might be blind or so (it's 4am) but you don't send any requests or setup any system events that you want to receive.For example you could do something like that (after connecting):simconnet.SubscribeToSystemEvent(MyEventIDEnum.FlightLoaded, "FlightLoaded")simconnet.SubscribeToSystemEvent(MyEventIDEnum.FlightSaved, "FlightSaved")simconnect.SubscribeToSystemEvent(MyEventIDEnum.AircraftLoaded, "AircraftLoaded")simconnect.SubscribeToSystemEvent(MyEventIDEnum.FlightPlanActivated, "FlightPlanActivated")This will sooner or later reward you with a bunch of filename events.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.