Search Results

Search found 4237 results on 170 pages for 'delphi 2009'.

Page 27/170 | < Previous Page | 23 24 25 26 27 28 29 30 31 32 33 34  | Next Page >

  • Delphi: Alternative to using Reset/ReadLn for text file reading

    - by Ian Boyd
    i want to process a text file line by line. In the olden days i loaded the file into a StringList: slFile := TStringList.Create(); slFile.LoadFromFile(filename); for i := 0 to slFile.Count-1 do begin oneLine := slFile.Strings[i]; //process the line end; Problem with that is once the file gets to be a few hundred megabytes, i have to allocate a huge chunk of memory; when really i only need enough memory to hold one line at a time. (Plus, you can't really indicate progress when you the system is locked up loading the file in step 1). The i tried using the native, and recommended, file I/O routines provided by Delphi: var f: TextFile; begin Reset(f, filename); while ReadLn(f, oneLine) do begin //process the line end; Problem withAssign is that there is no option to read the file without locking (i.e. fmShareDenyNone). The former stringlist example doesn't support no-lock either, unless you change it to LoadFromStream: slFile := TStringList.Create; stream := TFileStream.Create(filename, fmOpenRead or fmShareDenyNone); slFile.LoadFromStream(stream); stream.Free; for i := 0 to slFile.Count-1 do begin oneLine := slFile.Strings[i]; //process the line end; So now even though i've gained no locks being held, i'm back to loading the entire file into memory. Is there some alternative to Assign/ReadLn, where i can read a file line-by-line, without taking a sharing lock? i'd rather not get directly into Win32 CreateFile/ReadFile, and having to deal with allocating buffers and detecting CR, LF, CRLF's. i thought about memory mapped files, but there's the difficulty if the entire file doesn't fit (map) into virtual memory, and having to maps views (pieces) of the file at a time. Starts to get ugly. i just want Reset with fmShareDenyNone!

    Read the article

  • Best way to test a Delphi application

    - by Osama ALASSIRY
    I have a Delphi application that has many dependencies, and it would be difficult to refactor it to use DUnit (it's huge), so I was thinking about using something like AutomatedQA's TestComplete to do the testing from the front-end UI. My main problem is that a bugfix or new feature sometimes breaks old code that was previously tested (manually), and used to work. I have setup the application to use command-line switches to open-up a specific form that could be tested, and I can create a set of values and clicks needed to be done. But I have a few questions before I do anything drastic... (and before purchasing anything) Is it worth it? Would this be a good way to test? The result of the test should in my database (Oracle), is there an easy way in testcomplete to check these values (multiple fields in multiple tables)? I would need to setup a test database to do all the automated testing, would there be an easy way to automate re-setting the test db? Other than drop user cascade, create user,..., impdp. Is there a way in testcomplete to specify command-line parameters for an exe? Does anybody have any similar experiences.

    Read the article

  • Delphi: Problems with TList of Frames

    - by Dan Kelly
    I'm having a problem with an interface that consists of a number of frames (normally 25) within a TScrollBox. There are 2 problems, and I am hoping that one is a consequence of the other... Background: When the application starts up, I create 25 frames, each containing approx. 20 controls, which are then populated with the default information. The user can then click on a control to limit the search to a subset of information at which point I free and recreate my frames (as the search may return < 25 records) The problem: If I quit the application after the initial search then it takes approx. 5 seconds to return to Delphi. After the 2nd search (and dispose / recreate of frames) it takes approx. 20 seconds) Whilst I could rewrite the application to only create the frames once, I would like to understand what is going on. Here is my create routine: procedure TMF.CreateFrame(i: Integer; var FrameBottom: Integer); var NewFrame: TSF; begin NewFrame := TSF.Create(Self); NewFrame.Name := 'SF' + IntToStr(i); if i = 0 then NewSF.Top := 8 else NewSF.Top := FrameBottom + 8; FrameBottom := NewFrame.Top + NewFrame.Height; NewFrame.Parent := ScrollBox1; FrameList.Add(NewFrame); end; And here is my delete routine: procedure TMF.ClearFrames; var i: Integer; SF: TSF; begin for i := 0 to MF.FrameList.Count -1 do begin SF := FrameList[i]; SF.Free; end; FrameList.Clear; end; What am I missing?

    Read the article

  • Delphi Performance: Case Versus If

    - by Andreas Rejbrand
    I guess there might be some overlapping with previous SO questions, but I could not find a Delphi-specific question on this topic. Suppose that you want to check if an unsigned 32-bit integer variable "MyAction" is equal to any of the constants ACTION1, ACTION2, ... ACTIONn, where n is - say 1000. I guess that, besides being more elegant, case MyAction of ACTION1: {code}; ACTION2: {code}; ... ACTIONn: {code}; end; if much faster than if MyAction = ACTION1 then // code else if MyAction = ACTION2 then // code ... else if MyAction = ACTIONn then // code; I guess that the if variant takes time O(n) to complete (i.e. to find the right action) if the right action ACTIONi has a high value of i, whereas the case variant takes a lot less time (O(1)?). Am I correct that switch is much faster? Am I correct that the time required to find the right action in the switch case actually is independent of n? I.e. is it true that it does not really take any longer to check a million cases than to check 10 cases? How, exactly, does this work?

    Read the article

  • Delphi - Help calling threaded dll function from another thread

    - by cloudstrif3
    I'm using Delphi 2006 and have a bit of a problem with an application I'm developing. I have a form that creates a thread which calls a function that performs a lengthy operation, lets call it LengthyProcess. Inside the LengthyProcess function we also call several Dll functions which also create threads of their own. The problem that I am having is that if I don't use the Synchronize function of my thread to call LengthyProcess the thread stops responding (the main thread is still responding fine). I don't want to use Synchronize because that means the main thread is waiting for LengthyProcess to finish and therefore defeats the purpose of creating a separate thread. I have tracked the problem down to a function inside the dll that creates a thread and then calls WaitFor, this is all done using TThread by the way. WaitFor checks to see if the CurrentThreadID is equal to the MainThreadID and if it is then it will call CheckSychronization, and all is fine. So if we use Synchronize then the CurrentThreadID will equal the MainThreadID however if we do not use Synchronize then of course CurrentThreadID < MainThreadID, and when this happens WaitFor tells the current thread (the thread I created) to wait for the thread created by the DLL and so CheckSynchronization never gets called and my thread ends up waiting forever for the thread created in the dll. I hope this makes sense, sorry I don't know any better way to explain it. Has anyone else had this issue and knows how to solve it please?

    Read the article

  • delphi app freezes whole win7 system

    - by avar
    Hello i have a simple program that sorts a text file according to length of words per line this program works without problems in my xp based old machine now i run this program on my new win7/intel core i5 machine, it freezes whole system and back normal after it finishes it's work. i'v invastigated the code and found the line causing the freeze it was this specific line... caption := IntToStr(i) + '..' + IntTostr(ii); i'v changed it to caption := IntTostr(ii); //slow rate change and there is no freeze and then i'v changed it to caption := IntTostr(i); //fast rate change and it freeze again my main complete procedure code is var tword : widestring; i,ii,li : integer; begin tntlistbox1.items.LoadFromFile('d:\new folder\ch.txt'); tntlistbox2.items.LoadFromFile('d:\new folder\uy.txt'); For ii := 15 Downto 1 Do //slow change Begin For I := 0 To TntListBox1.items.Count - 1 Do //very fast change Begin caption := IntToStr(i) + '..' + IntTostr(ii); //problemetic line tword := TntListBox1.items[i]; LI := Length(tword); If lI = ii Then Begin tntlistbox3.items.Add(Trim(tntlistbox1.Items[i])); tntlistbox4.items.Add(Trim(tntlistbox2.Items[i])); End; End; End; end; any idea why ? and how to fix it? i use delphi 2007/win32

    Read the article

  • Delphi trace tool

    - by Max
    I was wondering if there's a tool or a component for Delphi that can trace method execution line by line and create a log file. With this kind of tool it is easy to compare how method performs on two sets of input data by comparing two log files. EDIT: Let's say there is a function 10: function MyFunction(aInput: Integer): Integer; 11: begin 12: if aInput 10 then 13: Result := 10 14: else 15: Result := 0; 16: end; I'm looking for a tool that would give the log which whould be similar to the following: When aInput parameter is 1: Line 10: 'function MyFunction(aInput: Integer): Integer;' Line 11: 'begin' Line 12: 'if aInput 10 then' Line 15: 'Result := 0;' Line 16: 'end;' and when aInput parameter is 11: Line 10: 'function MyFunction(aInput: Integer): Integer;' Line 11: 'begin' Line 12: 'if aInput 10 then' Line 13: 'Result := 10;' Line 16: 'end;' The only information that should be required by the tool is the function name. It's like stepping through the method under debugger, but in an automatic manner with logging every line of code.

    Read the article

  • Delphi: Error when starting MCI

    - by marco92w
    I use the TMediaPlayer component for playing music. It works fine with most of my tracks. But it doesn't work with some tracks. When I want to play them, the following error message is shown: Which is German but roughly means that: In the project pMusicPlayer.exe an exception of the class EMCIDeviceError occurred. Message: "Error when starting MCI.". Process was stopped. Continue with "Single Command/Statement" or "Start". The program quits directly after calling the procedure "Play" of TMediaPlayer. This error occurred with the following file for example: file size: 7.40 MB duration: 4:02 minutes bitrate: 256 kBit/s I've encoded this file with a bitrate of 128 kBit/s and thus a file size of 3.70 MB: It works fine! What's wrong with the first file? Windows Media Player or other programs can play it without any problems. Is it possible that Delphi's TMediaPlayer cannot handle big files (e.g. 5 MB) or files with a high bitrate (e.g. 128 kBit/s)? What can I do to solve the problem?

    Read the article

  • Delphi: Center Specific Line in TRichEdit by Scrolling

    - by Anagoge
    I have a Delphi 2007 TRichEdit with several lines in it. I want to scroll the richedit vertically such that a specific line number if approximately centered in the visible/display area of the richedit. For example, I want to write the code for CenterLineInRichEdit in this example: procedure CenterLineInRichEdit(Edit: TRichEdit; LineNum: Integer); begin ... Edit.ScrollTo(...); end; procedure TForm1.FormCreate(Sender: TObject); var REdit: TRichEdit; i: Integer; begin REdit := TRichEdit.Create(Self); REdit.Parent := Self; Redit.ScrollBars := ssVertical; REdit.SetBounds(10, 10, 200, 150); for i := 1 to 25 do REdit.Lines.Add('This is line number ' + IntToStr(i)); CenterLineInRichEdit(REdit, 13); end; I looked into using the WM_VSCROLL message, and it allows scrolling up/down one line, etc. but not scrolling to center a specific line. I assume I would need to calculate the line height, the display area height, etc? Or is there an easier way?

    Read the article

  • Delphi fastMM doesn't work with operator "IS"

    - by Joc02
    I work on Delphi project who interac with many other small libraries. I use FastMM4 and I would like work with complex classes passed on dll parameter. So for exemple I send my form to my dll. Into the dll I test the type of parameter with the operator "IS". But into the Dll the operator "IS" return always "false" Exemple library Dll; uses FastMM4, System.SysUtils, System.Classes, Vcl.Dialogs, Vcl.Forms; {$R *.res} procedure Complex(L : TObject);stdcall; begin if L is TForm then showmessage('Ok') else showmessage('Pas ok') ; if L is TCustomFrame then showmessage('Ok') else showmessage('Pas ok') end; exports Complex; begin end. And the call procedure TffsIsOperator.Button2Click(Sender: TObject); var MaDLL : THandle; Proc : procedure (l : TForm); begin try MaDLL := LoadLibrary(PChar('Dll.dll')); @Proc := GetProcAddress(MaDLL, 'Complex'); Proc(self); finally FreeLibrary(MaDLL); end; end;

    Read the article

  • Accessing Sub functions /procedures from DPR or other function / procedure in Delphi

    - by HX_unbanned
    Hello, stackoverflowers :) As much I know - Subroutines are with Private access mode to its parent unction / procedure, right? Is there any way to access them from "outer-world" - dpr or other function / procedure in unit? Also - which way takes more calcualtion and space to compiled file? for example: function blablabla(parameter : tparameter) : abcde; procedure xyz(par_ : tpar_); begin // ... end; begin // ... end; procedure albalbalb(param : tparam) : www; begin xyz(par_ : tpar); // is there any way to make this function public / published to access it therefore enabling to call it this way? end; // all text is random. // also, is there way to call it from DPR in this manner? // in C++ this can be done by specifing access mode and/or using "Friend" class .. but in DELPHI?

    Read the article

  • Delphi static method of a class returning property value

    - by mitko.berbatov
    I'm making a Delphi VCL application. There is a class TStudent where I have two static functions: one which returns last name from an array of TStudent and another one which returns the first name of the student. Their code is something like: class function TStudent.FirstNameOf(aLastName: string): string; var i : integer; begin for i := 0 to Length(studentsArray) - 1 do begin if studentsArray[i].LastName = aLastName then begin result := studentsArray[i].FirstName; Exit; end; end; result := 'no match was found'; end; class function TStudent.LastNameOf(aFirstName: string): string; var i : integer; begin for i := 0 to Length(studentsArray) - 1 do begin if studentsArray[i].FirstName = aFirstName then begin result := studentsArray[i].LastName; Exit; end; end; result := 'no match was found'; end; My question is how can I avoid writing almost same code twice. Is there any way to pass the property as parameter of the functions.

    Read the article

  • Creating a ComboBox with one or more separator items?

    - by Steve
    I'm using Delphi7 and I'd like to have a ComboBox with separator items (Just like in popup menus). I've seen this beautifully implemented in Mozilla Sunbird (I know, it's not Delphi...) the following way: The separator item is a simple gray line drawn in the center of the item If you hover over the separator with the mouse, the selection doesn't appear If the user clicks the separator, it's not selected either AND the combobox doesn't closeup. No. 1 could be implemented using DrawItem. I could live without No. 2 because I have no idea about that. For No. 3 I'm asking for your help. I've figured out that straight after closing up a CBN_CLOSEUP message is sent to the combobox. I thought about hooking the window proc and if CBN_CLOSEUP is sent to a certain combobox then countering it. But I'm unsure if this is the best solution, or maybe there are other, more elegant ways? Whatever the solution is, I'd like to have a standard ComboBox which supports WinXP/Vista/7 theming properly. Thanks! Edit: For a working component please see this thread: Can you help translating this very small C++ component to Delphi?

    Read the article

  • UTF-8 GET using Indy 10.5.8.0 and Delphi XE2

    - by Bogdan Botezatu
    I'm writing my first Unicode application with Delphi XE2 and I've stumbled upon an issue with GET requests to an Unicode URL. Shortly put, it's a routine in a MP3 tagging application that takes a track title and an artist and queries Last.FM for the corresponding album, track no and genre. I have the following code: function GetMP3Info(artist, track: string) : TMP3Data //<---(This is a record) var TrackTitle, ArtistTitle : WideString; webquery : WideString; [....] WebQuery := UTF8Encode('http://ws.audioscrobbler.com/2.0/?method=track.getcorrection&api_key=' + apikey + '&artist=' + artist + '&track=' + track); //[processing the result in the web query, getting the correction for the artist and title] // eg: for artist := Bucovina and track := Mestecanis, the corrected values are //ArtistTitle := Bucovina; // TrackTitle := Mestecani?; //Now here is the tricky part: webquery := UTF8Encode('http://ws.audioscrobbler.com/2.0/?method=track.getInfo&api_key=' + apikey + '&artist=' + unescape(ArtistTitle) + '&track=' + unescape(TrackTitle)); //the unescape function replaces spaces (' ') with '+' to comply with the last.fm requests [some more processing] end; The webquery looks in a TMemo just right (http://ws.audioscrobbler.com/2.0/?method=track.getInfo&api_key=e5565002840xxxxxxxxxxxxxx23b98ad&artist=Bucovina&track=Mestecani?) Yet, when I try to send a GET() to the webquery using IdHTTP (with the ContentEncoding property set to 'UTF-8'), I see in Wireshark that the component is GET-ing the data to the ANSI value '/2.0/?method=track.getInfo&api_key=e5565002840xxxxxxxxxxxxxx23b98ad&artist=Bucovina&track=Mestec?ni?' Here is the full headers for the GET requests and responses: GET /2.0/?method=track.getInfo&api_key=e5565002840xxxxxxxxxxxxxx23b98ad&artist=Bucovina&track=Mestec?ni? HTTP/1.1 Content-Encoding: UTF-8 Host: ws.audioscrobbler.com Accept: text/html, */* Accept-Encoding: identity User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.23) Gecko/20110920 Firefox/3.6.23 SearchToolbar/1.22011-10-16 20:20:07 HTTP/1.0 400 Bad Request Date: Tue, 09 Oct 2012 20:46:31 GMT Server: Apache/2.2.22 (Unix) X-Web-Node: www204 Access-Control-Allow-Origin: * Access-Control-Allow-Methods: POST, GET, OPTIONS Access-Control-Max-Age: 86400 Cache-Control: max-age=10 Expires: Tue, 09 Oct 2012 20:46:42 GMT Content-Length: 114 Connection: close Content-Type: text/xml; charset=utf-8; <?xml version="1.0" encoding="utf-8"?> <lfm status="failed"> <error code="6"> Track not found </error> </lfm> The question that puzzles me is am I overseeing anything related to setting the property of the tidhttp control? How can I stop the well-formated URL i'm composing in the application from getting wrongfully sent to the server? Thanks.

    Read the article

  • Delphi - WndProc() in thread never called

    - by Robert Oschler
    I had code that worked fine when running in the context of the main VCL thread. This code allocated it's own WndProc() in order to handle SendMessage() calls. I am now trying to move it to a background thread because I am concerned that the SendMessage() traffic is affecting the main VCL thread adversely. So I created a worker thread with the sole purpose of allocating the WndProc() in its thread Execute() method to ensure that the WndProc() existed in the thread's execution context. The WndProc() handles the SendMessage() calls as they come in. The problem is that the worker thread's WndProc() method is never triggered. Note, doExecute() is part of a template method that is called by my TThreadExtended class which is a descendant of Delphi's TThread. TThreadExtended implements the thread Execute() method and calls doExecute() in a loop. I triple-checked and doExecute() is being called repeatedly. Also note that I call PeekMessage() right after I create the WndProc() in order to make sure that Windows creates a message queue for the thread. However something I am doing is wrong since the WndProc() method is never triggered. Here's the code below: // ========= BEGIN: CLASS - TWorkerThread ======================== constructor TWorkerThread.Create; begin FWndProcHandle := 0; inherited Create(false); end; // --------------------------------------------------------------- // This call is the thread's Execute() method. procedure TWorkerThread.doExecute; var Msg: TMsg; begin // Create the WndProc() in our thread's context. if FWndProcHandle = 0 then begin FWndProcHandle := AllocateHWND(WndProc); // Call PeekMessage() to make sure we have a window queue. PeekMessage(Msg, FWndProcHandle, 0, 0, PM_NOREMOVE); end; if Self.Terminated then begin // Get rid of the WndProc(). myDeallocateHWnd(FWndProcHandle); end; // Sleep a bit to avoid hogging the CPU. Sleep(5); end; // --------------------------------------------------------------- procedure TWorkerThread.WndProc(Var Msg: TMessage); begin // THIS CODE IS NEVER CALLED. try if Msg.Msg = WM_COPYDATA then begin // Is LParam assigned? if (Msg.LParam > 0) then begin // Yes. Treat it as a copy data structure. with PCopyDataStruct(Msg.LParam)^ do begin ... // Here is where I do my work. end; end; // if Assigned(Msg.LParam) then end; // if Msg.Msg = WM_COPYDATA then finally Msg.Result := 1; end; // try() end; // --------------------------------------------------------------- procedure TWorkerThread.myDeallocateHWnd(Wnd: HWND); var Instance: Pointer; begin Instance := Pointer(GetWindowLong(Wnd, GWL_WNDPROC)); if Instance <> @DefWindowProc then begin // Restore the default windows procedure before freeing memory. SetWindowLong(Wnd, GWL_WNDPROC, Longint(@DefWindowProc)); FreeObjectInstance(Instance); end; DestroyWindow(Wnd); end; // --------------------------------------------------------------- // ========= END : CLASS - TWorkerThread ======================== Thanks, Robert

    Read the article

  • Delphi - threads and FindFirst function

    - by radu-barbu
    Hi, I'm encountering a big problem when i'm trying to make a recursive search function inside a thread (using delphi 7) bellow is the code: TParcFicDir = class(TThread) private several variables.. protected procedure Execute; override; public constructor Create(CreateSuspended: Boolean); constructor TParcFicDir.Create(CreateSuspended: Boolean); begin inherited Create(CreateSuspended); end; procedure TParcFicDir.Execute; begin try FindFiles(FStartDir,FMask);//'c:\' and '*.*' except on e:Exception do end; end; procedure TParcFicDir.FindFiles(StartDir, FileMask: string); var wTmp : string; f:TextFile; wTempSR:TSearchRec; function Search(StartDir, FileMask: string): string; var SR : TSearchRec; IsFound : Boolean; files : integer; dirs : integer; t : string; begin try files := 0; dirs := 0; if StartDir[length(StartDir)] <> '\' then StartDir := StartDir + '\'; try IsFound := (FindFirst(StartDir + '*.*', faAnyFile, SR) = 0);// here the thread gets interrupted except on e: Exception do end; while IsFound do begin if (SR.Name <> '.') and (SR.Name <> '..') then if ((SR.Attr and faDirectory) <> 0) then if FScanDirs then begin inc(dirs); t := Search(StartDir + SR.Name, FileMask); try files := files + strtoint(copy((t), 0, pos('#', t) - 1));//old code, don't take on calcul; Delete(t, 1, pos('#', t)); dirs := dirs + strtoint(t); except on e: Exception do end; begin t := StartDir + SR.Name; wTmp := t; wtmp := ''; Inc(FDirNo); writeln(f,t); inc(filno); end; end else if ScanFiles then begin inc(filno); inc(files); end; IsFound := FindNext(SR) = 0; end; Result := IntToStr(files) + '#' + IntToStr(dirs); sysutils.FindClose(SR); except on e: Exception do end; end; begin filno := 0; try try if trim(FPathFileTmp)<>'' then AssignFile(f, FPathFileTmp+'Temp.bak') else AssignFile(f,ExtractFileDir(GetDllName)+'\Temp.bak'); Rewrite(f); Search(StartDir, FileMask); if StartDir[length(StartDir)] = '\' then delete(StartDir, length(StartDir), 1); wTmp := StartDir; wTmp := ''; if FindFirst(StartDir, faDirectory, wTempSR) = 0 then writeln(f); writeln(f); CloseFile(f); except on e: Exception do end; finally end; end; ok, probably the code is a little messed up, but i don't understand why the thread ends at 'findfirst' part....i googled it, no results. any help will be appreciated! Thanks in advance

    Read the article

  • calling delphi dll from c#

    - by Wouter Roux
    Hi, I have a Delphi dll defined like this: TMPData = record Lastname, Firstname: array[0..40] of char; Birthday: TDateTime; Pid: array[0..16] of char; Title: array[0..20] of char; Female: Boolean; Street: array[0..40] of char; ZipCode: array[0..10] of char; City: array[0..40] of char; Phone, Fax, Department, Company: array[0..20] of char; Pn: array[0..40] of char; In: array[0..16] of char; Hi: array[0..8] of char; Account: array[0..20] of char; Valid, Status: array[0..10] of char; Country, NameAffix: array[0..20] of char; W, H: single; Bp: array[0..10] of char; SocialSecurityNumber: array[0..9] of char; State: array[0..2] of char; end; function Init(const tmpData: TMPData; var ErrorCode: integer; ResetFatalError: boolean = false): boolean; procedure GetData(out tmpData: TMPData); My current c# signatures looks like this: [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public struct TMPData { [MarshalAs(UnmanagedType.LPStr, SizeConst = 40)] public string Lastname; [MarshalAs(UnmanagedType.LPStr, SizeConst = 40)] public string Firstname; [MarshalAs(UnmanagedType.R8)] public double Birthday; [MarshalAs(UnmanagedType.LPStr, SizeConst = 16)] public string Pid; [MarshalAs(UnmanagedType.LPStr, SizeConst = 20)] public string Title; [MarshalAs(UnmanagedType.Bool)] public bool Female; [MarshalAs(UnmanagedType.LPStr, SizeConst = 40)] public string Street; [MarshalAs(UnmanagedType.LPStr, SizeConst = 10)] public string ZipCode; [MarshalAs(UnmanagedType.LPStr, SizeConst = 40)] public string City; [MarshalAs(UnmanagedType.LPStr, SizeConst = 20)] public string Phone; [MarshalAs(UnmanagedType.LPStr, SizeConst = 20)] public string Fax; [MarshalAs(UnmanagedType.LPStr, SizeConst = 20)] public string Department; [MarshalAs(UnmanagedType.LPStr, SizeConst = 20)] public string Company; [MarshalAs(UnmanagedType.LPStr, SizeConst = 40)] public string Pn; [MarshalAs(UnmanagedType.LPStr, SizeConst = 16)] public string In; [MarshalAs(UnmanagedType.LPStr, SizeConst = 8)] public string Hi; [MarshalAs(UnmanagedType.LPStr, SizeConst = 20)] public string Account; [MarshalAs(UnmanagedType.LPStr, SizeConst = 10)] public string Valid; [MarshalAs(UnmanagedType.LPStr, SizeConst = 10)] public string Status; [MarshalAs(UnmanagedType.LPStr, SizeConst = 20)] public string Country; [MarshalAs(UnmanagedType.LPStr, SizeConst = 20)] public string NameAffix; [MarshalAs(UnmanagedType.I4)] public int W; [MarshalAs(UnmanagedType.I4)] public int H; [MarshalAs(UnmanagedType.LPStr, SizeConst = 10)] public string Bp; [MarshalAs(UnmanagedType.LPStr, SizeConst = 9)] public string SocialSecurityNumber; [MarshalAs(UnmanagedType.LPStr, SizeConst = 2)] public string State; } [DllImport("MyDll.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool Init(TMPData tmpData, int ErrorCode, bool ResetFatalError); [DllImport("MyDll.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool GetData(out TMPData tmpData); I first call Init setting the BirthDay, LastName and FirstName. I then call GetData but the TMPData structure I get back is incorrect. The FirstName, LastName and Birthday fields are populated but the data is incorrect. Is the mapping correct? ( "array[0..40] of char" equal to "[MarshalAs(UnmanagedType.LPStr, SizeConst = 40)]" )?

    Read the article

  • VCL/Delphi/BCB - which IDE/language should I use?

    - by mawg
    I bought Delphi 1 when it came out - and was hooked. When BCB came out (around D3, iirc), I switched, mainly because I have used C/C++ professionally for a few decades. I have "been away" for 7 or 8 years and am now returning. I still have BCB 6 & Delphi 7 (not to mention Kylix). I always felt more comfortable with C++ than Pascal - purely because of work-day familiarity. But, realistically, iirc, most 3rd party VCL components are coded in Delphi/Pascal. And I think I used to have problems debugging Delphi components from BCB, but I could well remember wrongly. Anyhoo, now I am back and intend to use VCL components / hack the code of same / debug them & code a few of my own. Given that I am slightly more comfortable with C++, is there any compelling reason to choose Delphi over BCB, or is this just a case of how long my particular piece of string is?

    Read the article

  • design suggestion for a message decoder in delphi

    - by stanleyxu2005
    Hi All, I want to implement a RPC module. Different requests are encoded as JSON objects. They will be decoded and then be handled by a request handler. At last a corresponding response will be returned. The demo code looks as follows: type IRequestHandler = interface function Handle(const Request: TAaaRequest): TResponse; function Handle(const Request: TBbbRequest): TResponse; end; TDecoder = class class function Decode(const Json: TJsonObject; const RequestHandler: IRequestHandler): TResponse; end; class function TDecoder.Decode(const Json: TJsonObject; const RequestHandler: IRequestHandler): TResponse; var Method: string; Request: TObject; begin Method := Json['method'].AsString; if (Method = TAaaRequest.ClassName) then begin Request := TAaaRequest.FromJSON(Json); // Casted as TObject if Request <> nil then begin Result := RequestHandler.Handle(TAaaRequest(Request)); Request.Free; end; end else if (Method = TBbbRequest.ClassName) then begin Request := TBbbRequest.FromJSON(Json); // Casted as TObject if Request <> nil then begin Result := RequestHandler.Handle(TBbbRequest(Request)); Request.Free; end; end else Result := CreateErrorResponse('Unknown method: ' + Json.ToString); end; According to the code, the handling of different request types are very similar. If I have 100 different request types, I have to copy and paste the above code block 100 times. This is not clever. I am looking for a better way to do the same logic. My imagination is as follows: TDecoder = class private FRequestTypes: TDictionary<string, TClassInfo>; // Does this work? public constructor Create; destructor Destroy; override; function Decode(const Json: TJsonObject; const RequestHandler: IRequestHandler): TResponse; end; constructor TDecoder.Create; begin FRequestTypes := TDictionary<string, TClassInfo>.Create; FRequestTypes.Add(TAaaRequest.ClassName, TAaaRequest); // Does this work? FRequestTypes.Add(TBbbRequest.ClassName, TBbbRequest); end; destructor TDecoder.Destroy; begin FRequestTypes.Free; inherited; end; function TDecoder.Decode(const Json: TJsonObject; const RequestHandler: IRequestHandler): TResponse; var Method: string; Info: TClassInfo; Request: TObject; begin Method := Json['method'].AsString; if FRequestTypes.ContainsKey(Method) then begin // An universal way Info := FRequestTypes[Method]; Request := Info.FromJSON(Json); // Casted as TObject if Request <> nil then begin Result := RequestHandler.Handle(Info(Request)); // Casted to corresponding class type (e.g. TAaaRequest or TBbbRequest) Request.Free; end; end else Result := CreateErrorResponse('Unknown method: ' + Json.ToString); end; I do not know, if I can write an universal way to handle a great number of different request types. Development environment Delphi 2010. Any hint is appreciated.

    Read the article

  • I need my BizTalk map to stop converting xml:lang to ns1:lang

    - by Jeremy Stein
    I have a map in BizTalk 2009 that is converting some data into an XML document to be sent on to another system. The target schema includes some elements with xml:lang attributes. BizTalk generates those as ns1:lang. The target system requires that the prefix xml be used. Here is a simplified example to show what BizTalk is doing: sample.xsd <xs:schema targetNamespace="http://example.com/" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:import schemaLocation="common.xsd" namespace="http://www.w3.org/XML/1998/namespace" /> <xs:element name="example"> <xs:complexType> <xs:attribute ref="xml:lang" /> </xs:complexType> </xs:element> </xs:schema> common.xsd <?xml version="1.0" encoding="utf-16"?> <xs:schema xmlns:xml="http://www.w3.org/XML/1998/namespace" targetNamespace="http://www.w3.org/XML/1998/namespace" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:attribute name="lang" type="xs:language" /> </xs:schema> Example of map output <ns0:example xmlns:ns0="http://example.com/" xmlns:ns1="http://www.w3.org/XML/1998/namespace" ns1:lang="en-US" /> Is there some way to convince BizTalk to use the xml prefix?

    Read the article

  • CEF3 application crash: Fault Module KERNELBASE.DLL

    - by Asadullah Laghari
    I am using CEF3 in Delphi XE3. Application crashes as soon as I launch it. It gives following details **Problem Event Name: APPCRASH Application Name: Project4.exe Application Version: 1.0.0.0 Application Timestamp: 50c4062d Fault Module Name: KERNELBASE.dll Fault Module Version: 6.2.9200.16384 Fault Module Timestamp: 5010acfa Exception Code: 0eedfade Exception Offset: 0001277c OS Version: 6.2.9200.2.0.0.256.48 Locale ID: 1033** Can anyone help me out plz??

    Read the article

  • What tool can I use to merge wsdl and xsd file?

    - by LukLed
    I have two files, one with webservice description (wsdl), second with data structures used in webservice (xsd). I have nothing more, webservice doesn't work yet. I need to merge them into one, because Delphi 7 WSDL Importer doesn't handle included xsd files to well. Where can I find tool to do it?

    Read the article

  • Python4Delphi: Returning a python object in a function. (DelphiWrapper)

    - by Gabriel Fonseca
    I am using python4delphi. ow can I return an object from a wrapped Delphi class function? Code Snippet: I have a simple Delphi Class that i wrapped to Python Script, right? TSimple = Class Private function getvar1:string; Public Published property var1:string read getVar1; function getObj:TSimple; end; ... function TSimple.getVar1:string; begin result:='hello'; end; function TSimple.getObj:TSimple; begin result:=self; end; I made the TPySimple like the demo32 to give class access to the python code. My python module name is test. TPyDado = class(TPyDelphiPersistent) // Constructors & Destructors constructor Create( APythonType : TPythonType ); override; constructor CreateWith( PythonType : TPythonType; args : PPyObject ); override; // Basic services function Repr : PPyObject; override; class function DelphiObjectClass : TClass; override; end; ... { TPyDado } constructor TPyDado.Create(APythonType: TPythonType); begin inherited; // we need to set DelphiObject property DelphiObject := TDado.Create; with TDado(DelphiObject) do begin end; Owned := True; // We own the objects we create end; constructor TPyDado.CreateWith(PythonType: TPythonType; args: PPyObject); begin inherited; with GetPythonEngine, DelphiObject as TDado do begin if PyArg_ParseTuple( args, ':CreateDado' ) = 0 then Exit; end; end; class function TPyDado.DelphiObjectClass: TClass; begin Result := TDado; end; function TPyDado.Repr: PPyObject; begin with GetPythonEngine, DelphiObject as TDado do Result := VariantAsPyObject(Format('',[])); // or Result := PyString_FromString( PAnsiChar(Format('(%d, %d)',[x, y])) ); end; And now the python code: import test a = test.Simple() # try access the property var1 and everything is right print a.var1 # work's, but.. b = a.getObj(); # raise a exception that not find any attributes named getObj. # if the function returns a string for example, it's work.

    Read the article

< Previous Page | 23 24 25 26 27 28 29 30 31 32 33 34  | Next Page >