Jump to content

alank2

Members
  • Content Count

    176
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by alank2

  1. I've been using 10.3.3 for a long time, but needed to upgrade to a newer version because TMultipartFormData does not properly work on it. I get a 400 BadRequest instead of a 200 OK. Something with this component must have been updated because it works in later versions. I couldn't get 12.2 to install on the machine I have 10.3.3 because for some reason it won't install the bds.exe and then gives an error trying to run it (embarcadero unable to execute file c:\program files (x86)\embarcadero\studio\23.0\bin\bds.exe). Not getting past that I decide to install it on a different machine (win11 instead of win10) that I am moving to (new notebook). Install goes fine there, but it has a weird debugging crash problem I can't figure out: I am building a program in debug mode. It has one unit in it. I can step into the program. I can go to cursor and step through FormShow for Unit1. I can go to cursor and step through two different functions that are called by TStartTimer. BUT, if I go to cursor inside of even a mostly empty TStartTimer, it will hang for 60 seconds and the compiler/application will close and leave me looking at the desktop. Even if I cut this function down to this: void __fastcall TFMainform::TStartTimer(TObject *Sender) { // wchar_t ws1[4096]; wchar_t ws1[1024], ws2[1024], wts1[1024], cmd[1024]; //disable timer TStart->Enabled=false; } It will currently WORK in the above scenario. I can go to cursor the TStart->Enabled=false; statement and then step over/run and all is fine. If I change the variables so that the ws1 is unremarked and the line with the 4 variables below it is remarked, it will CRASH despite both still being the same amount of overall variables put on the stack. I've tried the classic win32 compiler and the newer one, same result. I've tried enabling or disabling codeguard, same result. The code works if I don't try to stop inside this function. If I unremark everything that was in there to make the API call, I get a 200 OK back from it. It just seems to hang if I try to stop and step inside it. edit to add; 11.3 does not have the problem. it works fine there. also, while I'm piling on 12.2, if I open the project and do a build immediately, I get errors like this: If I then double click unit1.cpp to open it and repeat the build, these errors go away. Any ideas?
  2. I tried Application->Terminate(); or Svcmgr::Application->Terminate();, but they do not exist. There is this, but I have no idea what the CtrlCode is - is there one for "stop" ? void __stdcall ServiceController(unsigned CtrlCode) { Service1->Controller(CtrlCode); } What is the proper way for a service application to request shutdown? I have a ServiceExecute method being called that contains this: while (!Terminated) { ServiceThread->ProcessRequests(true); Sleep(250); } I can't change Terminated to true, it says it is inaccessible.
  3. Thanks Remy; I'll work through this! I appreciate it.
  4. The sleep isn't really important as it was just added to keep it from consuming the CPU if ServiceThread->ProcessRequests(true); returns immediately. I am okay with ServiceThread->ProcessRequests(true); not returning until the service is stopped, the loop only needs to come into play during that situation where the "while (!Terminated || !TProcess->Enabled)" keeps it running until TProcess->Enabled becomes true (meaning that that method has successfully completed). The goal there is to not have the service stop without waiting for the TProcess method to complete. Maybe the 250ms should be dropped to 1ms in the Sleep as that could be keeping the ServiceThread->ProcessRequests(true); from executing more quickly to help it get stopped. So, my ServiceExecute does (1) init code, (2) ServiceThread->ProcessRequests until terminated and my tprocess timer method is complete, and finally (3) termination code. Is there a better way to do it? Should I move 1 into OnStart and 2 into OnStop? Can I eliminate ServiceExecute but still have it wait on the tprocess timer method to complete before executing OnStop and shutting down?
  5. I called this from a timer method and it did not work. ServiceThread->Terminate(); But this worked beautifully. ServiceController(SERVICE_CONTROL_STOP); Thanks for the info! I've got other init code in it and my loop also tests to see if the timer has finished executing before exiting the loop. I clear TProcess->Enabled when entering it and set it when it exits. log1.Log(L"Service started"); TProcess->Enabled=true; while (!Terminated || !TProcess->Enabled) //do not quit if process is running until it is finished { ServiceThread->ProcessRequests(true); Sleep(250); } TProcess->Enabled=false; log1.Log(L"Service STOPPED");
  6. alank2

    12.2 Crashing during debugging

    https://embt.atlassian.net/servicedesk/customer/portal/1/RSS-1987 They changed its status to Open. >I also get the same issue if I add a line: > String S = _D("μ \u00B5 α Ω °C © Å "); >and then save the file - this forces the file encoding to be UTF-8 with a BOM identifier. >Definitely a bug.  You might add this note to the case link above. >What is interesting is that the IDE works fine with target of Win64 (traditional) or Win64 (modern). I agree, tested this and it worked fine. >What is interesting and surprising is that the IDE hangs in the same bad way if you use the Win32 classic compiler. I tried newer and classic, both failed. Also codeguard on or off, both failed.
  7. alank2

    12.2 Crashing during debugging

    I opened up a bug request at the Embarcadero site (RSS-1987) for this.
  8. alank2

    12.2 Crashing during debugging

    This bug is easily reproduced. Launch RAD Studio 12.2 File -> New -> Windows VCL Application - C++ Builder Save All - give the project a new folder to work in and save the files Double Click Target Platform - Windows 32-bit to select it F12 on unit1.cpp to go to code. Insert the below bold lines in the form constructor __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { int i1; i1=5; } Save All Project -> Build All Press F4 on the i1=5; line Press F8 to step forward (this works as expected) Now change it to this by adding a declaration for headers: __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { int i1; char headers[4096]; i1=5; } Save All Project -> Build All Press F4 on the i1=5; line (it will stop here making you think it is working correctly, but it is hung. You can try to press F8, but it will not step forward and about 30-60 seconds later RAD Studio will crash and disappear form the desktop).
  9. alank2

    12.2 Crashing during debugging

    I appreciate the reply. I was not doing a make, but a build for the compile that generates the linker errors, so it shouldn't (I would think) use any existing data, but I'm not sure if it uses any precompiled headers or similar. I know it shouldn't have an error one way (just opening a problem) and not 3 seconds later after just opening a unit like Unit1.cpp. It should build either of those states exactly the same. As odd as that error is, the big one is the debugging one is the deal breaker for me being unable to use 12.2. I'll try to delete any intermediate files and see if that changes anything. I suppose I could build a new project file instead of upgrading my 10.3.3 one to see if that has any bearing on the issue as well. Thanks!
  10. I am trying to think about how to set up a server API that would push data down to multiple sites, but I don't want those sites to have to require static IP/domain name/opened ports of any type. The general work flow I am thinking about would be that an API request is made from the Internet to the server and then the server would push that request to one of the multiple sites (again, no static ip, no DNS, no open ports). I don't want polling where the clients hit the API every so many seconds or minutes, but the real time speed of the data being pushed to them. I am just thinking about IP here, and in that context I am presuming that the multiple sites must start a service or program that reaches out to the server API to establish the connection, but keeps that connection open. Then the server, when it wants to push something to them, would already have that open connection to send it over. Would that be a workable plan? Is that the way something like this is being done by others? Are there better ways to do it? Are there service providers that handle some of the tough lifting on this? Is this something that the Windows Communication Foundation does? Is there something better?
  11. Thanks for the ideas; I appreciate them. Will keep thinking through this.
  12. I am familiar with setting them as an array like this: nhc->CustomHeaders["Authorization"]="mydata"; But could all of them be set from a string formatted as http headers like this authorization:mydata another:value As a single string with a newline between them? If so, how? I see a Data, but it is a const void. (I am using cppbuilder)
  13. This isn't an Embarcadero question per se, but a generic #include <windows.h> and data alignment question. Do the structures defined in windows.h require a specific alignment in the operating system? I have a legacy program that uses 1-byte alignment and the result is a VOLUME_DISK_EXTENTS structure of 24 bytes. If I call DeviceIoControl(Volume, IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS, ...) with this 24 bytes for the size, it fails, but when packing by 8 bytes resulting in a structure size of 32, it works fine. I solved this by wrapping the windows.h header with pshpack8/poppack, but if the structures require 8 byte alignment, why didn't they do this inside windows.h? #include <pshpack8.h> #include <windows.h> #include <shlobj.h> #include <poppack.h> edit : I found this: https://stackoverflow.com/questions/29518184/64-bit-windows-api-struct-alignment-caused-access-denied-error-on-named-pipe Does the VCL expect a specific alignment (#include <vcl.h>) ?
  14. alank2

    C++ / windows.h and data alignment

    Also, just to add to this, the latest headers in VS2019 do warn of this problem - if the structure packing is changed to something other than 8 and you include <windows.h>, it will give this error. Severity Code Description Project File Line Suppression State Error C2338 Windows headers require the default packing option. Changing this can lead to memory corruption. This diagnostic can be disabled by building with WINDOWS_IGNORE_PACKING_MISMATCH defined. Which is easily fixed by wrapping the include like this: #include <pshpack8.h> #include <windows.h> #include <poppack.h>
  15. alank2

    C++ / windows.h and data alignment

    Mine too; I couldn't believe it until I saw the sizeof() some structures were different based on the data packing setting.
  16. alank2

    C++ / windows.h and data alignment

    I thought so too, but see the Remy's link above for: What structure packing do the Windows SDK header files expect? Expect as in it should be set to 8 byte packing BEFORE including the windows.h header. Unlike the vcl.h and presumably fmx.h headers which Remy mentioned above will changing the packing to 8 if it is something different.
  17. alank2

    C++ / windows.h and data alignment

    Try moving it before the vcl.h include and see if that causes it.
  18. alank2

    C++ / windows.h and data alignment

    That is the whole problem I am describing here. They do not. If you change the data alignment from its default of 8, then the structures defined in windows.h will not be correct for what the OS expects. Remy - I usually use #include <pshpack8.h>, but I thoght I'd try your #pragma pack(push,8) and #pragma pack(pop) like this: #pragma pack(push,8) #include <windows.h> #pragma pack(pop) The result is a warning from cppb10.3: [bcc32 Warning] program.cpp(34): W8083 Pragma pack pop with no matching pack push If I remark out the #include, then no warning. Does this mean that MS's header pops more than it pushes leaving my final pop to not have its matching push?
  19. alank2

    C++ / windows.h and data alignment

    Oddly, they don't. If a project's alignment is changed from quad word (8) to something else, there will be issues including windows.h because its structures may not be 8 aligned as the OS expects them to be. I'm glad Embarcadero's copy does force 8 byte alignment, I would have thought that Microsoft's windows.h would have done the same thing, but it doesn't. I only ran into this with some legacy code that needs to be compiled with 1 byte alignment. I'll just be careful to wrap windows.h in a pack 8. Thanks everyone!
  20. If I throw 3 buttons onto a form and set button 1's click to this, it seems the ProcessMessages doesn't fully update all the buttons status. I can run this in bcb6 which is very old, but it behaves as expected, all 3 buttons go to gray/disabled, 3s goes by, then they are become active again, then another 3s delay before the form is available for another click. In cppb10.3 however, something different happens. The first time it is run, the first pass leaves button1 in a non normal state, but not disabled. buttons2/3 unaffected. When it gets to the 2nd pass where it sets the buttons to true, now it updates button1 to visible, and it disables button2 (from the earlier set to false!) The second time it is run, the button1 goes disabled, but buttons 2/3 stay enabled, until the second pass where button1 goes enabled, but buttons 2/3 go disabled. I think ProcessMessages was supposed to process all messages, right? (and yes, the loop where I repeatedly call processmessages every 100ms, does update them more as expected, but not instantaneously) void __fastcall TForm1::Button1Click(TObject *Sender) { //int i1; Button1->Enabled=false; Button2->Enabled=false; Button3->Enabled=false; Application->ProcessMessages(); Sleep(3000); /* for (i1=0; i1<30; i1++) { Application->ProcessMessages(); Sleep(3000/30); }*/ Button1->Enabled=true; Button2->Enabled=true; Button3->Enabled=true; Application->ProcessMessages(); Sleep(3000); }
  21. alank2

    ProcessMessages doesn't seem to update controls

    A colleague of mine suggested changing DoubleBuffered and this seems to change the behavior enough to fix it! edit: well, it fixes it in debug mode, but not always in release mode so it isn't a fix after all.
  22. alank2

    ProcessMessages doesn't seem to update controls

    This really does have to do with the highlighting and styling of the button. If I make a loop that disables and enables a button when clicking it, sometimes it won't change states if I am still hovering over it with the mouse. Is there a way to disable the highlighting that happens when you simply hover over a button?
  23. alank2

    ProcessMessages doesn't seem to update controls

    Fr0sT.Brutal that works - the optimal delay is above 300ms: #define DELAY 325 Label1->Caption="off"; Button1->Enabled=false; Button2->Enabled=false; Button3->Enabled=false; Sleep(DELAY); Application->ProcessMessages(); Sleep(3000); Label1->Caption="on"; Button1->Enabled=true; Button2->Enabled=true; Button3->Enabled=true; Sleep(DELAY); Application->ProcessMessages(); Sleep(3000); Label1->Caption="";
  24. alank2

    ProcessMessages doesn't seem to update controls

    DelphiUdIT - I tried the below (with and without the processmessages calls) and it still has the issue Button1->Enabled=false; Button1->Update(); Button2->Enabled=false; Button2->Update(); Button3->Enabled=false; Button3->Update(); // Application->ProcessMessages(); Sleep(3000); Button1->Enabled=true; Button1->Update(); Button2->Enabled=true; Button2->Update(); Button3->Enabled=true; Button3->Update(); // Application->ProcessMessages(); Sleep(3000);
×