|
OK - that's not how sizeof works - it tells you the size of a type, either via the typename ('sizeof (char)') or a compile-time static expression ('sizeof (3 * 4.0)'). The WIkipedia entry[^] is quite accurate.
I presume you know you can use n to tell you how many characters have been entered...
Razanust wrote: printf("\n\nWant to delete the array?");
dec=getche();
if (dec=='y')
{
for (i=0;i<99;i++)
ch[i]=0;
}
Can I suggest you read up how strings (specifically null terminated strings) and arrays work in C?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Razanust wrote: count=sizeof(ch[100]);
As a side note, your code (possibly) does not own the memory at location ch[100] . While that variable holds 100 chars, they are numbered 0-99.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
I am new for vc++, i am doing project on vc++2008 clr base windows form application. not able to use inpout.dll in my project please help. if possible give example. thanks
|
|
|
|
|
It will be hard without a header and lib files to import DLL to your application. There are other alternatives as well.
Anyway See <a href="http://msdn.microsoft.com/en-us/library/kh1zw7z7(VS.71).aspx">this</a>[<a href="http://msdn.microsoft.com/en-us/library/kh1zw7z7(VS.71).aspx" target="_blank" title="New Window">^</a>]
-Sarath.
"Great hopes make everything great possible" - Benjamin Franklin
|
|
|
|
|
Hi, i need to be able to create a C++ dll that can be call from JAVA or PHP can someone help me get in the right direcction to accomplish this?.
By the way can someone tell if the C++ dll that can be called from Visual Basic can be called from JAVA or PHP too?
printf("Error: No keyboard found!");
printf("Press any key to continue");
|
|
|
|
|
Calling C++ from Java[^] - or there's this option[^] - I've used JNI successfully, never used J/Invoke.
Writing a PHP extension in C++[^] seems to be the accepted way of making native code available to PHP.
I have (recently) written code (a DLL) that was available to Java, VB6 and C/C++ - I did that by making different entry-points for each language. The Java and VB entry-points are just shims that convert Java/VB data types into native ones, call into the C/C++ entry point and then convert data types back into Java/VB on the way out. It works fine.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Does anybody know the details of how linking works in VS2005 vs Qt? Namely, QtCreator. I've got an app I'm writing that uses a 3rd party library, and it works correctly when I build the project in VS2005, but not when I build in QtCreator. Everything seems to link correctly in both cases, so I'm sort of at a loss.
The error I get when I build with QtCreator is an access violation error. It seems like my code is calling into an invalid memory location. I can see that the function has an address with something like cout << SomeFunction << endl; but that doesn't tell me a whole lot besides that it's not null.
Maybe the runtime is doing something different? When I look at my exe in depends, I get some strange results. Both versions (VS and Qt) show my exe pointing at the correct dlls, but in the Qt one I don't get any entries in the "Parent Import Function List View" but I do get entries when I build with VS. I feel like that bit of information is pointing out something obvious to me, but I can't figure out what it is.
Nick
|
|
|
|
|
thebeekeeper wrote: in the Qt one I don't get any entries in the "Parent Import Function List View"
Sounds like Qt is static linking against the run-time? Are you using the same code generation/runtime library options to build Qt as you are building against Qt?
Does QtCreator use Visual C++? I had a remembrance that it used gcc?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I am accessing a DLL written in VB which has a number of methods. This DLL is designed to sign onto a sqlserver database and return various information depending on the methods called.
To date I have managed to CoCreateInstance and successfully access several of these methods.
My issue is this: Several of these methods return a record set with possibly multiple rows of data and I have no idea how to create a record set in VC++ and how access it.
This is the description of one of the methods I am trying to use:
<br />
GetCustomerList()<br />
Returns a RecordSet of all customer fields<br />
<br />
Required Properties<br />
LastName<br />
<br />
RecordSet Layout<br />
uidCustomerID<br />
strCustNo<br />
strMem_Ext<br />
strTitle<br />
strFirstName<br />
strMiddleInitial<br />
strLastName<br />
In code (I have removed pieces to make it easier to read), you can see how I have accessed some of the methods:
The method GetCustomerList requires the property of LastName to be set prior to calling and will return a RecordSet of all the Customers with the last name given.
How do I construct this record set and walk through it?
Thanks for all help
Phil
_WebRes *wr;
hresult=CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER, __uuidof(_WebRes), (LPVOID *)&wr);
bool bCon = wr->Connect("GXX", "");
bool bSUser = wr->SetUser("GXX");
BSTR bstrMess;
wr->FirstName = "Davis";
wr->LastName = "Phil";
wr->PhoneNo = "123 456 7890";
wr->Display = "Davis, Phil";
wr->Email = "phil@email.com";
bool bCust = wr->CreateCustomer(&bstrMess);
CString str(bstrMess);
MessageBox(str);
wr->LastName = _bstr_t ("Davis");
Record Set = wr->GetCustomerList();
|
|
|
|
|
Well....what defines the RecordSet structure? Is it the DLL written in VB6? Does it return ADO record-sets? That's the first thing you need to find out, anyway, so you can pull in some artefact that defines the recordset structure within your C++ program.
Once you've done that, it's relatively simple. Have a look at this post[^] I recently made showing how to use ADO connections and recordsets - they're COM objects. If you use #import to pull in the COM library's type library, it's pretty simple.
|
|
|
|
|
Hi Stuart,
Thank you for responding.
Some answers to you questions:
The DLL is written in VB6.
Yes, the record set is defined in the DLL.
I don't know what kind of record-sets it returns, ADO or otherwise.
Yes, I do use #import and a .tli and a .tlh are generated.
I have included the .tlh if that helps.
Does that help us reach the next stage?
Thanks
Phil
#pragma once
#pragma pack(push, 8)
#include <comdef.h>
struct __declspec(uuid("e897466c-75b0-459f-9512-21d42e1f5703"))
__TTExt;
struct __declspec(uuid("dc8718c4-d07f-4542-a799-f2015a0614cf"))
_WebRes;
struct WebRes;
_COM_SMARTPTR_TYPEDEF(_WebRes, __uuidof(_WebRes));
struct __declspec(uuid("dc8718c4-d07f-4542-a799-f2015a0614cf"))
_WebRes : IDispatch
{
__declspec(property(get=GetLastError))
_bstr_t LastError;
__declspec(property(get=GetDatabase,put=PutDatabase))
_bstr_t Database;
__declspec(property(get=GetServer,put=PutServer))
_bstr_t Server;
__declspec(property(put=PutResNotes))
_bstr_t ResNotes;
__declspec(property(get=GetReservationID))
_bstr_t ReservationID;
__declspec(property(get=GetConfirmationNumber))
_bstr_t ConfirmationNumber;
__declspec(property(put=PutVoucherNo))
long VoucherNo;
__declspec(property(put=PutNumberOfPlayers))
long NumberOfPlayers;
__declspec(property(put=PutSelectedSlot))
_bstr_t SelectedSlot;
__declspec(property(put=PutPlayDate))
DATE PlayDate;
__declspec(property(put=PutEndTime))
DATE EndTime;
__declspec(property(put=PutStartTime))
DATE StartTime;
__declspec(property(put=PutTee))
_bstr_t Tee;
__declspec(property(put=PutFacility))
_bstr_t Facility;
__declspec(property(get=GetCustomerID,put=PutCustomerID))
_bstr_t CustomerID;
__declspec(property(put=PutCreditCardExpDate))
_bstr_t CreditCardExpDate;
__declspec(property(put=PutCreditCard))
_bstr_t CreditCard;
__declspec(property(put=PutEmail))
_bstr_t Email;
__declspec(property(put=PutFaxNo))
_bstr_t FaxNo;
__declspec(property(put=PutPhoneExt))
_bstr_t PhoneExt;
__declspec(property(put=PutPhoneNo))
_bstr_t PhoneNo;
__declspec(property(put=PutCountry))
_bstr_t Country;
__declspec(property(put=PutState))
_bstr_t State;
__declspec(property(put=PutCompany))
_bstr_t Company;
__declspec(property(put=PutCity))
_bstr_t City;
__declspec(property(put=PutZip))
_bstr_t Zip;
__declspec(property(put=PutDisplay))
_bstr_t Display;
__declspec(property(put=PutAddress2))
_bstr_t Address2;
__declspec(property(put=PutAddress1))
_bstr_t Address1;
__declspec(property(put=PutMidInitial))
_bstr_t MidInitial;
__declspec(property(put=PutFirstName))
_bstr_t FirstName;
__declspec(property(get=GetLastName,put=PutLastName))
_bstr_t LastName;
_variant_t GetCustomerList ( );
VARIANT_BOOL CreateCustomer (
BSTR * ReturnMessage );
_variant_t GetFacilityList ( );
_variant_t GetSlotsAvailable ( );
VARIANT_BOOL CreateReservation (
BSTR * ReturnMessage );
_variant_t GetReservationsForConfirmationNo (
_bstr_t ConfirmationNo );
VARIANT_BOOL CancelReservation (
_bstr_t ReservationID,
BSTR * ReturnMessage );
_variant_t GetServers ( );
VARIANT_BOOL Connect (
_bstr_t vendor_name,
_bstr_t ini_path );
VARIANT_BOOL Connect1 (
_bstr_t Server,
_bstr_t Database );
_bstr_t GetLastName ( );
void PutLastName (
_bstr_t _arg1 );
void PutFirstName (
_bstr_t _arg1 );
void PutMidInitial (
_bstr_t _arg1 );
void PutAddress1 (
_bstr_t _arg1 );
void PutAddress2 (
_bstr_t _arg1 );
void PutDisplay (
_bstr_t _arg1 );
void PutZip (
_bstr_t _arg1 );
void PutCity (
_bstr_t _arg1 );
void PutCompany (
_bstr_t _arg1 );
void PutState (
_bstr_t _arg1 );
void PutCountry (
_bstr_t _arg1 );
void PutPhoneNo (
_bstr_t _arg1 );
void PutPhoneExt (
_bstr_t _arg1 );
void PutFaxNo (
_bstr_t _arg1 );
void PutEmail (
_bstr_t _arg1 );
void PutCreditCard (
_bstr_t _arg1 );
void PutCreditCardExpDate (
_bstr_t _arg1 );
_bstr_t GetCustomerID ( );
void PutCustomerID (
_bstr_t _arg1 );
void PutFacility (
_bstr_t _arg1 );
void PutTee (
_bstr_t _arg1 );
void PutStartTime (
DATE _arg1 );
void PutEndTime (
DATE _arg1 );
void PutPlayDate (
DATE _arg1 );
void PutSelectedSlot (
_bstr_t _arg1 );
void PutNumberOfPlayers (
long _arg1 );
void PutVoucherNo (
long _arg1 );
_bstr_t GetConfirmationNumber ( );
_bstr_t GetReservationID ( );
void PutResNotes (
_bstr_t _arg1 );
void PutServer (
_bstr_t _arg1 );
void PutDatabase (
_bstr_t _arg1 );
VARIANT_BOOL SetResellerCode (
_bstr_t InterfaceResellerCode );
VARIANT_BOOL SetUser (
_bstr_t Name );
_bstr_t GetLastError ( );
_bstr_t GetServer ( );
_bstr_t GetDatabase ( );
virtual HRESULT __stdcall raw_GetCustomerList (
VARIANT * _arg1 ) = 0;
virtual HRESULT __stdcall raw_CreateCustomer (
BSTR * ReturnMessage,
VARIANT_BOOL * _arg2 ) = 0;
virtual HRESULT __stdcall raw_GetFacilityList (
VARIANT * _arg1 ) = 0;
virtual HRESULT __stdcall raw_GetSlotsAvailable (
VARIANT * _arg1 ) = 0;
virtual HRESULT __stdcall raw_CreateReservation (
BSTR * ReturnMessage,
VARIANT_BOOL * _arg2 ) = 0;
virtual HRESULT __stdcall raw_GetReservationsForConfirmationNo (
BSTR ConfirmationNo,
VARIANT * _arg2 ) = 0;
virtual HRESULT __stdcall raw_CancelReservation (
BSTR ReservationID,
BSTR * ReturnMessage,
VARIANT_BOOL * _arg3 ) = 0;
virtual HRESULT __stdcall raw_GetServers (
VARIANT * _arg1 ) = 0;
virtual HRESULT __stdcall raw_Connect (
BSTR vendor_name,
BSTR ini_path,
VARIANT_BOOL * _arg3 ) = 0;
virtual HRESULT __stdcall raw_Connect1 (
BSTR Server,
BSTR Database,
VARIANT_BOOL * _arg3 ) = 0;
virtual HRESULT __stdcall get_LastName (
BSTR * _arg1 ) = 0;
virtual HRESULT __stdcall put_LastName (
BSTR _arg1 ) = 0;
virtual HRESULT __stdcall put_FirstName (
BSTR _arg1 ) = 0;
virtual HRESULT __stdcall put_MidInitial (
BSTR _arg1 ) = 0;
virtual HRESULT __stdcall put_Address1 (
BSTR _arg1 ) = 0;
virtual HRESULT __stdcall put_Address2 (
BSTR _arg1 ) = 0;
virtual HRESULT __stdcall put_Display (
BSTR _arg1 ) = 0;
virtual HRESULT __stdcall put_Zip (
BSTR _arg1 ) = 0;
virtual HRESULT __stdcall put_City (
BSTR _arg1 ) = 0;
virtual HRESULT __stdcall put_Company (
BSTR _arg1 ) = 0;
virtual HRESULT __stdcall put_State (
BSTR _arg1 ) = 0;
virtual HRESULT __stdcall put_Country (
BSTR _arg1 ) = 0;
virtual HRESULT __stdcall put_PhoneNo (
BSTR _arg1 ) = 0;
virtual HRESULT __stdcall put_PhoneExt (
BSTR _arg1 ) = 0;
virtual HRESULT __stdcall put_FaxNo (
BSTR _arg1 ) = 0;
virtual HRESULT __stdcall put_Email (
BSTR _arg1 ) = 0;
virtual HRESULT __stdcall put_CreditCard (
BSTR _arg1 ) = 0;
virtual HRESULT __stdcall put_CreditCardExpDate (
BSTR _arg1 ) = 0;
virtual HRESULT __stdcall get_CustomerID (
BSTR * _arg1 ) = 0;
virtual HRESULT __stdcall put_CustomerID (
BSTR _arg1 ) = 0;
virtual HRESULT __stdcall put_Facility (
BSTR _arg1 ) = 0;
virtual HRESULT __stdcall put_Tee (
BSTR _arg1 ) = 0;
virtual HRESULT __stdcall put_StartTime (
DATE _arg1 ) = 0;
virtual HRESULT __stdcall put_EndTime (
DATE _arg1 ) = 0;
virtual HRESULT __stdcall put_PlayDate (
DATE _arg1 ) = 0;
virtual HRESULT __stdcall put_SelectedSlot (
BSTR _arg1 ) = 0;
virtual HRESULT __stdcall put_NumberOfPlayers (
long _arg1 ) = 0;
virtual HRESULT __stdcall put_VoucherNo (
long _arg1 ) = 0;
virtual HRESULT __stdcall get_ConfirmationNumber (
BSTR * _arg1 ) = 0;
virtual HRESULT __stdcall get_ReservationID (
BSTR * _arg1 ) = 0;
virtual HRESULT __stdcall put_ResNotes (
BSTR _arg1 ) = 0;
virtual HRESULT __stdcall put_Server (
BSTR _arg1 ) = 0;
virtual HRESULT __stdcall put_Database (
BSTR _arg1 ) = 0;
virtual HRESULT __stdcall raw_SetResellerCode (
BSTR InterfaceResellerCode,
VARIANT_BOOL * _arg2 ) = 0;
virtual HRESULT __stdcall raw_SetUser (
BSTR Name,
VARIANT_BOOL * _arg2 ) = 0;
virtual HRESULT __stdcall get_LastError (
BSTR * _arg1 ) = 0;
virtual HRESULT __stdcall get_Server (
BSTR * _arg1 ) = 0;
virtual HRESULT __stdcall get_Database (
BSTR * _arg1 ) = 0;
};
struct __declspec(uuid("d00de9f1-98eb-4cd9-8685-0ea4f283971f"))
WebRes;
#include "c:\documents and settings\phild\my documents\visual studio code\vbdll\vcclient\debug\ttext.tli"
#pragma pack(pop)
modified on Tuesday, June 30, 2009 12:20 PM
|
|
|
|
|
Heh - it's in a variant. That makes things a little more tricky
I still reckon it could well be an ADO recordset - ADO plays nicely with VB and SQL Server. So, #import the ADO libraries (as shown in the post I linked to earlier - look for the 'Debug Assertion' thread) and try assigning the result of GetCustomerList to a variable of type ADODB::_RecordsetPtr - the _com_ptr_t class has a constructor that takes a variant and attempts to extract an IUnknown pointer and QueryInterface for the interface you first thought of.
[edit]If your recordset pointer isn't an ADO recordset pointer, an exception'll get thrown, so you'll soon know that it's failed![/edit]
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Stuart,
the link "this post", goes to this thread.
Thanks
Phil
|
|
|
|
|
You should find (when you click on that link), if you look further down the page, a thread titled 'Debug Assertion', with a message exapnded - I did, anyway. Look for that thread - my last post in it has the example I was talking about.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi Stuart,
ok, this is as far as I've gotten so far...
wr->LastName = _bstr_t ("Davis");
using namespace ADODB;
_RecordsetPtr ptrRS;
hresult = ptrRS.CreateInstance(__uuidof(Recordset));
if(FAILED(hresult)) {
MessageBox("ptrRS.CreateInstance Failed *****");
}
ptrRS = wr->;GetCustomerList();
ptrRS->MoveFirst();
_variant_t vtRows = ptrRS->GetRows(ADODB::adGetRowsRest);
No crashes to this point...
So how do I get the data out of the variant?
Thanks
phil
|
|
|
|
|
The variant should contain a SAFEARRAY[^]. There are useful classes wrapping SAFEARRAYs - see here[^] and here[^].
The other way would be to use the methods of record set (other than GetRows - that's not the best way, to be honest, but the easiest for the specific example I was showing).
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
how to create an xml file in vc++6.0 and writing data to it.please let me know
kir_MFC
|
|
|
|
|
|
As Naveen suggested. There are other XML parsers available as well. Also you could look at the XML DOM tutorial on www.w3schools.com. There are other sites with DOM info as well
[modified]
Why? What was wrong with the replies from previous post?
|
|
|
|
|
kir_MFC wrote: please let me know
See here.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
hi there,
I have one modal dialog box, created by DialogBox() api. This dialog box has some buttons and other control.
1. Here I want to capture Ctrl+PgUP and Ctrl+PgDn key strokes. and based on them i want to move to another button
2. Once i am on another button i want to forward this action to one of the case in WM_COMMAND.
could you be able to take some time and answer my questions please?
Thanks in advance
Warm Regards
Ajay
London
|
|
|
|
|
reply2am wrote: could you be able to take some time and answer my questions please?
Try this.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
in my application i have to read edit box controls data into xml file .please let me know how to do it
kir_MFC
|
|
|
|
|
|
thank u very much
kir_MFC
|
|
|
|