CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2014
    Posts
    3

    Question OS compatibility issues.

    I developed a program for a video game (before you ask upon looking at the code, yes, it is an adult game) that I own that makes it a lot easier for people to use the video game's unpacking tool for making and installing mods. Unfortunately, I've already had two people report issues with the program on XP and 7. While the XP issue seems to be unsolvable until I download VS 2012 (I programmed this in VS 2010), I can't seem to find a solution to the Windows 7 compatibility issue, as all of my research would point to either re-installing the software which doesn't seem to apply here since there is no install to my program (it's a lone .exe), or putting exception handling in the code, but I would have no idea where to put it if the program is crashing on startup. Therefore I am asking if the Windows 7 compatibility issue can be found somewhere in the code itself, or if it is due to some other issue.

    The program is designed to delete and rewrite a configuration file for the game's unpacking program, and then upon rewriting the configuration file, it runs the external unpacking program.

    My OS is Windows Vista Home Premium 64-bit.

    Here is the whole program:
    Code:
    #pragma once
    
    #include <stdio.h>
    #include <msclr\marshal.h>
    #include <msclr\marshal_cppstd.h>
    #include <windows.h>
    
    namespace XSPQuickUnpacker {
    
    	using namespace System;
    	using namespace System::ComponentModel;
    	using namespace System::Collections;
    	using namespace System::Windows::Forms;
    	using namespace System::Data;
    	using namespace System::Drawing;
    	using namespace System::IO;
    	using namespace msclr::interop;
    
    	/// <summary>
    	/// Summary for Form1
    	/// </summary>
    	public ref class Form1 : public System::Windows::Forms::Form
    	{
    	public:
    		Form1(void)
    		{
    			InitializeComponent();
    			//
    			//TODO: Add the constructor code here
    			//
    		}
    
    	protected:
    		/// <summary>
    		/// Clean up any resources being used.
    		/// </summary>
    		~Form1()
    		{
    			if (components)
    			{
    				delete components;
    			}
    		}
    	private: System::Windows::Forms::TextBox^  FilePathBox;
    	protected: 
    
    	private: System::Windows::Forms::ComboBox^  StoryType;
    	private: System::Windows::Forms::Button^  StartButton;
    	private: System::Windows::Forms::RadioButton^  UnpackRadio;
    	private: System::Windows::Forms::RadioButton^  PackRadio;
    	private: System::Windows::Forms::Label^  label1;
    	private: System::Windows::Forms::Label^  label2;
    	protected: 
    
    
    	private:
    		/// <summary>
    		/// Required designer variable.
    		/// </summary>
    
    		String^ path;
    		String^ file;
    		int step;
    
    	private: System::Windows::Forms::Label^  DebugLabel;
    	private: System::Windows::Forms::Timer^  AntiFreezeTimer;
    	private: System::ComponentModel::IContainer^  components;
    
    
    
    #pragma region Windows Form Designer generated code
    		/// <summary>
    		/// Required method for Designer support - do not modify
    		/// the contents of this method with the code editor.
    		/// </summary>
    		void InitializeComponent(void)
    		{
                            this->components = (gcnew System::ComponentModel::Container());
    			this->FilePathBox = (gcnew System::Windows::Forms::TextBox());
    			this->StoryType = (gcnew System::Windows::Forms::ComboBox());
    			this->StartButton = (gcnew System::Windows::Forms::Button());
    			this->UnpackRadio = (gcnew System::Windows::Forms::RadioButton());
    			this->PackRadio = (gcnew System::Windows::Forms::RadioButton());
    			this->label1 = (gcnew System::Windows::Forms::Label());
    			this->label2 = (gcnew System::Windows::Forms::Label());
    			this->DebugLabel = (gcnew System::Windows::Forms::Label());
    			this->AntiFreezeTimer = (gcnew System::Windows::Forms::Timer(this->components));
    			this->SuspendLayout();
    			// 
    			// FilePathBox
    			// 
    			this->FilePathBox->Location = System::Drawing::Point(104, 28);
    			this->FilePathBox->Margin = System::Windows::Forms::Padding(2);
    			this->FilePathBox->Name = L"FilePathBox";
    			this->FilePathBox->Size = System::Drawing::Size(254, 20);
    			this->FilePathBox->TabIndex = 0;
    			// 
    			// StoryType
    			// 
    			this->StoryType->FormattingEnabled = true;
    			this->StoryType->Items->AddRange(gcnew cli::array< System::Object^  >(5) {L"pack0", L"Dungeon", L"Tentacle Dreams", L"Tentacle Dreams (Fast Sex)", 
    				L"Test"});
    			this->StoryType->Location = System::Drawing::Point(9, 28);
    			this->StoryType->Margin = System::Windows::Forms::Padding(2);
    			this->StoryType->Name = L"StoryType";
    			this->StoryType->Size = System::Drawing::Size(92, 21);
    			this->StoryType->TabIndex = 2;
    			this->StoryType->Tag = L"";
    			// 
    			// StartButton
    			// 
    			this->StartButton->Location = System::Drawing::Point(502, 27);
    			this->StartButton->Margin = System::Windows::Forms::Padding(2);
    			this->StartButton->Name = L"StartButton";
    			this->StartButton->Size = System::Drawing::Size(56, 19);
    			this->StartButton->TabIndex = 3;
    			this->StartButton->Text = L"Start!";
    			this->StartButton->UseVisualStyleBackColor = true;
    			this->StartButton->Click += gcnew System::EventHandler(this, &Form1::StartButton_Click);
    			// 
    			// UnpackRadio
    			// 
    			this->UnpackRadio->AutoSize = true;
    			this->UnpackRadio->Location = System::Drawing::Point(362, 28);
    			this->UnpackRadio->Margin = System::Windows::Forms::Padding(2);
    			this->UnpackRadio->Name = L"UnpackRadio";
    			this->UnpackRadio->Size = System::Drawing::Size(77, 17);
    			this->UnpackRadio->TabIndex = 4;
    			this->UnpackRadio->TabStop = true;
    			this->UnpackRadio->Text = L"Unpacking";
    			this->UnpackRadio->UseVisualStyleBackColor = true;
    			// 
    			// PackRadio
    			// 
    			this->PackRadio->AutoSize = true;
    			this->PackRadio->Location = System::Drawing::Point(439, 28);
    			this->PackRadio->Margin = System::Windows::Forms::Padding(2);
    			this->PackRadio->Name = L"PackRadio";
    			this->PackRadio->Size = System::Drawing::Size(64, 17);
    			this->PackRadio->TabIndex = 5;
    			this->PackRadio->TabStop = true;
    			this->PackRadio->Text = L"Packing";
    			this->PackRadio->UseVisualStyleBackColor = true;
    			// 
    			// label1
    			// 
    			this->label1->AutoSize = true;
    			this->label1->Location = System::Drawing::Point(10, 10);
    			this->label1->Margin = System::Windows::Forms::Padding(2, 0, 2, 0);
    			this->label1->Name = L"label1";
    			this->label1->Size = System::Drawing::Size(64, 13);
    			this->label1->TabIndex = 6;
    			this->label1->Text = L"Story Select";
    			// 
    			// label2
    			// 
    			this->label2->AutoSize = true;
    			this->label2->Location = System::Drawing::Point(104, 10);
    			this->label2->Margin = System::Windows::Forms::Padding(2, 0, 2, 0);
    			this->label2->Name = L"label2";
    			this->label2->Size = System::Drawing::Size(55, 13);
    			this->label2->TabIndex = 7;
    			this->label2->Text = L"Root Path";
    			// 
    			// DebugLabel
    			// 
    			this->DebugLabel->AutoSize = true;
    			this->DebugLabel->Location = System::Drawing::Point(13, 105);
    			this->DebugLabel->Name = L"DebugLabel";
    			this->DebugLabel->Size = System::Drawing::Size(27, 13);
    			this->DebugLabel->TabIndex = 8;
    			this->DebugLabel->Text = L"Idle.";
    			// 
    			// AntiFreezeTimer
    			// 
    			this->AntiFreezeTimer->Interval = 250;
    			this->AntiFreezeTimer->Tick += gcnew System::EventHandler(this, &Form1::AntiFreezeTimer_Tick);
    			// 
    			// Form1
    			// 
    			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
    			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
    			this->ClientSize = System::Drawing::Size(569, 130);
    			this->Controls->Add(this->DebugLabel);
    			this->Controls->Add(this->label2);
    			this->Controls->Add(this->label1);
    			this->Controls->Add(this->PackRadio);
    			this->Controls->Add(this->UnpackRadio);
    			this->Controls->Add(this->StartButton);
    			this->Controls->Add(this->StoryType);
    			this->Controls->Add(this->FilePathBox);
    			this->Margin = System::Windows::Forms::Padding(2);
    			this->Name = L"Form1";
    			this->Text = L"XSP Quick Packer/Unpacker";
    			this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
    			this->ResumeLayout(false);
    			this->PerformLayout();
    		}
    #pragma endregion
    	private: System::Void StartButton_Click(System::Object^  sender, System::EventArgs^  e)
    			 {
    				path=this->FilePathBox->Text;
    
    				if (!File::Exists(path+"\\filemaker\\start.ini"))
    				{
    					FileStream^ fs=File::Create(path+"\\filemaker\\start.ini");
    					delete fs;
    				}
    				else
    				{
    					marshal_context^ context=gcnew marshal_context();
    					String^ filepath=path+"\\filemaker\\start.ini";
    					const char* temp;
    					temp=context->marshal_as<const char*>(filepath);
    					DeleteFile(temp);
    					delete context;
    				}
    
    				path=path->Replace('\\', '/');
    
    				if(this->UnpackRadio->Checked==true)//UNPACKING
    				{
    					if(this->StoryType->SelectedItem=="pack0")
    					{
    						file="pack0";
    
    						WriteUnpackToFile();
    					}
    					else if(this->StoryType->SelectedItem=="Dungeon")
    					{
    						file="pack_dungeon";
    
    						WriteUnpackToFile();
    					}
    					else if(this->StoryType->SelectedItem=="Tentacle Dreams")
    					{
    						file="pack_tentacle_dreams";
    
    						WriteUnpackToFile();
    					}
    					else if(this->StoryType->SelectedItem=="Tentacle Dreams (Fast Sex)")
    					{
    						file="pack_tentacle_fast";
    
    						WriteUnpackToFile();
    					}
    					else if(this->StoryType->SelectedItem=="Test")
    					{
    						file="pack_test";
    
    						WriteUnpackToFile();
    					}
    					else
    					{
    						this->DebugLabel->Text="ERROR: Invalid story selection!";
    					}
    				}
    				else if(this->PackRadio->Checked==true)//PACKING
    				{
    					if(this->StoryType->SelectedItem=="pack0")
    					{
    						file="pack0";
    
    						WritePackToFile();
    					}
    					else if(this->StoryType->SelectedItem=="Dungeon")
    					{
    						file="pack_dungeon";
    
    						WritePackToFile();
    					}
    					else if(this->StoryType->SelectedItem=="Tentacle Dreams")
    					{
    						file="pack_tentacle_dreams";
    
    						WritePackToFile();
    					}
    					else if(this->StoryType->SelectedItem=="Tentacle Dreams (Fast Sex)")
    					{
    						file="pack_tentacle_fast";
    
    						WritePackToFile();
    					}
    					else if(this->StoryType->SelectedItem=="Test")
    					{
    						file="pack_test";
    
    						WritePackToFile();
    					}
    					else
    					{
    						this->DebugLabel->Text="ERROR: Invalid story selection!";
    					}
    				}
    			 }
    private: System::Void AntiFreezeTimer_Tick(System::Object^  sender, System::EventArgs^  e)
    		 {
    			 if(step==0)
    			 {
    				 this->DebugLabel->Text="Writing to file";
    				 step+=1;
    			 }
    			 else if(step==1)
    			 {
    				 this->DebugLabel->Text="Writing to file.";
    				 step+=1;
    			 }
    			 else if(step==2)
    			 {
    				 this->DebugLabel->Text="Writing to file..";
    				 step+=1;
    			 }
    			 else if(step==3)
    			 {
    				 this->DebugLabel->Text="Writing to file...";
    				 step=0;
    			 }
    		 }
    private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e)
    		 {
    			 step=0;
    		 }
    
    void WriteUnpackToFile()
    {
    	StreamWriter^ sw = gcnew StreamWriter(path+"\\filemaker\\start.ini", true);
    
    	AntiFreezeTimer->Enabled=true;
    	
    	sw->WriteLine("Pack pack1");
    	sw->WriteLine("{");
    	sw->WriteLine("     unpack = true;");
    	sw->WriteLine("     file    = \""+path+"/pack/"+file+".bin\";");
    	sw->WriteLine("     outpath = \""+path+"/pack/\""";");
    	sw->WriteLine("}");
    	
    	AntiFreezeTimer->Enabled=false;
    
    	this->DebugLabel->Text="Opening filemaker.exe";
    	
    	delete sw;
    
    	marshal_context^ context=gcnew marshal_context();
    	String^ filepath=path+"\\filemaker\\filemaker.exe";
    	filepath=filepath->Replace('/', '\\');
    	filepath="\""+filepath+"\"";
    	const char* temp;
    	temp=context->marshal_as<const char*>(filepath);
    	system(temp);
    	delete context;
    
    	this->DebugLabel->Text="Opened "+filepath;
    }
    void WritePackToFile()
    {
    	StreamWriter^ sw = gcnew StreamWriter(path+"\\filemaker\\start.ini", true);
    
    	AntiFreezeTimer->Enabled=true;
    	
    	sw->WriteLine("Pack pack");
    	sw->WriteLine("{");
    	sw->WriteLine("		file     = \""+path+"/pack/"+file+".bin\";");
    	sw->WriteLine("     zip       = true;");
    	sw->WriteLine("     path_full = true;");
    	sw->WriteLine("     addpath = \""+path+"/pack/"+file+"/*.*\";");
    	sw->WriteLine("}");
    	
    	AntiFreezeTimer->Enabled=false;
    
    	this->DebugLabel->Text="Opening filemaker.exe";
    	
    	delete sw;
    
    	marshal_context^ context=gcnew marshal_context();
    	String^ filepath=path+"\\filemaker\\filemaker.exe";
    	filepath=filepath->Replace('/', '\\');
    	filepath="\""+filepath+"\"";
    	const char* temp;
    	temp=context->marshal_as<const char*>(filepath);
    	system(temp);
    	delete context;
    
    	this->DebugLabel->Text="Opened "+filepath;
    }
    	
    };
    }
    Here is what the Windows 7 user reported when the program crashed (it's translated from French, in case that causes some confusion):

    Code:
    Problem signature:
    Problem Event Name: APPCRASH
    Application Name: XSP Quick Packer-Unpacker.exe
    Application Version: 0.0.0.0
    Timestamp app: 54891aad
    Default Module Name: kernelbase.dll
    Version of the default module: 6.1.7601.18409
    Timestamp default module: 53159a86
    The exception code: e0434352
    Shifting the exception 0000c42d
    OS Version: 6.1.7601.2.1.0.256.1
    Locale ID: 1036
    Additional Information 1: 0a9e
    Additional Information 2: 0a9e372d3b4ad19135b953a78882e789
    Additional Information 3: 0a9e
    Additional Information 4: 0a9e372d3b4ad19135b953a78882e789

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: OS compatibility issues.

    There are many things that can go wrong, one such thing is a change in permissions to various folders where files are stored. Does the user enter a path to the file or is this auto-generated? It could be something as simple as the app not having permissions to write to the file location. It's hard to tell from the code, but you may need to check for errors and add some logging to the app.

  3. #3
    Join Date
    Dec 2014
    Posts
    3

    Re: OS compatibility issues.

    Quote Originally Posted by Arjay View Post
    There are many things that can go wrong, one such thing is a change in permissions to various folders where files are stored. Does the user enter a path to the file or is this auto-generated? It could be something as simple as the app not having permissions to write to the file location. It's hard to tell from the code, but you may need to check for errors and add some logging to the app.
    No, the path isn't auto-generated, as the user needs to tell the program where their game is installed, only the little end bits are generated for the specific areas in the game's main folder. While permission issues could be a problem, the users were reporting that my program would crash on start up, and not when the program's file writing is executed (which is via a button press), so the current issues that users are having can't be related to file permissions.

  4. #4
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: OS compatibility issues.

    Quote Originally Posted by TheMohawkNinja View Post
    No, the path isn't auto-generated, as the user needs to tell the program where their game is installed, only the little end bits are generated for the specific areas in the game's main folder. While permission issues could be a problem, the users were reporting that my program would crash on start up, and not when the program's file writing is executed (which is via a button press), so the current issues that users are having can't be related to file permissions.
    I didn't expect to guess on the first try, so here's what you need to do:

    >> ..., but you may need to check for errors and add some logging to the app.

  5. #5
    Join Date
    Dec 2014
    Posts
    3

    Re: OS compatibility issues.

    Quote Originally Posted by Arjay View Post
    I didn't expect to guess on the first try, so here's what you need to do:

    >> ..., but you may need to check for errors and add some logging to the app.
    Well, I'll put some try and catch statements around what's inside the form1_load event, since it's crashing on startup and just have it catch all exceptions for now just to see if that is where it's actually crashing.

    Is there a way to log stuff without using filestreams and stuff like that, as if it is crashing on startup, I highly doubt it will write anything to a text file if I code in a filestream for writing logging text to a text file.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured