topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • January 25, 2020, 08:34 PM
  • Proudly celebrating 14 years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Codebyte [ switch to compact view ]

Pages: prev1 2 3 4 5 [6]
126
Developer's Corner / Peer-2-Peer app
« on: February 26, 2008, 09:55 AM »
Alright, so I have been thinking about creating an application that can use a socket to communicate text and files and things... I have been wandering what component to use... I use the new RAD CodeGear C++ Builder... Im not to familiar with networking but all of the applications that I have been developing usually use an additional server application to do anything... Is there a socket (UDP, TCP/IP...etc) that supports these capabilities and which is the best to use? I dont want to run into errors with firewalls or anything either... What kind of work am i getting myself into? Whats the best way to go into this? Any ideas?

127
Developer's Corner / Re: My Application...
« on: January 22, 2008, 11:06 AM »
ok, looking into that now. Thank you for all the time spent and sorry for the late response. Things got crazy with college.

128
Developer's Corner / Re: My Application...
« on: January 11, 2008, 12:16 PM »
lol, any ideas as to why that error occurs?

129
Developer's Corner / Re: My Application...
« on: January 10, 2008, 08:26 PM »
Alright, so to be completely honest... I dont know how this coding will look but please dont kill me... Im a novice... lol! Here is the complete coding... Also, keep in mind that it's no where near finished... I also tried to learn the coding for the threading so bear with me...

