Comatose 290 Taboo Programmer Team Colleague

You can use ioctl on the socket with FIONBIO. Should make the socket "non-blocking" which allows it to basically continue if there is nothing on the socket. Alternative, use threads, with function pointers (or functors), and let the socket block ;)

Comatose 290 Taboo Programmer Team Colleague
string x;
x = "hello world";
cout << x.length() << endl;
Comatose 290 Taboo Programmer Team Colleague

Yeah Seriously..... This thread is like 5 years old, and you responded to it. If you bother to have a look at the forum, you'd see that responding to threads more than 3 months old is seriously frowned upon... ass.

Comatose 290 Taboo Programmer Team Colleague

*Looks Around*
Batch Files Isn't Linux and Unix Shell Scripting.....

No, This isn't possible with command.com / cmd.exe alone (Batch). In order to do it, you will need a special exe of some kind. Easy enough to write one.

Comatose 290 Taboo Programmer Team Colleague

*Points To BevoX's Code*

Comatose 290 Taboo Programmer Team Colleague

Sounds pretty easy actually. Have him write a CGI or PHP page, that queries the server-side database. It uses POST to accept the username and password fields. Then, you write the C++ application using sockets (sdl_net, save yourself the major headache) to connect to the web server, and simply send it the HTTP header with the required data (username and password). When you send the data to the webserver, his CGI/PHP will run, query the database, and return a web page that is basically just a 1 or 0. You parse the HTTP header, and find the 1 or 0.... then you know.

Comatose 290 Taboo Programmer Team Colleague

Sweet! Thanks for the post.

Comatose 290 Taboo Programmer Team Colleague

The web server is forbidding the web browser from accessing .mdb files... makes sense for security reasons. On the server, rename the .mdb file to something like "mydatabase.zip" and when you have downloaded the file, have vb rename it to something like "mydatabase.mdb"

Comatose 290 Taboo Programmer Team Colleague

the gobblydegook is fine, that means it's in access format... if the other opens some kind of weird text, then obviously access won't read it.... now the question is, what is this text about missing files?

Comatose 290 Taboo Programmer Team Colleague

weird...are the file sizes the same and all that?

Comatose 290 Taboo Programmer Team Colleague

Honestly, I've never tried it on Win7, but it works on Vista... and 7 really is just vista with it's service packs ;)

Comatose 290 Taboo Programmer Team Colleague

Mkay, have you tried opening the original (open it with wordpad or notepad, unless it's huge) and then opening the one downloaded through VB, and see if they are the same size and the same basic byte structure etc? And there is no DB on http://www.asite.com for me to check it myself ;)

Comatose 290 Taboo Programmer Team Colleague

Are you sure that the database is in the same format (ie, did you make the database in Access 2007, and are opening it in 2003?)

Comatose 290 Taboo Programmer Team Colleague

Each one has a purpose of its own. I prefer to use the one that best suits the job :icon_eek:

Comatose 290 Taboo Programmer Team Colleague
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <ctime>
using namespace std;

int main() 
{
	int number = 2;
	int random;
	int ran;
	string alpha[3];
	string list[3];
	string choose[2];

	srand(time(0));

	while(2 == number) {
        	random = rand() % 2;
	        string alpha[3];
        	alpha[0] = "a";
	        alpha[1] = "b";
        	alpha[2] = "c";
        
	        ran = rand() % 3;
		list[0] = "1";
	        list[1] = "2";
        	list[2] = "3";
	        choose[0] = "alpha";
        	choose[1] = "list";

		if (choose[random] == "alpha") {
		        cout << "get random alpha" << endl;
			cout << alpha[ran] << endl;
		} else {
			cout << "get random list" << endl;
			cout << list[ran] << endl;
		}
	}
}
Comatose 290 Taboo Programmer Team Colleague
use CGI;

chomp($name = param("name")); # // $name should have "foo" in it.
Comatose 290 Taboo Programmer Team Colleague

Certainly makes you think twice before adding a bad rep point...

Comatose 290 Taboo Programmer Team Colleague

Based on what is in the code that we are trying to write, it would look something like this:

public type franklinCheck
     Employee as string
     Check as string
     ChkDate as date
     Total as double
end type

dim ourCheck as franklinCheck
ourCheck.Employee = "Comatose"
ourCheck.Check = "S1812"
ourCheck.ChkDate = Format("01/10/2009", "mmm/dd/yyyy")
ourCheck.Total = 200.00

open path & "checkinfo.txt" for output as #1  'or for append
     mydata = ourCheck.employee & string(20, " ")
     mydata = mydata & string(10, " ") & ourCheck.check
     mydata = mydata & string(10, " ") & ourCheck.chkdate
     mydata = mydata & string(10, " ") & ourCheck.total 
     mydata = mydata &  vbnewline
     print #1, mydata
close #1

However, this method is probably NOT the same as what goes on with VB.NET.... in VB.NET, this is very likely an object (an instance of a class). In order to do so in VB6, you would have to build a class for it, which is a whole different beast (start by adding a "class module")

And actually, you could probably add the padding in the UDT, something like:

public type franklinCheck
     Employee as string * 10  ' <<--        Like This
     Check as string
     ChkDate as date
     Total as double
end type

But, You could only Pad on the right, not the left.

Comatose 290 Taboo Programmer Team Colleague

Not really. That code is not only functional, but also makes use of some techniques to reduce the load on the processor and make the program run faster.... so, truthfully, that code is about as good as you are going to get. Granted, I suppose there should be a method in the string class to return that kind of information, but there simply isn't.

Comatose 290 Taboo Programmer Team Colleague

Well, the problem is that franklinCheck needs to be either a user defined type (UDT) in VB6, or you have to build a class module, and instantiate an instance of it. How is VB6 supposed to have any idea what franklinCheck is?

Comatose 290 Taboo Programmer Team Colleague

I meant:
http://www.virtualbox.org/

And truth be told, without a virtual PC it very likely isn't going to happen. One thing to remember about Microsoft, is that they want you to upgrade to their latest trash, even if it is by force.... so assimilate to .NET or perish :icon_evil:

Comatose 290 Taboo Programmer Team Colleague

timer1.enabled = false ;)

