Results 1 to 13 of 13

Thread: [RESOLVED] Anyone Can Convert this Code From Delphi To VB?

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2007
    Location
    Brunei Darussalam
    Posts
    50

    Resolved [RESOLVED] Anyone Can Convert this Code From Delphi To VB?

    this is originally coded by monxxx -thanks to him and credit always goes to him

    i am not on delphi i want to learn more on visual basic,
    i try to compile this and this is the screenshot of my work


    but if anyone can convert this on vb that will really a big help
    because i understand a bit of code on vb while on delphi im zero level

    unit Unit1;

    // Coded by monxxx
    // email: nokmaster2003@yahoo.com

    interface

    uses
    Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    Dialogs, StdCtrls, Buttons, Registry;

    type
    TForm1 = class(TForm)
    Memo1: TMemo;
    SpeedButton1: TSpeedButton;
    SpeedButton2: TSpeedButton;
    procedure FormCreate(Sender: TObject);
    procedure SpeedButton1Click(Sender: TObject);
    procedure SpeedButton2Click(Sender: TObject);
    private
    { Private declarations }
    public
    { Public declarations }
    end;

    var
    Form1: TForm1;

    implementation

    {$R *.dfm}

    procedure TForm1.FormCreate(Sender: TObject);
    begin
    Form1.Caption := 'yahoo! messenger multiple account login patcher';
    end;

    procedure TForm1.SpeedButton1Click(Sender: TObject);
    var
    Reg: TRegistry;
    begin
    Reg := TRegistry.Create;
    Reg.RootKey := HKEY_CURRENT_USER;
    Reg.OpenKey('Software\Yahoo\pager\Test', True);
    Memo1.Text := 'Enabling yahoo msgr multiple account login done! :-)';
    Reg.WriteInteger('Plural', 1);
    Reg.Free;
    end;

    procedure TForm1.SpeedButton2Click(Sender: TObject);
    var
    Reg: TRegistry;
    begin
    Reg := TRegistry.Create;
    Reg.RootKey := HKEY_CURRENT_USER;
    Reg.OpenKey('Software\Yahoo\pager\Test', True);
    Memo1.Text := 'Disabling yahoo msgr multiple account login done! :-(';
    Reg.WriteInteger('Plural', 0);
    Reg.Free;
    end;

    end.
    thank you in advance,

    regards

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,930

    Re: Anyone Can Convert this Code From Delphi To VB?

    Thread moved from the 'CodeBank VB6' forum (which is for you to post working code examples, not questions) to the 'VB6' forum

  3. #3

    Thread Starter
    Member
    Join Date
    Dec 2007
    Location
    Brunei Darussalam
    Posts
    50

    Re: Anyone Can Convert this Code From Delphi To VB?

    oh sorry for my mistake sir, and thanks for moving this to the right section,

    im still having a problem on my code on vb,
    still hoping anyone can convert this whole code to vb

    thanks

  4. #4
    Fanatic Member BenJones's Avatar
    Join Date
    Mar 2010
    Location
    Wales UK
    Posts
    637

    Re: Anyone Can Convert this Code From Delphi To VB?

    Most of the code you want converting is Registry releated do a search on the forum for "Accessing the Registry" you find lots of examples. as for the rest of the code the memo part you can use a textbox

    Code:
    Text1.Text := "Enabling yahoo msgr multiple account login done! :-)'"
    Hope that gives you some ideas

  5. #5
    Hyperactive Member
    Join Date
    Jul 2009
    Posts
    489

    Re: Anyone Can Convert this Code From Delphi To VB?

    Quote Originally Posted by eyestrain View Post
    this is originally coded by monxxx -thanks to him and credit always goes to him

    i am not on delphi i want to learn more on visual basic,
    i try to compile this and this is the screenshot of my work


    but if anyone can convert this on vb that will really a big help
    because i understand a bit of code on vb while on delphi im zero level



    thank you in advance,

    regards
    open new project in VB
    now you have a new empty form
    add two command buttons to it
    name them SpeedButton1, SpeedButton2
    add text box, name it Memo1

    Code:
    Private Sub SpeedButton1_Click()
      Memo1.Text = "Enabling yahoo msgr multiple account login done! :-)"
    End Sub
    
    Private Sub SpeedButton2_Click()
      Memo1.Text = "Disabling yahoo msgr multiple account login done! :-("
    End Sub
    
    Private Sub Form_Load()
     Form1.caption = "yahoo! messenger multiple account login patcher"
    End Sub
    now try to fill the registery code in the buttons events, by searching a bit in this forum/google
    if you can't and no one else can help, i help you later with this

  6. #6

    Thread Starter
    Member
    Join Date
    Dec 2007
    Location
    Brunei Darussalam
    Posts
    50

    Re: Anyone Can Convert this Code From Delphi To VB?

    thanks sir benjones and sir whatsup for the tip,
    i think i can make it now

    ill try it,
    and about the word googling the "accessing the registry" i think this one also will help me



    thanks guys

  7. #7

    Thread Starter
    Member
    Join Date
    Dec 2007
    Location
    Brunei Darussalam
    Posts
    50

    Re: Anyone Can Convert this Code From Delphi To VB?

    i make it work with vb...

    Private Sub CmdYMulti_Click()
    Dim D As Object
    On Error Resume Next
    Set D = CreateObject("wscript.shell")
    D.regwrite "HKCU\Software\yahoo\pager\Test\Plural", 1, "REG_DWORD"
    lblstat.Caption = "Yahoo Multi Enabled"
    End Sub
    i have a question,
    why do we need this line?
    Set D = CreateObject("wscript.shell")
    what is his work?

    Is there any other simple way that is easy to understand?
    its almost half a month
    searching and reading really help

  8. #8
    Hyperactive Member
    Join Date
    Jul 2009
    Posts
    489

    Re: [RESOLVED] Anyone Can Convert this Code From Delphi To VB?

    you can use api function

    Code:
    Sub WriteRegNum(ByVal lKey As Long, ByVal sSubKey As String, ByVal sValueName As String, ByVal lData As Long)
        Dim lRet As Long
    
        Call RegCreateKey(lKey, sSubKey, lRet)
        Call RegSetValueEx(lRet, sValueName, 0, REG_DWORD, lData, 4)
        Call RegCloseKey(lRet)
    End Sub
    
    
    Private Sub Form_Load()
      WriteRegNum HKEY_CURRENT_USER, "Software\yahoo\pager\Test", "Plural", 1
    End Sub

  9. #9

    Thread Starter
    Member
    Join Date
    Dec 2007
    Location
    Brunei Darussalam
    Posts
    50

    Re: [RESOLVED] Anyone Can Convert this Code From Delphi To VB?

    i think using that api becomes more complicated to my level, i still go with my small code
    and sir you didnt answer the job of this line Set D = CreateObject("wscript.shell")

    thanks for the answer

  10. #10
    Hyperactive Member
    Join Date
    Jul 2009
    Posts
    489

    Re: [RESOLVED] Anyone Can Convert this Code From Delphi To VB?

    this line let you use the functions that in the object "wscript.shell"
    this line
    Code:
    D.regwrite "HKCU\Software\yahoo\pager\Test\Plural", 1, "REG_DWORD"
    is one of its functions, and it does exactly the same task that i showed in my code.

  11. #11
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,930

    Re: [RESOLVED] Anyone Can Convert this Code From Delphi To VB?

    CreateObject is basically a way of creating a Reference (via Project->References) while your code is running.

    Doing it that way means the code runs more slowly (not a big deal for the code you have), but it does mean that you shouldn't have problems if your users have different versions of the Reference files.


    By the way, I recommend reading the article What is wrong with using "On Error Resume Next"? from our Classic VB FAQs (in the FAQ forum)

  12. #12

    Thread Starter
    Member
    Join Date
    Dec 2007
    Location
    Brunei Darussalam
    Posts
    50

    Re: [RESOLVED] Anyone Can Convert this Code From Delphi To VB?

    okey its clear now,
    thanks again for the explanation sir whatsup, and thanks sir si_the_geek for the link
    ill give time to read it


    regards

  13. #13
    New Member
    Join Date
    Apr 2011
    Posts
    1

    Re: [RESOLVED] Anyone Can Convert this Code From VB to Delphi?

    Help Me for converter This Code to Delphi
    Private Const MAX_DATALOGS As Integer = 500
    Dim TotalEntries As Integer, numTrans As Integer
    Dim Manejador_Memoria As IntPtr = IntPtr.Zero
    Dim buffSizeTotal As Integer, buffSize1Trans As Integer, lStatus As Integer
    Dim BII_Transaction As cDatalogVF.BII_Transaction_Log_Struct

    'checa si la terminal no esta Busy
    '1 The MV1200 is busy.
    '0 The(MV1200 Is idle)
    '2 The MV1200 is cleaning up flash
    'Error(<0) An error specified in the error table. See end of chapter for a description.
    lStatus = cDatalogVF.BII_Status_MT(HUNIT)
    If lStatus <> 0 Then
    Return False
    End If

    ' Determina el total de todas las transacciones
    TotalEntries = cDatalogVF.BII_Get_Num_Transaction_Log_MT(HUNIT, cDatalogVF.ALL_TRANSACTIONS)
    If TotalEntries < 0 Then
    Return False
    End If

    m_NumTransToEvaluate = -1
    m_NumTransProcessed = 0

    buffSize1Trans = Marshal.SizeOf(BII_Transaction.GetType)
    m_Resul = 1
    ' el while tiene como fin leer por bloques de MAX_DATALOGS todas las transaccines almacenadas
    ' en el lector e irlas procesando, mientras...
    While TotalEntries > 0 And m_Resul > 0 And lStatus = 0
    ' mientras haya checadas y no se tengan errores
    If TotalEntries > MAX_DATALOGS Then
    numTrans = MAX_DATALOGS
    Else
    numTrans = TotalEntries
    End If
    TotalEntries -= numTrans
    Try
    ' calcula el tamaño de todo el buffer de transacciones a bajar
    buffSizeTotal = buffSize1Trans * numTrans
    Dim rawData(buffSizeTotal - 1) As Byte
    Manejador_Memoria = Marshal.AllocHGlobal(buffSizeTotal)

    'checa si la terminal no esta Busy
    lStatus = cDatalogVF.BII_Status_MT(HUNIT)
    If lStatus = 0 Then
    ' baja el buffer y las marca como leidas
    m_Resul = cDatalogVF.BII_Read_Transaction_Log_MT(HUNIT, cDatalogVF.ALL_TRANSACTIONS, 1, numTrans, Manejador_Memoria)
    If m_Resul > 0 Then
    ' copia el buffer de memoria en un arreglo de bytes
    Marshal.Copy(Manejador_Memoria, rawData, 0, buffSizeTotal)
    Marshal.FreeHGlobal(Manejador_Memoria)
    'por cada una de las transaciones bajadas
    For i As Integer = 0 To numTrans - 1
    Manejador_Memoria = Marshal.AllocHGlobal(buffSize1Trans)
    'toma del arreglo de bytes la porcion correspondiente a la transacciones y lo copia en un buffer de memoria
    Marshal.Copy(rawData, i * buffSize1Trans, Manejador_Memoria, buffSize1Trans)
    BII_Transaction = CType(Marshal.PtrToStructure(Manejador_Memoria, GetType(cDatalogVF.BII_Transaction_Log_Struct)), cDatalogVF.BII_Transaction_Log_Struct)
    '---------------------------------------------------------------------
    ' registra la transaccion
    WriteTransacc(BII_Transaction)
    '---------------------------------------------------------------------
    Marshal.FreeHGlobal(Manejador_Memoria)
    Manejador_Memoria = IntPtr.Zero
    Next
    Marshal.FreeHGlobal(Manejador_Memoria)
    Manejador_Memoria = IntPtr.Zero
    End If
    End If 'If lStatus = 0 Then
    Catch ex As Exception
    lStatus = -99 'Error generico
    Finally
    If Not Manejador_Memoria.Equals(IntPtr.Zero) Then Marshal.FreeHGlobal(Manejador_Memoria)
    Manejador_Memoria = IntPtr.Zero
    End Try
    'checa si la terminal no esta Busy
    lStatus = cDatalogVF.BII_Status_MT(HUNIT)
    If lStatus = 0 And m_Resul > 0 Then
    ' borra las transacciones marcadas como ya leidas
    m_Resul = cDatalogVF.BII_Erase_Transaction_Log_MT(HUNIT, cDatalogVF.ONLY_READ_TRANSACTIONS, cDatalogVF.ASYNC_MODE)
    End If 'If lStatus <> 0 Then
    End While
    ' Una vez obtenidas todas dispara el evento OnDatalogTransactions avisando que ya termino

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