Code: C++ [Select]
  1. //---------------------------------------------------------------------------
  2.  
  3. #include <vcl.h>
  4. #pragma hdrstop
  5.  
  6. #include "Unit1.h"
  7. #include "registry.hpp"
  8. //---------------------------------------------------------------------------
  9. #pragma package(smart_init)
  10. #pragma link "IdExplicitTLSClientServerBase"
  11. #pragma resource "*.dfm"
  12. TForm1 *Form1;
  13. HANDLE Thread;
  14. int CurrentVersion, counter = 0, ServerVersionOnWeb;
  15. int downloadrate = 0, currentdownloadtotal = 0, previousdownloadtotal = 0, downloadtime = 0, totalrate = 0;
  16. int totaldownloadtotal = 0;
  17. String filename;
  18. bool required = false;
  19. bool start_install = false;
  20. //---------------------------------------------------------------------------
  21. DWORD WINAPI ThreadFunction(LPVOID Param)
  22. {
  23.    //if Memo2 has anything in it, start downloading
  24.    do
  25.    {
  26.            try
  27.            {
  28.                    filename = Form1->Memo2->Lines->Strings[0];
  29.                    //get size and update progressbar
  30.                    Form1->ProgressBar2->Max = Form1->FTP1->Size(filename);
  31.                    Form1->ProgressBar2->Position = 0;
  32.                    Form1->FTP1->Get(filename, filename, true, false);
  33.            }
  34.            catch(...)
  35.            {
  36.                    Form1->FTP1->Abort();
  37.                    Form1->FTP1->Disconnect();
  38.                    Application->Terminate();
  39.            };
  40.    }
  41.    while(Form1->Memo2->Lines->Strings[0] != "");
  42.    if(Form1->Memo2->Lines->Strings[0] == "")
  43.    {
  44.            required = false;
  45.            Form1->Label1->Caption = "Overall Progress: Download Complete!";
  46.            Form1->ProgressBar1->Position += 1;
  47.            Form1->Timer1->Enabled = false;
  48.            Form1->Label2->Caption = "File Progress: ";
  49.            //start next process
  50.        start_install = true;
  51.            SuspendThread(Thread);
  52.    }
  53. }
  54. //---------------------------------------------------------------------------
  55. void ExitApp(void)
  56. {
  57.         try
  58.         {
  59.            //Free all open resources, then exit the app
  60.            Form1->FTP1->Abort();
  61.            Form1->FTP1->Disconnect();
  62.            Application->Terminate();
  63.         }
  64.         catch(...){};
  65. }
  66. //---------------------------------------------------------------------------
  67. void FilterMemo12(void)
  68. {
  69.         //filter Memo1
  70.         int x = 0;
  71.         do
  72.         {
  73.                 if(Form1->Memo1->Lines->Strings[x] == "")
  74.                 {
  75.                         Form1->Memo1->Lines->Delete(x);
  76.                 }
  77.                 else
  78.                 {
  79.             x++;
  80.                 }
  81.         }
  82.         while(x < Form1->Memo1->Lines->Count);
  83.         //repeat the process for Memo2
  84.         x = 0;
  85.         do
  86.         {
  87.                 if(Form1->Memo2->Lines->Strings[x] == "")
  88.                 {
  89.                         Form1->Memo2->Lines->Delete(x);
  90.                 }
  91.                 else
  92.                 {
  93.             x++;
  94.                 }
  95.         }
  96.         while(x < Form1->Memo2->Lines->Count);
  97.         //now allow Threading Process to begin
  98.         Form1->Label1->Caption = "Overall Progress: Downloading Updates...";
  99.         Form1->ProgressBar1->Position += 1;
  100.         Form1->Timer1->Enabled = true;
  101.         Form1->ProgressBar1->Max += Form1->Memo2->Lines->Count;
  102.         required = true;
  103.         //Set Cursor to beginning of Memo1, so user can see top of Memo
  104.         ResumeThread(Thread);
  105. }
  106. //---------------------------------------------------------------------------
  107. void CompareVersions(void)
  108. {
  109.         //Compare CurrentVersion and ServerVersionOnWeb
  110.         if(CurrentVersion >= ServerVersionOnWeb)
  111.         {
  112.                 //close program and launch vsu
  113.                 ExitApp();
  114.                 ShellExecute(GetDesktopWindow(), "open", "VSU.exe", NULL, NULL, SW_SHOWNORMAL);
  115.         }
  116.         else if(CurrentVersion < ServerVersionOnWeb)
  117.         {
  118.                 //VSU needs to be updated, download nufls.vor, swn.vor
  119.                 //after these files are downloaded, then begin to download the files
  120.                 //contained in "nufls.vor"
  121.                 try
  122.                 {
  123.                         Form1->Label1->Caption = "Overall Progress: Preparing Information...";
  124.                         Form1->ProgressBar1->Position += 1;
  125.                         Form1->ProgressBar2->Max = Form1->FTP1->Size("nufls.vor");
  126.                         required = false;
  127.                         Form1->FTP1->Get("nufls.vor", "nufls.vor", true, false);
  128.                         Form1->ProgressBar2->Max = Form1->FTP1->Size("swn.vor");
  129.                         Form1->FTP1->Get("swn.vor", "swn.vor", true, false);
  130.                         //done downloading important updates, now begin showing them and
  131.                         //preparing data for final update process
  132.                         Form1->Memo2->Clear();
  133.                         Form1->Memo2->Lines->LoadFromFile("nufls.vor");
  134.                         Form1->Memo1->Clear();
  135.                         Form1->Memo1->Lines->LoadFromFile("swn.vor");
  136.                         //done displaying content, now filter spaces in memo1, memo2
  137.                         FilterMemo12();
  138.                 }
  139.                 catch(...)
  140.                 {
  141.             ExitApp();
  142.         }
  143.     }
  144. }
  145. //---------------------------------------------------------------------------
  146. void FTPConnect(void)
  147. {
  148.         //Connect to FTP
  149.         try
  150.         {
  151.                 Form1->FTP1->Connect();
  152.         }
  153.         catch(...)
  154.         {
  155.         ExitApp();
  156.     }  
  157. }
  158. //---------------------------------------------------------------------------
  159. void CheckRegistry(void)
  160. {
  161.    //Check the registry for the current server version installed on the
  162.    //system, so we can come back and check to see if the current version is
  163.    //more recent than the latest update or not.
  164.    Form1->Label1->Caption = "Overall Progress: Checking Registry...";
  165.    Form1->ProgressBar1->Position += 1;
  166.    TRegistry *Reg = new TRegistry();
  167.    Reg->RootKey = HKEY_LOCAL_MACHINE;
  168.    AnsiString temp;
  169.    char gSerial[40];
  170.    if(Reg->KeyExists("SOFTWARE\\VSU"))
  171.    {
  172.            //try to open the key and read from it
  173.            try
  174.            {
  175.                    //
  176.                    if(Reg->OpenKey("SOFTWARE\\VSU", FALSE))
  177.                    {
  178.                            //key has been opened now begin reading
  179.                            temp = Reg->ReadString("ServerVersion");
  180.                            strcpy(gSerial, temp.c_str());
  181.                            Reg->CloseKey();
  182.                            CurrentVersion = StrToInt(gSerial);
  183.                            //RETRIEVED THE KEY, NOW CONTINUE WITH PROCESS
  184.                            Form1->Show();
  185.                            Form1->FTPConnectTimer->Enabled = true;
  186.                    }
  187.                    else
  188.                    {
  189.                            //could not open the key for 2 reasons
  190.                            //1) Vista needs to run the program with administrative rights
  191.                            //2) no idea lol
  192.                            /*                     close or no??                       */
  193.                            ExitApp();
  194.                    }
  195.            }
  196.            catch(...)
  197.            {
  198.                    //could not open the key and read from it, close the program
  199.                    ExitApp();
  200.            };
  201.    }
  202.    else
  203.    {
  204.            //could not open the key, because it probably does not exist
  205.            CurrentVersion = 0;
  206.            Form1->Show();
  207.            Form1->FTPConnectTimer->Enabled = true;
  208.    }
  209. }
  210. //---------------------------------------------------------------------------
  211. __fastcall TForm1::TForm1(TComponent* Owner)
  212.         : TForm(Owner)
  213. {
  214.    DWORD Id;
  215.    Thread = CreateThread(0, 0, ThreadFunction, Form1->Handle, CREATE_SUSPENDED, &Id);
  216.    if(!Thread)
  217.    {
  218.                 //ADD CODING FOR WHAT TO DO WHEN THREAD CANNOT BE CREATED
  219.                 Application->Terminate();
  220.    }
  221.    else
  222.    {
  223.                 //BEGIN PROCESSING
  224.                 CheckRegistry();
  225.    }
  226. }
  227. //---------------------------------------------------------------------------
  228. void __fastcall TForm1::FTP1AfterClientLogin(TObject *Sender)
  229. {
  230.    Form1->Label1->Caption = "Overall Progress: Connected to the VSU Network!";
  231.    ProgressBar1->Position += 1;
  232.    //Client has connected, begin the process of file downloads
  233.    try
  234.    {
  235.            //try to get the csv.vor file
  236.            ProgressBar2->Max = FTP1->Size("csv.vor");
  237.            //tell the FTP component that this is not a required file
  238.            required = false;
  239.            Form1->Show();
  240.            FTP1->Get("csv.vor", "csv.vor", true, false);
  241.            Memo3->Clear();
  242.            Memo3->Lines->LoadFromFile("csv.vor");
  243.            ServerVersionOnWeb = StrToInt(Memo3->Lines->Strings[0]);
  244.            CompareVersions();
  245.    }
  246.    catch(...)
  247.    {
  248.        ExitApp();
  249.    };
  250. }
  251. //---------------------------------------------------------------------------
  252.  
  253. void __fastcall TForm1::FTP1WorkEnd(TObject *ASender, TWorkMode AWorkMode)
  254. {
  255.    //check to see if the file that was downloaded was a required file for the updater
  256.    if(required == true)
  257.    {
  258.            Memo2->Lines->Delete(0);
  259.            totaldownloadtotal += ProgressBar2->Max;
  260.            ProgressBar1->Position += 1;
  261.    }
  262. }
  263. //---------------------------------------------------------------------------
  264.  
  265. void __fastcall TForm1::FTP1Work(TObject *ASender, TWorkMode AWorkMode,
  266.       int AWorkCount)
  267. {
  268.    ProgressBar2->Position = AWorkCount;
  269. }
  270. //---------------------------------------------------------------------------
  271. void __fastcall TForm1::FTPConnectTimerTimer(TObject *Sender)
  272. {
  273.    FTPConnectTimer->Enabled = false;
  274.    FTPConnect();
  275. }
  276. //---------------------------------------------------------------------------
  277.  
  278. void __fastcall TForm1::Timer1Timer(TObject *Sender)
  279. {
  280.   try
  281.   {
  282.         downloadtime += 1;
  283.         currentdownloadtotal = ProgressBar2->Position;
  284.         totalrate += (totaldownloadtotal + currentdownloadtotal) - previousdownloadtotal;
  285.         previousdownloadtotal = totaldownloadtotal + currentdownloadtotal;
  286.         downloadrate = totalrate / downloadtime;
  287.         Form1->Label2->Caption = "File Progress: "+filename+"... "+IntToStr(downloadrate/1024)+" KB/Second...";
  288.   }
  289.   catch(...){};
  290. }
  291. //---------------------------------------------------------------------------
  292.  
  293. void __fastcall TForm1::Timer2Timer(TObject *Sender)
  294. {
  295.         if(start_install == true)
  296.         {
  297.                 //
  298.                 Timer2->Enabled = false;
  299.                 Label1->Caption = "Overall Progress: Installing Files...";
  300.                 //begin the installation process by calling 'sinsall.bat'
  301.                 ShellExecute(GetDesktopWindow(), "open", "sinstall.bat", NULL, NULL, SW_HIDE);
  302.                 //begin timer
  303.                 Timer3->Enabled = true;
  304.     }  
  305. }
  306. //---------------------------------------------------------------------------
  307.  
  308. void __fastcall TForm1::Timer3Timer(TObject *Sender)
  309. {
  310.    Timer3->Enabled = false;
  311.    //installation done, now close and restart 'VSU.exe'
  312.    Label1->Caption = "Overall Progress: Installation Complete! Launching VSU Server...";
  313.    ExitApp();
  314. }
  315. //---------------------------------------------------------------------------