Comatose 290 Taboo Programmer Team Colleague

....

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim windir As String
        Dim Uname As String

        windir = Environ("windir")
        Uname = InputBox("Enter The Name")

        Shell(windir & "\system32\RUNAS.exe /profile /user:" & Uname & " /savecred C:\Program Files\Skype\Phone\Skype.exe", AppWinStyle.NormalFocus, False)

        End
    End Sub
End Class

Instead of all that (I'm just assuming I know what you are talking about... your description for help was very unclear), you could simply make a file called something like "RunIt.vbs" and add this:

dim Wsh
dim objEnv
dim windir
dim Uname

set wsh = WScript.createobject("WScript.Shell")
set objEnv = wsh.environment("Process")

windir = objEnv("Windir")

uname = inputbox("Enter The Name")

wsh.run windir & "\system32\RUNAS.exe /profile /user:" & Uname & " /savecred C:\Program Files\Skype\Phone\Skype.exe", 1, 0

set wsh = nothing
set objEnv = nothing

Wscript.Quit()
Comatose 290 Taboo Programmer Team Colleague

Except for not using goto's :P

edit: and using functions/methods is always a plus.

Comatose 290 Taboo Programmer Team Colleague

:)

Comatose 290 Taboo Programmer Team Colleague

what is the "command" that you put there for the shortcut in accessories?

Comatose 290 Taboo Programmer Team Colleague

Yeah, basically you install VirtualBox. Once you install Virtualbox, you install a different Operating system into the virtualbox. The virtualbox basically tricks the operating system into thinking it's on a full machine (the virtualbox has a bios, etc). So basically, you install VirtualBox, then you install XP in a virtualbox window (so you have a windows 7 window... inside that window is XP). Then you can run "incompatible" programs in XP in the window.

Comatose 290 Taboo Programmer Team Colleague

Variants use more memory, and require additional overhead because when passed to a function or used in a certain way, it has to be cast to that type. The same VB code I posted above, I changed the Dim I as Integer to Dim I as Variant and the speed jumped from 8 seconds (for the wild loop with multiplication) to 18 seconds just by using the Variant data type instead of integer. Using = makes it more difficult for code readability, and slightly confusing, because in most other languages if you do something like if (x = 5) { it will return true if x successfully gets assigned the value of 5. So if x fails to become 5, then you know not process the following code. Such a thing isn't possible in VB, without adding additional steps.

All that said, don't beat yourself up. VB does work, and honestly, for applications that don't require time critical processing, does it really matter? With RAM cost dropping faster than a roller-coaster the extra it uses is hardly a reason to never use it. I've written an instant messenger client and server with VB6... and just recently, a program that blocks certain web-sites based on the current time. So while VB does suck, it's not entirely without use, and to some degree kind of fun. :)

