Results 1 to 15 of 15

Thread: COM Objects on Windows 7 with 4.7.2

  1. #1
    Join Date
    Mar 2009
    Location
    Ada, OH, USA
    Posts
    11
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default COM Objects on Windows 7 with 4.7.2

    Good morning all. I've been using QT off and on for several years and have always been able to find answers to
    my problems here on the forum. So thanks for that... But I am stumpped this time.

    In my application I am printing Labels on a Dymo LabelWriter 400. I used the type library and opened a
    command box and ran "dumpcpp DYMO.DLS.SDK.tlb -o dymosdk". That generated the dymosdk.h and
    dymosdk.cpp files which I link into my application.

    I have been using Creator 2.0.1 and Qt 4.7.1 on a laptop running Vista (32bit) and it has been working fine.
    Then last weekend I set up an new desktop machine running Windows 7 (64bit) and installed Qt 4.7.2 and Creator 2.1.0.

    I installed the same DYMO software (& SDK) as on the Vista machine.

    Here is the code:
    Qt Code:
    1. dymoAddIn = new DYMO_DLS_SDK::ISDKDymoAddin();
    2. // dymoAddIn->setControl("{09DAFAE2-8EB0-11D2-8E5D-00A02415E90F}");
    3. dymoAddIn->setControl("Dymo.DymoAddIn");
    4. dymoAddIn->Open("d:/abe/catalog/abe_catalog/BinLabelKAWDIB-New.label");
    5.  
    6. dymoLabels = new DYMO_DLS_SDK::ISDKDymoLabels;
    7. // dymoLabels->setControl("{3AAD7661-8F83-11D2-8E5D-00A02415E90F}");
    8. dymoLabels->setControl("Dymo.DymoLabels");
    To copy to clipboard, switch view to plain text mode 
    When I run the application it chokes with

    CoCreateInstance failure (Class not registered)
    QAxBase::setControl: requested control Dymo.DymoAddIn could not be instantiated

    on first setControl() method, and

    CoCreateInstance failure (Not enough storage is available to complete this operation.)
    QAxBase::setControl: requested control Dymo.DymoLabels could not be instantiated

    on the second setControl() method.

    I have verified in the registry that the Guid is correct for both objects. The Dymo Label Software works just fine.
    I believe it uses the same COM objects I am trying to use. And as I said the same code works on my laptop running
    Vista using either the Guid or the name of the object.

    Can anybody think of anything else I can check? I thought about installing 4.7.1 (which is what is on the laptop)
    on the new machine, but thought I'd ask for help first...

    Thanks, Keith

  2. #2
    Join Date
    Oct 2009
    Posts
    364
    Thanks
    10
    Thanked 37 Times in 36 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: COM Objects on Windows 7 with 4.7.2

    It has been a while since I've used COM but I remember that the COM registration instructions have to be followed to the dot.

    Are you sure you don't need some sort of license string or file in the control's constructor?
    Also, is this perhaps due to your new OS being 64 bit and the control isn't?

    Other than that, I can only suggest to contact dymo sdk support.

  3. #3
    Join Date
    Mar 2009
    Location
    Ada, OH, USA
    Posts
    11
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: COM Objects on Windows 7 with 4.7.2

    Thanks schnitzel,

    Since it works on the Vista machine I don't think I need anything in the constructor. As I said I believe the COM is being used by DYMO's own software. The FAQ for the DYMO software says it is compatible with Win-7 (32 & 64).

    I have contacted DYMO support, so I guess I'll keep my fingers crossed. I really want to do this in the "new and faster" machine .

    Keith

  4. #4
    Join Date
    Oct 2009
    Posts
    364
    Thanks
    10
    Thanked 37 Times in 36 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: COM Objects on Windows 7 with 4.7.2

    have you tried using the control in a .NET app?
    Do they provide sample code?

  5. #5
    Join Date
    Mar 2009
    Location
    Ada, OH, USA
    Posts
    11
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: COM Objects on Windows 7 with 4.7.2

    Shnitzel,

    I discovered something a minute ago...

    If I take the constructor for my "DymoPrinter" (code below) out of the constructor for the form and put it in the "clicked"
    slot of my "Post" button where I print labels for each record that was changed it works. To test it out I just dropped a
    new button on the form and put these two lines in the "clicked" slot and it works just fine.
    Qt Code:
    1. dPrinter = new DymoPrinter();
    2. dPrinter->printOneLabel("000346050493");
    To copy to clipboard, switch view to plain text mode 
    That makes no sense to me at all...

    I tried stepping through the debugger and I get lost in all the "Ax" code.

    Can you see anything wrong with my "DymoPrinter" object? Is there a reason I can't instantiate COM object in the
    constructor of a form?

    BTW, no I haven't tried to use the control in .NET... Thanks for all your ideas.

    Keith
    Qt Code:
    1. dymoPrinter.h
    2. ---------------------------------
    3. #ifndef DYMOPRINTER_H
    4. #define DYMOPRINTER_H
    5.  
    6. #include <QString>
    7. #include <QSqlQuery>
    8.  
    9. #include "dymosdk.h"
    10.  
    11. class DymoPrinter
    12. {
    13. public:
    14. DymoPrinter();
    15. ~DymoPrinter();
    16. bool printOneLabel(const QString productId) const;
    17. private:
    18. QSqlQuery *rockQuery;
    19.  
    20. DYMO_DLS_SDK::ISDKDymoAddin *dymoAddIn;
    21. DYMO_DLS_SDK::ISDKDymoLabels *dymoLabels;
    22.  
    23. };
    24. #endif // DYMOPRINTER_H
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. dymoPrinter.cpp
    2. -----------------------------
    3. #include <QMessageBox>
    4. #include <QSqlDatabase>
    5.  
    6. #include "dymoPrinter.h"
    7. #include "dymosdk.h"
    8.  
    9. DymoPrinter::DymoPrinter()
    10. {
    11. dymoAddIn = new DYMO_DLS_SDK::ISDKDymoAddin();
    12. dymoAddIn->setControl("{09DAFAE2-8EB0-11D2-8E5D-00A02415E90F}");
    13. dymoAddIn->Open("d:/abe/catalog/abe_catalog/BinLabelKAWDIB-New.label");
    14.  
    15. dymoLabels = new DYMO_DLS_SDK::ISDKDymoLabels;
    16. dymoLabels->setControl("{3AAD7661-8F83-11D2-8E5D-00A02415E90F}");
    17.  
    18. if (QSqlDatabase::database("rock").isValid())
    19. rockQuery = new QSqlQuery(QSqlDatabase::database("rock"));
    20. else
    21. QMessageBox::critical( 0, "Error!", "Unable to connect to database! Are you sure you set up the correct paths?" );
    22. }
    23.  
    24. DymoPrinter::~DymoPrinter()
    25. {
    26. QSqlDatabase::database().close();
    27. delete rockQuery;
    28. }
    29.  
    30. bool DymoPrinter::printOneLabel(const QString productId) const
    31. {
    32. bool result = false;
    33. rockQuery->clear();
    34. rockQuery->exec("SELECT p.cdeProduct, " \
    35. "p.cdeV1SKU, " \
    36. "p.dscDescription, " \
    37. "uom.dscUOM, " \
    38. "p.curStnd_price, " \
    39. "p.numORD_MULT1, " \
    40. "p.numORD_MULT2, " \
    41. "p.numORD_MULT3, " \
    42. "p.cdeMSKU " \
    43. "FROM tProducts AS p INNER JOIN tUOM AS uom ON p.cdeUOM = uom.cdeUOM " \
    44. "WHERE cdeProduct = '" + productId + "';");
    45.  
    46. if (rockQuery->isActive())
    47. {
    48. if (rockQuery->next())
    49. {
    50. dymoLabels->SetField("Vendor 1 SKU", rockQuery->value(1).toString());
    51. dymoLabels->SetField("Description", rockQuery->value(2).toString());
    52. dymoLabels->SetField("UOM", rockQuery->value(3).toString());
    53. dymoLabels->SetField("Product Code", productId);
    54. dymoLabels->SetField("Standard Retail Price", "$" + rockQuery->value(4).toString());
    55. dymoLabels->SetField("OrdMult", rockQuery->value(5).toString() + "-" +
    56. rockQuery->value(6).toString() + "-" +
    57. rockQuery->value(7).toString());
    58. dymoLabels->SetField("cdeMSKU", rockQuery->value(8).toString());
    59.  
    60. if( dymoAddIn->Print(1,true) )
    61. result = true;
    62. else
    63. result = false;
    64. }
    65. }
    66. return result;
    67. }
    To copy to clipboard, switch view to plain text mode 

  6. #6
    Join Date
    Oct 2009
    Posts
    364
    Thanks
    10
    Thanked 37 Times in 36 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: COM Objects on Windows 7 with 4.7.2

    How exactly did you register this COM object on the new machine? Did you use regsvr32?

    btw: looking at the info on DYMO website regarding COM class factory...

    http://developers.dymo.com/2010/06/2...class-factory/

    they also have .NET samples - I suggest you try that first as I believe your troubles are not related to Qt at all but I have to agree that it is weird if you get it working by taking it out of the constructor.
    Last edited by schnitzel; 16th March 2011 at 00:00.

  7. #7
    Join Date
    Mar 2009
    Location
    Ada, OH, USA
    Posts
    11
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: COM Objects on Windows 7 with 4.7.2

    schnitzel

    I didn't need to use regsvr32 because there was an install program.

    The COM objects work because their software, a label designing application, works and prints using the same objects.

    It works in my application too, if I take the constructor out of the form constructor. Now that is strange....

    I saw those notes on the DYMO support site too, thanks for looking.

    Have I tried it on .NET? No I was a Clipper programmer back in the days of DOS, then moved to Delphi for years. I used .NET and C# on one project, but never really got comfortable with it.

    I like Qt a lot, but there is a learning curve with any software and the older I get the longer it takes me to get around the corner...

    Thanks, Keith

  8. #8
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: COM Objects on Windows 7 with 4.7.2

    Just a small comment:
    I don't see where you are deleting 'dymoAddIn' and 'dymoLabels'?

    I tried stepping through the debugger and I get lost in all the "Ax" code.
    try setting a break point in the constructor, and just let it run, see if the break point gets caught.
    It looks like this code is not getting called (for what ever reason) where it is.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  9. #9
    Join Date
    Oct 2009
    Posts
    364
    Thanks
    10
    Thanked 37 Times in 36 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: COM Objects on Windows 7 with 4.7.2

    Taking one of their samples to try it on .NET shouldn't be too hard. You could try VB express (for free) which is very similar to Delphi. Anyway, the point is not to push you away from Qt, but to quickly try something that will show whether or not *their* stuff works.
    If they have examples for C++, then I would try to follow that as closely as possible.
    The fact that their software works might be because they do things programmatically - such as the registering a dll.

    The link I sent had a lot of posts below the article where people were having tons of trouble with registration - that didn't look good
    Last edited by schnitzel; 16th March 2011 at 15:56. Reason: updated contents

  10. #10
    Join Date
    Mar 2009
    Location
    Ada, OH, USA
    Posts
    11
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: COM Objects on Windows 7 with 4.7.2

    schnitzel,

    I downloaded and installed VB express. Tried it on the DYMO .NET VB example included in the SDK. After it converted the project it compiled it and ran just fine. I was able to open the label, fill in the data fields and it printed my labels including the barcode. So I guess the COM objects are registered and working OK.

    I still can't think of a good reason I have to take the COM object instantiation out of the constructor. This project has a Main Form where I call each job from the menu by creating another form where I do the work and print my labels. Something in Qt must need to be done in the constructor before I can create these two COM objects.

    I hate it when I don't know what is going on...

    Keith

    high_flyer,

    I may be wrong, but I thought COM objects were reference counted and didn't need to be manually deleted. At least that is the way they always worked in Delphi and C#. When the last variable went out of scope that referenced the COM object the object was automatically deleted.

    Is that not true for Qt?

    Keith

  11. #11
    Join Date
    Oct 2009
    Posts
    364
    Thanks
    10
    Thanked 37 Times in 36 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: COM Objects on Windows 7 with 4.7.2

    Do they provide a C++ example? If so, are they also allocating the objects using new in the constructor?
    Last edited by schnitzel; 16th March 2011 at 23:31. Reason: updated contents

  12. #12
    Join Date
    Mar 2009
    Location
    Ada, OH, USA
    Posts
    11
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: COM Objects on Windows 7 with 4.7.2

    schnitzel,

    They have a Visual C++ example but they use CreateDispatch().

    I took my inspiration for my code from the Qt dumpcpp documentation I found here.

    I have tried lots of things and read lots and I think my usage is correct, it just won't work in the constructor of the form...

    Keith

  13. #13
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: COM Objects on Windows 7 with 4.7.2

    I may be wrong, but I thought COM objects were reference counted and didn't need to be manually deleted. At least that is the way they always worked in Delphi and C#. When the last variable went out of scope that referenced the COM object the object was automatically deleted.

    Is that not true for Qt?
    It has nothing to do with Qt.
    Regarding the reference count on COM objects, I think it depends on what kind of pointer container they are held.
    CComXXX<T> pointer does ref counts, but a plain pointer does not.
    I can't see the declaration of the pointer variable so I don't know for your case.

    You should run you application through a leak detection tool, which can also detect COM leakages to be sure.
    I'd recommend that you ask that on a COM oriented forum, where the people know these issues in more detail.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  14. #14
    Join Date
    Mar 2009
    Location
    Ada, OH, USA
    Posts
    11
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: COM Objects on Windows 7 with 4.7.2

    high_flier, can you recommend a good "leak detection tool" that works on Windows 7?

  15. #15
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: COM Objects on Windows 7 with 4.7.2

    You need more the just a leak detection tool, you need one that can also detect COM leaks (which (can be)/is trickier).
    For "regular" leak detection you can use the CRT leak detection tool:
    http://msdn.microsoft.com/en-us/libr...=vs.71%29.aspx
    In my company we use our own brewed leak detection (which basically intercepts ALL (external as well) allocations/frees before the kernel) since we didn't find anything that could handle our large code base.
    Again, you should ask that on forums that specialize with COM.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. QSharedMemory and C++ objects
    By MattPhillips in forum Qt Programming
    Replies: 7
    Last Post: 29th November 2010, 07:42
  2. Replies: 3
    Last Post: 9th January 2010, 15:47
  3. Replies: 7
    Last Post: 18th July 2006, 21:33
  4. How to Use Objects
    By raphaelf in forum Newbie
    Replies: 1
    Last Post: 2nd June 2006, 09:59
  5. Objects and members
    By mickey in forum General Programming
    Replies: 8
    Last Post: 1st February 2006, 00:13

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.