Sign in to follow this  
Guest A_Delta_Sierra

VB and the aircraft.cfg file

Recommended Posts

I am trying to develop an application to modify the aircraft.cfg file through a VB GUI. Can anyone give me ideas or lead me to some documentation that could help me get started. Thanks,

Share this post


Link to post
Share on other sites
Help AVSIM continue to serve you!
Please donate today!

Get the Aircraft SDK from Microsoft. It has most of the parameters that can go in the aircraft.cfg file.Matt

Share this post


Link to post
Share on other sites

Pretty easy thing, you want to do. The hard thing--to code it considering all the parameters you have in a typical aircraft.cfg. I use a simple API call to read and write .txt files like .cfg and .ini files. It first must be declared with these statements (for both reading and writing)Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As LongDeclare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As LongHere's an example of the Write function in use:dummy = WritePrivateProfileString("flight_tuning", "elevator_effectiveness", "2.0", ".aircraft.cfg")Breaking this down into English, you'll recognize "flight_tuning" as the header of a section of an aircraft.cfg. "Elevator_effectiveness" is one of the variables within. "2.0" is the value I want to write, and the last is the filename I'm writing to.Only difference between writing the data and getting the data, is during the "get", you'll want to read the variable value into your program, to populate the appropriate field.Here is a breakdown of the variable meanings in the declaration:lpAppName$ Name of a Windows-based application that appears in the initialization file.(Note: For your purposes, this would be the name of the section heading, such as "flight_tuning")lpKeyName$Key name that appears in the initialization file.nDefault$Specifies the default value for the given key if the key cannot be found in the initialization file.lpFileName$ Points to a string that names the initialization file. If lpFileName does not contain a path to the file, Windows searches for the file in the Windows directory.lpDefault$ Specifies the default value for the given key if the key cannot be found in the initialization file.lpReturnedString$Specifies the buffer that receives the character string.(note: IOTW, this is the variable you store the string in)nSize% Specifies the maximum number of characters (including the last null character) to be copied to the buffer.lpString$ Specifies the string that contains the new key value.I hope this helps a bit....Regards,John

Share this post


Link to post
Share on other sites

Save yourself some trouble and make sure what you want to do has not been done already and is available as freeware.

Share this post


Link to post
Share on other sites

John,Thanks for the help. This is enough to get me started. I am not going to make anything for release until I can prove its' worth to me and it hasn't been done as freeware, well it might have been, but hasn't been done correctly yet. Thanks again for the help.

Share this post


Link to post
Share on other sites

Along these lines, early this week I was looking at brining all of the aircraft.cfg data for all of the planes, not many right now since replacement of drive c, into an ACESS/Excel data file for quick and handy reference for use when adjusting the parameters.I decided if was too much work for a summer job. Everything is too much for summer. ;-)Regards,Bob

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this