130
Developer's Corner / Re: My Application...
« on: January 10, 2008, 03:02 PM »
Bad news: I am getting this error now:
------------------------------------------------
Project F:\Borland Programs\Project1\Debug\VSU.exe faulted with message: 'application-define exception (code 0x0eedfade) at 0x75ecb09e.' Process Stopped. Use Step or Run to continue.

[OK Button]
------------------------------------------------
This is the error I get right after I compile the program. If I goto run the program It gets to the part right before it downloads at says, "VSU.exe has stopped working..." I have no idea what this is, but if anyone could help that would be awesome... Also, if you need anything further, let me know.

131
Developer's Corner / Re: My Application...
« on: January 09, 2008, 10:35 AM »
f0dder, i think you're right, although Im still learning more and more about threads between my college classes lol... I think I remember reading about it though...

btwn: Great Tutorial, Jazper! I really liked it! Everywhere I look, I cant seem to find any useful information and both of the things you have showed me helped alot... I might possibly do a full write-up/tutorial on multithreading from my point of view, someone who is new to the entire concept lol...

132
Developer's Corner / Re: My Application...
« on: January 09, 2008, 07:39 AM »
Here is a general idea of Threading for someone new to the concept...

Create a new project and add 2 Buttons, named Suspend and Resume... These will control the Thread using the OnClick() function.