Comatose 290 Taboo Programmer Team Colleague

Setting Aside Minor Language Quirks, It's slow as hell. Don't believe me?
Add a button, and 2 labels...(I've done this without a form too, using sub main() with debug.prints, but the difference is negligible)

Private Sub Command1_Click()
Dim retval As Double

Label1.Caption = Time
Me.Refresh

For I = 0 To 100000000
    retval = I * I
Next I

Label2.Caption = Time
Me.Refresh
End Sub

On A Pentium 4 2.80Ghz Dual core processor with 3GB's Ram, this code averages (compiled, not IDE) 8 seconds.
Now this in Visual C++ (it's faster in code::blocks, but hey):

#include <iostream>
#include <time.h>

using namespace std;

int main(int argc, char **argv)
{
	double retval;
	char timeStr[9];

	_strtime( timeStr );
	
	cout << timeStr << endl;

	for (int i=0; i < 100000000; i++) {
		retval = i * i;
	}

	_strtime( timeStr );

	cout << timeStr << endl;

	return 0;
}

On the same processor averages 1 second. So, 7 times faster than VB? To be perfectly honest, the inability to use pointers is annoying as all hell (addressof, for real?). What about strings.... what about how strings are always duplicated no matter what?

Form_Unload very hardly does justice to a destructor, and Form_Load is a poor example of a constructor. To be honest, I don't use windows, I use *nix only (well, ok, so I have a virtualbox with XP in it, but eah).

String escapes.... wow, that's frickin' nasty. Go ahead, add a " to your vb …

Comatose 290 Taboo Programmer Team Colleague

*Scratches His Head*
Frickin' Permissions.

Comatose 290 Taboo Programmer Team Colleague

Change the shortcut's link file to +x?

Comatose 290 Taboo Programmer Team Colleague

First, Lua is a scripting language, not a compiled language. This means there is no compiler or linker, Just an interpreter (which probably acts as both). Second, you need to find the lua executable, and run it first. On a linux system, it might look like: ./lua myfile.lua . Alternately, you could open the .lua file that you are making and make the first line something like: #!/usr/bin/lua or if the .lua file is in the same directory as the lua binary #!./lua And yes, this is the C++ forum.

Comatose 290 Taboo Programmer Team Colleague

I Think Teme64's Right. Once Program copy 1 opens the file, I think the system locks it. I guess a solution around this, would be to have the program download a local copy, and work with it, then re-upload it.... but you are going to run into mad problems with keep things in order. I guess the way to do that would be, when they are finished working on it, the changes are submitted to some kind of server program, which waits for all copies that are opened to be closed. Then, it would check the timestamps of each uploaded file.... then it would have to basically modify one file, with any differences of the other, and do this for all the uploaded files, until you reach the one with the latest time stamp. Then, rename it to the main filename (after all changes were merged to it). What a mess that would be.

Comatose 290 Taboo Programmer Team Colleague

Yeah, that code is Not VB6 Code. In order to do something similar to what you have there:

open path & "checkinfo.txt" for output as #1  'or for append
     mydata = ourCheck.employee & string(20, " ")
     mydata = mydata & string(10, " ") & ourCheck.check
     mydata = mydata & string(10, " ") & ourCheck.chkdate
     mydata = mydata & string(10, " ") & ourCheck.total 
     mydata = mydata &  vbnewline
     print #1, ourCheck.employee & string(20, " ")
close #1

I'm not 100% sure that vb6 is even going to recognize whatever object "ourCheck" is, but in order to do the "ToString("N2")" you may have to look at using "Format$" in vb6 in order to format the string data.

Comatose 290 Taboo Programmer Team Colleague

The thread I linked you to in my previous post http://www.daniweb.com/forums/thread18618.html should answer your questions. I personally don't have the kind of time needed to focus strictly on one project like that. Good luck.

PS: Check This Post In Particular: http://www.daniweb.com/forums/post95357-17.html

Comatose 290 Taboo Programmer Team Colleague

Well right, you want to associate the IP with the account, but you can't. If I reboot my router/modem for example.... my provider will give me a new IP. So, now I can't access my account, and I am seen as a thief because I restarted my router?

Comatose 290 Taboo Programmer Team Colleague

Also keep in mind, I think FTP uses 2 ports (not just 1). 21 and 20.... 21 for all the commands, and 20 for actual data transfer.

Comatose 290 Taboo Programmer Team Colleague

I agree. I'm much more a fan of "VirtualBox", but certainly running a VM and installing XP on it... then putting VS6 on the XP in the VM is the best solution to this so far.

Comatose 290 Taboo Programmer Team Colleague

You should have read This Sticky Post first.

Comatose 290 Taboo Programmer Team Colleague

This thread is like, four years old.... how about you start a thread of your own?

Comatose 290 Taboo Programmer Team Colleague

Sure... but the amount of code and difficulty level for this task is nothing to take lightly. This Thread will help you understand why.

Comatose 290 Taboo Programmer Team Colleague

How about you rename your FlexGrid control to Grd..... (or is it already Grd)?

Comatose 290 Taboo Programmer Team Colleague

No No, It was faulty code :$:

dim urls as new List(of string)()
dim I as integer
urls =  PopulateUrlList()

for  I = 0 to urls.count -1 ' maybe i = 1 to urls.count
     ComboBox1.Items.Add(urls(i))   ' // oops!
next I
Comatose 290 Taboo Programmer Team Colleague

That code is fantastic. The only thing that I would mention about it... is that you are using the function to work with your form. On a small scale project, this is fine (and I've seen it used on large scale projects too), but keep in mind that this defeats the entire purpose of a function. Why even use a function... why not put all that code in the Button1_Click Event? The function is meant to be used to GET the list of URL's.... actually displaying them to the user is a different process... a different concept. So getting the data, and showing the data should not be combined.

Imports System
Imports Microsoft.Win32
Imports System.Windows.Forms

Public Class Form1

    Public Function PopulateUrlList() As List(Of String)
        Dim regKey As String = "Software\Microsoft\Internet Explorer\TypedURLs"
        Dim subKey As RegistryKey = Registry.CurrentUser.OpenSubKey(regKey)
        Dim url As String
        Dim urlList As New List(Of String)()
        Dim counter As Integer = 1
        While True
            Dim sValName As String = "url" + counter.ToString()
            url = DirectCast(subKey.GetValue(sValName), String)
            If DirectCast(url, Object) Is Nothing Then
                Exit While
            End If
            urlList.Add(url)
            counter += 1
        End While
        Return urlList
    End Function

 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
     dim urls as new List(of string)()
     dim I as integer
     urls =  PopulateUrlList()

     for  I = 0 to urls.count -1 ' maybe i = 1 to urls.count
            ComboBox1.Items.Add(url)          
     next I
    End Sub
End Class
Comatose 290 Taboo Programmer Team Colleague

You would have to do something entirely different. Firefox stores it's URL's in files.... I believe under something like "c:\documents and settings\%username%\Application Data\Mozilla\Firefox\Profiles\<somenumberhash>\history.dat" although now, I think they store it in an sqlite database (same path), making it that much more complicated to read.

Comatose 290 Taboo Programmer Team Colleague

Well, That code works... And Pretty Well.

Comatose 290 Taboo Programmer Team Colleague

Well, I posted before I saw Ancient Dragon's Post... I think his should work (adding an additional include path, that points to the directory with the .h)

Comatose 290 Taboo Programmer Team Colleague

How long it was since I last posted... and how long it's been that way is fairly irrelevant. The point of the post was to bring it to the attention of the community and those in charge (hence the forum... Feedback) that there was no kind of link or access point to post a new tutorial. Regardless of whatever kind of process is being put in place to regulate the tutorial posts (which, is also somewhat discouraging for people who do want to contribute tutorials) There simply wasn't/isn't a means by which to post one....not even a link to "send this tutorial for review/post" nothing.

Comatose 290 Taboo Programmer Team Colleague

Open includes.h and check the #include directive. Does it point to the same path that windns.h resides? That is, do you have something like:
#include "c:\blahblah\blah\windns.h" ?

Comatose 290 Taboo Programmer Team Colleague

What's interesting here, is that both methods are pretty great..... but neither one of them gets the typed URL's of a browser other than IE. What about getting the history of Firefox.... Opera.... Chrome?