|
Hi,
Is it possible or how do you create a exe that when you drop a file onto it, the program will run and do a task on the file that your dragged onto it.
|
|
|
|
|
When you drag a file over an exe (or shortcut), the program will be started with the filename as a command line argument. You can either change Sub Main() to Sub Main(args() As String) or find some other way to get the command line arguments (System.Environment.GetCommandLineArgs(), for example).
Something similar happens if you associate a file type with your program and double-click the file in explorer.
|
|
|
|
|
I will try explain what I am trying to do a little better than before. I have a program that when you run it the Open FIle Dialog appears so you can select a pdf to run a check on. What I want to do is to allow the user to drag and drop the pdf onto the exe an instead of opening the Open File dialog it would bypass it but still use the file name and path that I have selected as the file to check. An example of this would be if you create a text file on your desktop. You can then drag and drop the file on Notepad.exe and the file will open straight away.
modified on Thursday, July 3, 2008 10:46 AM
|
|
|
|
|
Gideon provided you with the answer you need
When you drop a file onto you'r exe, the exe will start with in its arguments the path to that file
like gideon said you can then eighter change the constructor of you'r startupform form
public sub new()
to
public sub new(args() as string)
or use System.Environment.GetCommandLineArgs() to get the arguments passed to the exe
this is a standerd function in windows (drop any file onto (olmost) any exe and the exe will start)
But all this has been said by Gideon so...
|
|
|
|
|
I haven't done that myself, but this article has a basic tutorial that should point you in the right direction. The main events here seem to be DragEnter and DragDrop.
|
|
|
|
|
sorry for posting second question on same topic becouse second is for display data is posted by mistake and try to modify in edit mode thats is not shown ,
'this code is worked
isql="Insert Into students(id, first_name, last_name, major,current_credits) values (?, ?, ?, ?, ?)"
idbcomm=new odbccommand(isql,dbconn)
idbcomm.Parameters.Add("id", id.Text)
idbcomm.Parameters.Add("fname", fname.text)
idbcomm.Parameters.Add("lname", lname.Text)
idbcomm.Parameters.Add("major", major.Text)
idbcomm.Parameters.Add("credits", credits.Text)
idbcomm.ExecuteNonQuery()
'This code is not working reports error
'lsSQL ="Insert Into stud(id,firstname,lastname,major) values (@id,@fname,@lname,@major)"
'idbcomm=new odbccommand(isql,dbconn)
'idbcomm.Parameters.Add( "@id",id.Text)
'idbcomm.Parameters.Add( "@fname",fname.text)
'idbcomm.Parameters.Add( "@lname",lname.Text)
'idbcomm.Parameters.Add( "@major",major.Text)
idbcomm.ExecuteNonQuery()
sanjeev
|
|
|
|
|
Please Check your data type against your Variable data.
and why you use Paramenters. It is meaning less.
Anubhava
|
|
|
|
|
idsanjeevjha wrote: 'This code is not working reports error
What is the error ? You have use @ symbol for parameter. I believe you should use ? symbol for parameters in Odbc.
|
|
|
|
|
i am getting ERROR [42000] [Microsoft][ODBC driver for Oracle][Oracle]ORA-00936: missing expression.
ya i have to use ? symbol for parameter in odbce but why @ is used in sql or msaccess
thanks
sanjeev
|
|
|
|
|
That depends on the databases. SQL and access uses @ symbol.
|
|
|
|
|
It may not help much, but when using an old version of sqlce, I used to use the following to add a parameter to the query:
cmd.Parameters.Add(New SqlCeParameter("id", SqlDbType.Int)).Value = nextID
maybe you can modify to get it working?
|
|
|
|
|
Code for data insertion is not work reported error
<script runat="server">
Sub submit(sender As Object, e As EventArgs)
dim dbconn,sql,dbcomm,dbread
dbconn=New ODbcConnection("dsn=oracle;uid=starter;pwd=starter;")
dbconn.Open()
sql="SELECT * FROM students"
dbcomm=New ODbcCommand(sql,dbconn)
dbread=dbcomm.ExecuteReader()
customers.DataSource=dbread
customers.DataBind()
dbread.Close()
dim isql,idbread,idbcomm
isql="Insert Into students(id,first_name,last_name,major) values (@fname,@id,@lname,@major)"
idbcomm=new odbccommand(isql,dbconn)
idbcomm.Parameters.Add( "@fname",fname.text)
idbcomm.Parameters.Add( "@id",id.Text)
idbcomm.Parameters.Add( "@lname",lname.Text)
idbcomm.Parameters.Add( "@major",major.Text)
idbcomm.ExecuteNonQuery()
dbconn.Close()
End Sub
</script>
but this code is excuted success fully
<script runat="server">
Sub submit(sender As Object, e As EventArgs)
Dim strConnectionString As String
strConnectionString = "Dsn=oracle;uid=gatepass;pwd=gp"
Dim pConn As New OdbcConnection(strConnectionString)
'Dim pSELECTQUERY As String = "SELECT *from students"
Dim pSELECTQUERY As String = "SELECT distinct PassMaster.*,passarea_dtls.passarea,empmaster.empname,visitormaster.visitorname FROM PassMaster, VisitorMaster,passarea_dtls,empmaster where passmaster.authorisationby=empmaster.empno and passmaster.passareacode=passarea_dtls.passareacode and PassMaster.PassIssueDt + PassMaster.validity -1 >= trunc(sysdate) and PassMaster.PassID = VisitorMaster.PassID and PassMaster.AuthorisationStatus = 'YES' and passmaster.PASSISSUESTATUS not like 'YES' order by PassMaster.PassID"
Dim adapter As New OdbcDataAdapter(pSELECTQUERY, pConn)
Dim DS As DataSet = New DataSet()
adapter.Fill(DS)
Repeater1.DataSource = ds
pConn.Close()
adapter.Dispose()
Repeater1.DataBind()
End Sub
</script>
i don't know whats is the reason any help ?
sanjeev
|
|
|
|
|
try changing
isql="Insert Into students(id,first_name,last_name,major) values (@fname,@id,@lname,@major)"
to
isql="Insert Into students(id,first_name,last_name,major) values (@id,@fname,@lname,@major)"
|
|
|
|
|
Thanks for your reply
Please see my last post where i already changed some code problems in commented code is not worked but other code thats is not commented is inserted data successfully.
so i wants to know whats is the mistakes in my commented code
thanks
sanjeev
|
|
|
|
|
Yep. I spotted that after I had posted the Q.
|
|
|
|
|
I used AxShockwaveFlash Object to play first.swf file, i wanna play second.swf when first.swf complete so how can i get the total completion time period of flash file, means each swf file must play only once then load next swf file..
Can anyone give me suggestion 4 this
Thanks with annticaptions
Unless u don't give ur hundred percent whatever u r doning till there is no result of ur work...
|
|
|
|
|
I have some code that reads email items and their attachments and then moves the mail item to a "Processed" folder in the users mail box. In general it works ok, but if the attachment in a file type that is not recognised (this raises an error), I want to identify the mail item and move it to a different folder. When I debug my code, the appropriate catch statements seem to get called and the flags set correctly, but when I get the part of the code that moves the mail items, the one that raised the error gets moved into the "Processed" folder and not the "Failed" folder.
Can anyone see what I am doing wrong?
In the code below, theMailItem is a structure.
I.E.
<br />
Public Structure TheMailItem<br />
Dim theItem As MailItem<br />
Dim theMove As Boolean<br />
Dim theFail As Boolean<br />
End Structure<br />
For Each theMailItem In theMailItems
Try
ReadMailItem(theMailItem.theItem)
Catch ex As InvalidCastException
theMailItem.theFail = True
theMailItem.theMove = False
Catch ex As NullReferenceException
theMailItem.theFail = True
theMailItem.theMove = False
Catch ex As System.Exception
theMailItem.theFail = True
theMailItem.theMove = False
End Try
Next
For Each theMailItem In theMailItems
'Move any processed items
If theMailItem.theMove = True Then
theMailItem.theItem.Move(theMoveFolder)
End If
'Move any fail items
If theMailItem.theFail = True Then
theMailItem.theItem.Move(theFailedFolder)
End If
Next
|
|
|
|
|
I love it "programming by error", perfect example, try something and when it fails try something else, when the error trap fails (possibly becasue the variable is now out of scope) ask on CP.
Where do these ideas come from, you KNOW there may be errors, you know where they are, you know what causes them, for all thats sensible TEST the attachment BEFORE you attempt to move it, don't rely on your error handling to do your job for you.
Sorry for the rant....
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I would love to test the attachment before attempting to read it (I want to move the whole email-not the attachment). I just can't find any information about how to test it. If you know of any good Outlook API programming resources I would be grateful. I can't find any and MSDN is just about worthless.
Testing first (which I agree would be the best thing) is not really the question. The question is why do the flags seem to be set in the catch statements but revert to the default settings.
The variable is not out of scope (I think). The catch block seems to set the flags ok and when I step through it the email item is still set.
(I have stripped out some of the other parts of the catch statements and also want to develop this up so that it moves files that throw different exceptions to different folders - I just wanted to keep my question as simple as possible).
Also, I don't mind the rant. I realise that I am opening up for criticism of my code when I post here. I don't do it without looking everywhere I can for an answer first.
|
|
|
|
|
RCoate wrote: opening up for criticism of my code when I post here
I don't have an issue with your code - seems Ok to me, I just hate the use of the exception handler as any thing but a disaster trap.
RCoate wrote: I would love to test the attachment before attempting to read it
I'm pretty sure you can save the attachment via the API. This would then let you inspect the attributes of the file. I know this is a kludge but may be an option.
I also seem to remember there was an array of attachments within the mail object that can probably be inspected directly.
RCoate wrote: good Outlook API programming resources
Sorry - I hate Outlook as much as the next bloke so my knowledge is limited.
I realise you want to move the whole message but you have identified the problem that is stopping you so now you need to handle the attachment issue before attempting to move the mail object.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Mycroft Holmes wrote: I love it "programming by error"
Yes, very lovely
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
The problem you are having is caused by the way structures are handled. When you declare a class, you essentially pass around a pointer and code like
Dim A as new SomeObject
A.SomeProperty = 3
Dim B As SomeObject = A
B.SomeProperty = 5
Console.WriteLine(A.SomeProperty)
would output 5. However with structures, you are actually making copies of the data. So for your code, the first loop makes a copy of the items in the array, then modifies the properties of the *copies* in the exception handlers. You have two options. One is to change TheMailItem to a class, which is probably a better option if MailItem (the type of one of the properties on TheMailItem) is a class. The other is to combine the loops into a single loop. Here's some code to show that structures really are copied:
Sub Main()
Dim items(10 - 1) As CopyTest
Dim i As Integer
Dim ct As CopyTest
For i = 0 To items.Length - 1
items(i) = New CopyTest
items(i).Original = i
items(i).Modified = i
Next
Console.WriteLine("Original Values:")
For Each ct In items
Console.WriteLine("Original: {0} Modified: {1}", _
ct.Original, ct.Modified)
Next
Console.WriteLine("Modifications in progress:")
For Each ct In items
ct.Modified = ct.Modified * 3
Console.WriteLine("Original: {0} Modified: {1}", _
ct.Original, ct.Modified)
Next
Console.WriteLine("After Modifications:")
For Each ct In items
Console.WriteLine("Original: {0} Modified: {1}", _
ct.Original, ct.Modified)
Next
Console.ReadKey()
End Sub
Private Structure CopyTest
Public Original As Integer
Public Modified As Integer
End Structure
|
|
|
|
|
Thanks Gideon.
That makes sense.
I changed the structure to a class and it is working now.
modified on Thursday, July 3, 2008 12:25 AM
|
|
|
|
|
I'm stumped on something that should be simple, but.....
I've written a VBscript to create a folder on an IOMega NAS box using objFSO.CreateFolder, and copy some files to it for backup. It runs on a server using Win2003R2. The NAS box is mapped to a local drive letter on this server.
I use cscript to run the script, fired off by the scheduler at night, under an Administrator user ID.
The script works fine in debug mode.
If I execute the script from a Run|cmd command line, it works fine.
When kicked off by the scheduler, it always fails on the CreateFolder method with a 76 error (path not found).
But if I open the scheduler, right click on the job and select "Run", it runs the job with no problems and completes successfully!
I've inserted some debug code before the CreateFolder, checking for FolderExists on the NAS box and that is always successful. The first hint of trouble is the 76 error on the CreateFolder method.
Here's some of the code. "x" is the mapped drive.
BTW: all of the code referencing "NAS disks to spinup" was added to get around this 76-error problem, under the assumption that idled disks were the culprit; none of it helped.
Const Backupfolder = "x:\Data Backups"
.
.
.
' Checking to see if NAS disks are still spinning
If objFSO.FolderExists(Backupfolder) Then i=1
writelog ("check that NAS disks are spinning: err.num: " & Err.Number & " " & Err.Description)
errHandler ("checking if NAS disks are spinning")
' Generate today's directory name in the format yymmdd
strmonth = month(date)
if strmonth < 10 then strmonth = "0" & strmonth
strday = day(date)
if strday < 10 then strday = "0" & strday
todaysfolder = right(year(date),2) & strmonth & strday
' Now create the full pathname to today's backup folder
todayspath = Backupfolder & "\" & todaysfolder
' Create todays backup folder
If objFSO.FolderExists(todayspath) Then
Set objbkupFolder = objFSO.GetFolder(todayspath)
writelog(todayspath & " already exists!")
Else
writelog("Creating folder " & todayspath)
Err.Clear
Set objbkupFolder = objFSO.CreateFolder(todayspath)
If Err.Number <> 0 Then
writelog ("Waiting 15 seconds for NAS disks to start. Err: " & Err.Number & " " & Err.Description)
Err.Clear
objbkupFolder = nothing
Wscript.Sleep 15000 'Wait 15 seconds for NAS disks to spin up
Set objbkupFolder = objFSO.CreateFolder(todayspath)
If Err.Number <> 0 Then
errHandler (" trying to create folder " & todayspath)
abendscript
End If
End If
End If
Anybody have any ideas on this?
Jeff
|
|
|
|
|
It doesn't work because the drive mapping doesn't exist under the scheduler's user session. You have to provide code in the script for mapping the drive, or just skip the drive mapping and recode the script to use UNC paths instead.
|
|
|
|
|