Here is the coding I used along with BCB RAD Studio 2007:
(Keep in mind this is a sample template I wrote...)

Code: C++ [Select]
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4.  
  5. #include "Unit1.h"
  6. //---------------------------------------------------------------------------
  7. #pragma package(smart_init)
  8. #pragma link "IdExplicitTLSClientServerBase"
  9. #pragma resource "*.dfm"
  10. TForm1 *Form1;
  11. HANDLE Thread; //THIS IS FOR THE THREAD
  12. //---------------------------------------------------------------------------
  13. DWORD WINAPI ThreadFunc(LPVOID Param)
  14. {
  15.         //Tell the Thread what to do here
  16. }
  17. //---------------------------------------------------------------------------
  18. __fastcall TForm1::TForm1(TComponent* Owner)
  19.         : TForm(Owner)
  20. {
  21.         DWORD Id;
  22.         Thread = CreateThread(0, 0, ThreadFunc, Form1->Handle, CREATE_SUSPENDED, &Id);
  23.         if(!Thread)
  24.         {
  25.                 ShowMessage("Cannot Create Thread!");
  26.                 Application->Terminate();
  27.         }
  28. }
  29. //---------------------------------------------------------------------------
  30. void __fastcall TForm1::ResumeClick(TObject *Sender)
  31. {
  32.    ResumeThread(Thread);
  33. }
  34. //---------------------------------------------------------------------------
  35. void __fastcall TForm1::SuspendClick(TObject *Sender)
  36. {
  37.    SuspendThread(Thread);      
  38. }
  39. //---------------------------------------------------------------------------

