VB To PureBasic No

Windows specific forum
Rascal
User
User
Posts: 30
Joined: Mon Sep 17, 2007 11:06 pm

VB To PureBasic No

Post by Rascal »

:cry: :cry: :cry: :cry:

Code: Select all

Option Explicit

Private Type AT_INFO   
   JobTime     As Long 
   DaysOfMonth As Long 
   DaysOfWeek  As Byte 
   Flags       As Byte 
   Command     As String
End Type

Private Declare Function NetScheduleJobAdd Lib "netapi32.dll" (ByVal servername As String, buffer As Any, JobId As Long) As Long

Private Sub Form_Load()
   Dim strComputerName As String
   Dim lngJobID As Long
   Dim udtAtInfo As AT_INFO
   
   strComputerName = StrConv(".", vbUnicode)
   udtAtInfo.Command = StrConv("c:\test.exe", vbUnicode)
   
   udtAtInfo.Flags = 16
   udtAtInfo.DaysOfWeek = 0
   udtAtInfo.DaysOfMonth = 0
   udtAtInfo.JobTime = 57900000
      
   MsgBox NetScheduleJobAdd(strComputerName, udtAtInfo, lngJobID)

   End
End Sub
To PureBasic NetScheduleJobAdd_() Return No 0

Code: Select all

Structure AT_INFO
  JobTime.l
  DaysOfMonth.l
  DaysOfWeek.b
  Flags.b
  Command.s
EndStructure

Procedure StringToUnicode (pbstrptr.l,ucstrptr.l )
MultiByteToWideChar_(#CP_ACP,#Null,pbstrptr,Len(PeekS(pbstrptr)),ucstrptr,Len(PeekS(ucstrptr))) 
PokeL ( ucstrptr+Len(PeekS(pbstrptr))*2,#Null) 
EndProcedure


A.s = "c:\test.exe" 
A_uc.s = Space (#MAX_PATH) 
StringToUnicode(@A,@A_uc ) 

B.s = "."
B_uc.s = Space (#MAX_PATH) 
StringToUnicode(@B,@B_uc ) 


udtAtInfo.AT_INFO
udtAtInfo\Command     = A_uc
udtAtInfo\Flags       = 16
udtAtInfo\DaysOfWeek  = 0
udtAtInfo\DaysOfMonth = 0
udtAtInfo\JobTime     = 57900000

Debug  NetScheduleJobAdd_(B_uc,@ai,@f)  

NetScheduleJobAdd_(B_uc,@ai,@f) Return No 0 :cry: :cry: :cry: :cry: :cry: :cry:
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

See if this works for you. Notice the changes to the AT_INFO structure. ;)

Code: Select all

#NERR_Success = 0
Structure _AT_INFO 
  JobTime.l 
  DaysOfMonth.l 
  DaysOfWeek.b 
  flags.b 
  dummy.w
  Command.l
EndStructure 
a.s = Space(10)
;...Run Windows Calculator at the next change of minute.
PokeS(@a, "calc.exe", -1, #PB_Unicode) 

hour = Hour(Date()) * 3600
min = (Minute(Date()) + 1)  * 60
runtime = (hour + min) * 1000

ai._AT_INFO 
ai\Command = @a
ai\flags = 0
ai\DaysOfWeek = 0 
ai\DaysOfMonth = 0 
ai\JobTime = runtime
result = NetScheduleJobAdd_(0, ai, @JobId)

If result = #NERR_Success 
  MessageRequester("Success", "New JobID is: " + Str(JobId))
Else
  MessageRequester("Failure", "Unable to set new Job")
EndIf
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
Post Reply