Ill have a sample of how to set priorities between threads soon, once I fully embrace the concept.

133
Developer's Corner / Re: My Application...
« on: January 08, 2008, 07:09 PM »
thats way cool! ill upload the coding once I finish a basic template for multithreading in BCB 2007. ty for all the help guys!

134
Developer's Corner / Re: My Application...
« on: January 08, 2008, 03:43 PM »
Alright, so status update... I wrote my first threaded program that uses 2 threads, 1 thread that accesses global variables and another thread that downloads files from a list of "Files to be downloaded" lol... This coding helped alot! I do have a question however, what did you use to drop in that coding for me to see? I wanted to upload a sample for people to see how it works in Borland C++ builder...

135
Developer's Corner / Re: My Application...
« on: January 08, 2008, 09:59 AM »
wow, tyvm! this is awesome and im understanding this for the most part! way cool, ty again!

136
Developer's Corner / Re: My Application...
« on: January 08, 2008, 09:24 AM »
lol, i have no idea how to sychronize access to global data... :( is running FTP in a background thread classified as access to global data? this is entirely new to me

137
Developer's Corner / Re: My Application...
« on: January 08, 2008, 09:12 AM »
BCB does come with a command-line Delphi compiler for 3rd party components and such... If you have a delphi example, I might be able to make out the idea of how to do this, or at least I can try. ty again guys! this is helping a great deal! :)

138
Developer's Corner / Re: My Application...
« on: January 08, 2008, 07:50 AM »
Yes, Im using Indy's FTP client and thats a wonderful idea... I have no idea how to go about doing this though, anyway you could write a quick example or have a tutorial I could check out? Any time would greatly be appreciated alot :)

139
Developer's Corner / My Application...
« on: January 07, 2008, 10:25 PM »
Im using BCB 2007 to code my application for windows vista... My app connects to a declared ftp server just fine, but when it begins to download files it locks the application up until the download is done... Is there some kind of coding that I can add to allow my program to run fine?

Any help is greatly appreciated... thnx :)

140
Post New Requests Here / IDEA: Volume Controller
« on: December 30, 2007, 07:18 PM »
Here is my problem: I play alot of video games and while chatting to friends using an application such as Ventrilo. I need a program that will minimize the volume of the game and maximize the volume of Ventrilo when someone talks. It also has to be able to allow me to select the process that i want to minimize and maximize. It also needs to have an option that allows me to switch between Auto adjusting the volume and manually adjusting the volume (where i hit a global hotkey and while the hotkey is held down it keeps the volumes equal to what i set.) The program needs to fade the volume in and out so it doesnt hurt my ears as well.

141
Developer's Corner / Re: Implementing VoIP to a simple program...
« on: November 26, 2007, 07:51 AM »
EDIT: June 30th, 2008

Alright, so... Here is my new understanding of what needs to be accomplished.. There will be no VoIP involved but rather the transmission of voice packets (recorded to a filestream using the MCI device or waveIn(), etc...) through a TClientSocket and TServerClient. While i've made tremendous progress on understanding the process of how this works, i'm still stuck because I cannot implement exactly what I need..

Here is what I'm looking to develop:

Client Form
--------------------------------
-Holds a simple TClientSocket that will maintain an active connection with the server. The audio that is captured to the filestream needs to be sent over this socket as well as received from this socket too.
-This form will have a hotkey (like the 'CTRL' button) which, when held down, will record a wave file to a stream. When the hotkey is let go, that wave stream is complete but not deleted. While the wave audio is being recorded when the button is held down, it also needs to be put into buffers and sent through the TClientSocket component. When the button is pressed again, the wave stream simply starts over and repeats the SendStream process

Server Form
--------------------------------
-Acts the same as the Client form but is classified as the server simply because it holds the Active Connection.

I really don't care about encryption/decryption or compression/decompression. The wave stream will take on the GSM 6.0 Audio Format so that the wave file is only writing 1kbps and still maintains audio quality... To be honest, it really doesnt matter what form the wave takes as long as it can be streamed through the Socket at a fast rate.

Logically speaking, it will do this:
1. Ctrl button is pushed
2. Application creates a new wave file stream
3. Application records to the wave file stream
4. Application transmits buffers of size X through the Socket as the wave file stream is being recorded.
5. The receiving application realizes that the Sender is sending a streamed wave file, so it opens a wave file stream that can be read to for playback when all the voice packets have been received.
6. The application then waits for the ctrl button to be pressed again so that it can repeat the same process over and over until the Socket is closed.

This is where I am at.. I've researched alot of things using MSDN Microsoft, but cannot put together what I need for this to work.

On the form, the only thing i really need is a "Record" and "Stop" button for now, everything else is already preset (like the server info for the TClientSocket, etc)... If any of you masterminds understand how to do what i'm talking about, and wouldnt mind helping with the coding behind it, I would be more-than thankful because it seems like everyone points me to a component, which I have nothing against but i'd rather learn how to do this through sample coding so that I get a good grasp of how this works programatically... its not that hard to do, I just dont have experience with the 2 fundamental parts of this project: 1) recording to a file stream with MCI or something, and then 2) streaming/receiving this through the TClientSocket... Please help if you can, some sample source would be amazing! im using CodeGear Rad Studio but I can try to look through Delphi coding or something similiar..

142
Developer's Corner / Re: Implementing VoIP to a simple program...
« on: November 14, 2007, 05:36 PM »
Perfect! That is EXACTLY what I need! Thank you, thank you, thank you, thank you! lol! I am going to read up on it some more and then begin "toying" with things! I'll reply later with any questions/comments! Thanks again, Ethan!

143
Developer's Corner / Re: Implementing VoIP to a simple program...
« on: November 13, 2007, 09:07 PM »
Here is the Problem:
-If I was using a LAN, then it would be fine. I need to develop an application P2P or not to allow my father and I to talk using UDP (for lower latency and such.)
-I have researched multiple things concerning the VoIP capabilities and while using a component sounds best, I would like to implement this coding into an application of my own so that when I work on my 2D video game project, I will understand how to write the coding for the VoIP option I am looking to implement.
-I have looked into several different ways on how to do this but they all seem a bit over my head at the moment. Being in college, I have all the time in the world to learn things... Even if it means learning a new language...
-Most importantly, I have the ability to setup a protected server with a static IP address to host the server application that will be used to run this VoIP project.
-It doesn't need to be complex, it just needs to be able to hold a connection and transmit packets with the ability to skip a few here and there.

I know I need to use a Sound Codec, like Speex, and some network packet buffering code, but I need a little bit more to bite on. If someone would be willing to learn/help me with the project, that would be cool! It's something i've been looking to learn for a couple years now.

144
Developer's Corner / Re: Implementing VoIP to a simple program...
« on: November 09, 2007, 06:38 PM »
I was looking into developing this application to get a preview of how it works. I wouldn't mind using a tool if I can implement it the same way I would a component, but I would like to develop my own with the help of a 3rd party component/tool.

145
Developer's Corner / Implementing VoIP to a simple program...
« on: November 09, 2007, 02:16 PM »
Alright, so here is what I need to do:

I moved off to college and want to program a piece of software (nothing big), that will be able to take advantage of VoIP so I can talk to my parents at home. I am familiar with Delphi/C++ but would be willing to learn something new.

Is there a component/plugin I could buy for my IDE (Borland Developer Studio 2006/2007) that allows VoIP? If so, is it cheap and efficient? If not, could I program my own component to do the job? I don't even know where to start, but I do know that I want to make this software work.

Thanks for your time,
-CodeByer

Pages: prev1 2 3 4 5 [6]