|
How can I implement this?
So far I have:
using namespace std;
typedef std::vector<std::vector<unsigned char=""> > USBVECTOR;
// Declare a dynamically allocated vector of QuickUSB Devices
USBVECTOR aDeviceChannel;
// Iterator is used to loop through the vector.
USBVECTOR::iterator iDeviceIterator;
So how can I make aDeviceChannel into a typical 2d array? Then how can I write data to each index in the array (like array[i][j] = blah)
Thanks
|
|
|
|
|
Try this technique...
<pre>// Array of arrays of ints
typedef vector<vector<int> > CMultiIntArray;
void TraceDynamicArray(const unsigned int rows, const unsigned int columns)
{
CMultiIntArray aTest;
// Allocate number of rows
aTest.resize( rows );
// For each row
for (int row = 0; row < aTest.size(); row++)
{
// Allocate number of columns
aTest[row].resize( columns );
// For each column
for (int column = 0; column < aTest[row].size(); column++)
{
// Assign a value
aTest [row] [column] = 10 * row + column;
// Trace it
cout << aTest [row] [column] << "\t";
}
cout << "\n";
}
}
// Example usage: Standard C++ Library version
int main(int argc, char* argv[])
{
TraceDynamicArray(3,5);
return 0;
}</pre>
Kevin
|
|
|
|
|
How can i terminate/release file handles acquired by one process from some other process?
Thanks in Anticipation
|
|
|
|
|
Is there is any way to attach a toolbar to an ActiveX control ?
|
|
|
|
|
Hello Anand,
I think this is not possible.
You can do it if your activeX control gives any method to attach a toolbar to this control window.
One more thing. I think you can develop your own control using the existing one(writing wrapper on the existing one) so that u can add the toolbar at the time of development.
Any way, I am not quite sure.
I hope these info will help you,
Jahfer
|
|
|
|
|
|
i added the toolbar .
but now i display a dialog box when double clicking on the activex control.
it work fine. but when i touch the title bar to move the dialog box it hangs.
please help me.
|
|
|
|
|
try a modeless dialog with no title bar (Why you move the dialog in your ActiveX? It is a place holder for other controls.)
http://blog.joycode.com/jiangsheng
http://blog.csdn.net/jiangsheng
Command what is yours
Conquer what is not
---Kane
|
|
|
|
|
can we create an icon for dll file - similar to icon for exe file?
if yes, how?
thx
includeh10
|
|
|
|
|
You can put icons into the resources of DLL files.
However, there is typically only a single icon associaed with the DLL file extension at any given time, meaning that ALL dll files get the same icon. Is that what you wanted to change? Or did you think your DLL would get its own icon? If you want your own dll to get a speical icon, you might try writing an icon handler shell extension. I am not sure what yu are trying to acomplish, and it might not be really worth your troubles, your time might be better spent elsewhere, than trying to cirumvent the Windows UI.
|
|
|
|
|
I have a problem.
1. I wrote a simple .NET(C#) service that expose: void test(string fsrpath)
2. Wrote a win32 dll that invoke that web method. Use SoapClient (MSSOAP3.0) to invoke that web method but it doesn't work. I always got "Client:Incorrect number of parameters supplied for SOAP request HRESULT=0x80070057: The parameter is incorrect." I give the code as (**below**)
3. Wrote a win32 dll that invoke that web method. Use Http Request (MSSOAP3.0) to invoke that web method but it doesn't work. The server can't see the parammeter fsrpath. althought Client can call to that web method. I give the code as (***below***)
Does any experts have another Idea to call to that web method.
I really would like to have the example code to handle complex types such as structure in C++
Please please help me..... help me
Thanks a lot all experts.
(**below**)
#import "C:\Program Files\Common Files\MSSoap\Binaries\mssoap30.dll" \
exclude("IStream", "IErrorInfo", "ISequentialStream", "_LARGE_INTEGER", \
"_ULARGE_INTEGER", "tagSTATSTG", "_FILETIME")
using namespace MSSOAPLib30;
#import "c:\winnt\system32\msxml4.dll" named_guids
using namespace MSXML2;
void test()
{
CoInitialize(NULL);
HRESULT hr;
ISoapClientPtr m_pSoapClient;
hr = m_pSoapClient.CreateInstance(__uuidof(SoapClient30));
try
{
hr = m_pSoapClient->MSSoapInit2(
_variant_t(_T("http://localhost:8080/ICM/CMVersioning/CMVersioningService.asmx?WSDL")),
_variant_t(_T("")),
_T("CMVersioningService"),
_T("CMVersioningServiceSoap"),
_T("http://www.starviewtechnology.com/cm/services/CMVersioningService"));
}
catch (_com_error ce)
{
CString szLogMsg;
szLogMsg.Format("%s", (char *)ce.Description());
}
DISPID dispid;
DISPPARAMS dispparams;
VARIANTARG params[1];
VARIANT result;
EXCEPINFO ExceptInfo;
OLECHAR *pMethodName = L"test";
// Get dispatch ID corrisponding to method name.
hr = m_pSoapClient->GetIDsOfNames(IID_NULL,
&pMethodName,
1,
LOCALE_SYSTEM_DEFAULT,
&dispid);
if(FAILED(hr))
{
return NULL;
}
VariantInit(¶ms[0]);
params[0].vt = VT_BSTR;
params[0].bstrVal = L"ZZZZZZZZZZZ";
// Initialize DISPPARAMS structure.
dispparams.cArgs = 1;
dispparams.cNamedArgs = 0;
dispparams.rgdispidNamedArgs = NULL;
dispparams.rgvarg = params;
// Prepare result variant.
VariantInit(&result);
// Invoke the specified method.
hr = m_pSoapClient->Invoke(dispid,
IID_NULL,
LOCALE_SYSTEM_DEFAULT,
DISPATCH_METHOD,
&dispparams,
&result,
&ExceptInfo,
NULL);
if(FAILED(hr))
{
return NULL; // always got error
}
}
(***below***)
#import "C:\Program Files\Common Files\MSSoap\Binaries\mssoap30.dll" \
exclude("IStream", "IErrorInfo", "ISequentialStream", "_LARGE_INTEGER", \
"_ULARGE_INTEGER", "tagSTATSTG", "_FILETIME")
using namespace MSSOAPLib30;
void test()
{
CoInitialize(NULL);
ISoapSerializerPtr Serializer = NULL;
ISoapReaderPtr Reader = NULL;
ISoapConnectorPtr Connector = NULL;
try
{
// Connect to the service.
HRESULT hr = Connector.CreateInstance(__uuidof(HttpConnector30));
if (FAILED(hr))
{
goto exit_func;
}
else
{
// Set end point information to connector
Connector->Property["EndPointURL"] = _T("http://localhost:8080/ICM/CMVersioning/CMVersioningService.asmx");
Connector->Property["SoapAction"] = _T("http://tempuri.org/CheckIn");
Connector->Connect();
// Begin the message.
Connector->BeginMessage();
// Create the SoapSerializer object.
hr = Serializer.CreateInstance(__uuidof(SoapSerializer30));
if (FAILED(hr))
{
goto exit_func;
}
else
{
// Connect the serializer object to the input stream of the connector object.
Serializer->Init(_variant_t((IUnknown*)Connector->InputStream));
Serializer->StartEnvelope("soap","NONE", "utf-8");
Serializer->StartBody(_T("NONE"));
Serializer->StartElement(_T("CheckIn"),
_T(""),
_T("NONE"),
_T(""));
_bstr_t bstr(
_T("<test xmlns="\"http://tempuri.org/\""> ")
_T("<fsrpath>string ")
_T(""));
Serializer->WriteXml(bstr);
Serializer->EndElement();
Serializer->EndBody();
Serializer->EndEnvelope();
try
{
Connector->EndMessage();
}
catch (_com_error ce)
{
goto exit_func;
}
catch (...)
{
goto exit_func;
}
// Read the response.
hr = Reader.CreateInstance(__uuidof(SoapReader30));
if (FAILED(hr))
{
goto exit_func;
}
else
{
// Connect the reader to the output stream of the connector object.
if (Connector->OutputStream!=NULL)
{
try
{
// Maybe there is no respond
// so that this line will have exception
BOOL blRes = Reader->Load(_variant_t((IUnknown*)Connector->OutputStream), "CheckIn");
IXMLDOMDocument *spResponseXMLDOM = NULL;
spResponseXMLDOM = Reader->Dom;
BSTR bstr;
spResponseXMLDOM->get_xml(&bstr);
AfxMessageBox(CString(bstr));
}
catch (...)
{
}
}
}
}
}
}
catch (...)
{
}
}
|
|
|
|
|
I am having difficulty reading from a binary file. For some reason, the program is not reading from it properly.
My code is short and so I will show all of it
#include <iostream.h><br />
#include <fstream.h><br />
<br />
struct Info<br />
{<br />
int ID;<br />
float GPA, FinAid;<br />
<br />
char state[3];<br />
char gender[2];<br />
char Fname[15];<br />
char Lname[15];<br />
char status[15];<br />
};<br />
<br />
void main(void)<br />
{<br />
fstream people;<br />
Info person;<br />
char again;<br />
people.open("C:\\Student.bin", ios::in | ios::binary);<br />
if(!people)<br />
{<br />
cout << "Error Opening File! Program Aborting!!\n\n";<br />
return;<br />
}<br />
people.read((char *)&person, sizeof(person));<br />
while (!people.eof())<br />
{<br />
cout << "ID: ";<br />
cout << person.ID << endl; <br />
cout << "GPA: ";<br />
cout << person.GPA << endl;<br />
cout << "Financial Aid: ";<br />
cout << person.FinAid << endl;<br />
<br />
cout <<"State: ";<br />
cout << person.state << endl;<br />
cout << "Gender: ";<br />
cout << person.gender << endl;<br />
cout << "First Name: ";<br />
cout << person.Fname << endl;<br />
cout << "Last Name: ";<br />
cout << person.Lname << endl;<br />
cout << "Status: ";<br />
cout << person.status << endl;<br />
cin.get(again);<br />
people.read((char *)&person, sizeof(person));<br />
}<br />
people.close();<br />
}<br />
When I debug it, it will not gather the correct data and also show weird characters. I get the feeling that it is trying to read the file in text file mode still. Not sure why as I've checked examples through the internet and I have pretty much the same code.
|
|
|
|
|
Where's the code that writes to the file?
Regards
Senthil
My Blog
|
|
|
|
|
Sorry if I wasn't clear.
The program does not write to the file but rather reads in the information then outputs it on the screen for the user to see. It does not write to the binary file.
|
|
|
|
|
You can read only information that was previously written. Your program (or some other program) must have written the exact same structure instances to a file. Only then will your code work.
Regards
Senthil
My Blog
|
|
|
|
|
The problem is probably due to the member structure alignement: the data in the file have probably been saved with another program which specified a member struct alignement of 1.
Member struct alignement means on which byte boundaries are stored all the fields of your structure in memory. Thus, specifying a member struct of 8 (the default), every fields of the structure start on a 8 byte boundary. When you try to read directly data from a file and 'copy' it in memory, if the structure was not saved with the same member struct alignement, this will results in misalignement of your fields (and so, you won't be able to read anything).
To avoid the problem, try to set the alignement of your structure to 1:
<br />
#pragma pack(1)<br />
<br />
struct Info<br />
{<br />
int ID;<br />
float GPA, FinAid;<br />
<br />
char state[3];<br />
char gender[2];<br />
char Fname[15];<br />
char Lname[15];<br />
char status[15];<br />
};<br />
<br />
#pragma pack // reset to default
|
|
|
|
|
Hi everybody,
I have a slight problem with this segment of code, which gives me error. I want to read a process memory and save it to a file but then im having a syntax problems. Pliz help
ReadProcessMemory(HANDLE, /*hProcess*/
LPCVOID, /*lpBaseAddress*/
LPVOID, /*lpBuffer*/
SIZE_T, /*nSize*/
SIZE_T* /*lpNumberOfBytesRead*/
);
|
|
|
|
|
Can u post your code here. I mean the code which is giving error
"Aerodynamically, the bumble bee shouldn't be able to fly, but the
bumble bee doesn't know it so it goes on flying anyway." - Mary Kay Ash
My Articles
|
|
|
|
|
There is the code below
#include <windows.h>
#include <stdio.h>
//Program that creates a process
//This program assumes that numbers.exe is in the PATH!
int main(int argc, char **argv)
{
PROCESS_INFORMATION pi; /* filled in by CreateProcess */
STARTUPINFO si; /* startup info for the new process*/
/* print out our process ID */
printf("Process %d reporting for creation\n",GetCurrentProcessId());
/* Get startup info for current process, we will use this
as the startup info for the new process as well... */
GetStartupInfo(&si);
/* Call CreateProcess, telling it to run an exe file
with lots of defaults... (the NULLs mean "use defaults")
"\"F:\debug\numbers.exe\" -L",
*/
CreateProcess(NULL, /* lpApplicationName */
"numbers.exe", /* lpCommandLine assumes to use curent process directory*/
NULL, /* lpsaProcess */
NULL, /* lpsaThread */
FALSE, /* bInheritHandles */
CREATE_NEW_CONSOLE, /* dwCreationFlags */
NULL, /* lpEnvironment */
NULL, /* lpCurDir */
&si, /* lpStartupInfo */
&pi /* lpProcInfo */
);
/* print out the new process iD and quit
(does not wait for new process to exit!)
*/
printf("New Process ID: %d ",pi.dwProcessId);
printf("has started \n");
ReadProcessMemory(HANDLE, /*hProcess*/
LPCVOID, /*lpBaseAddress*/
LPVOID, /*lpBuffer*/
SIZE_T, /*nSize number of bytes to ead from process*/
SIZE_T* /*lpNumberOfBytesRead number of bytes transfered*/
);
printf("Process memory has read \n");
/*
WriteProcessMemory(
HANDLE, /* hProcess,*/
// LPVOID, /* lpBaseAddress*/
//LPCVOID, /* lpBuffer,*/
//SIZE_T, /* nSize,*/
//SIZE_T* /*lpNumberOfBytesWritten*/
//);
DWORD SuspendThread(HANDLE /*hThread*/
// );
// GetLastError(void);
return(0);
}
|
|
|
|
|
Hi everyone,
Im new to the site(as well as MFC and C++), so I hope this question is being put in the right spot.
Basically I want to know how to add a Dialog bar to a dialog based application. Is it possible?
Ive found various examples on the web but they seem to be aimed at SDI and MDI style apps.
When I try and use what they say, no dialog bar is created (when I use Create() ) and if I try EnableDocking the app compiles but crashes when it tries to execute the code with an error in dockcont.cpp line 45. Furthermore it doesnt even recognise the call "DockControlBar". I have included "#include <Afxext.h>".
Ive been banging my head against this for over a day now.
Can anyone tell me if its possible to have a dialogbar in a dialog based application, and if so point me towards a tutorial?
Thanks,
Will.
Can anyone help?
|
|
|
|
|
BTW I am using VisC6. I dont even really need toolbars, all I really want is some modeless windows I can dock onto a main window... (basically I want an expandable interface as my app has lots of controls that I want to be dynamically visible...
Cheers
Will.
|
|
|
|
|
It is possible to add menu, toolbar status bar to a dialog; the question is it feasible.
Dialog simply was not designed to route commands nor was it designed to dock bars. CControlBar is looking for a docking site and expect frame window to be one.
I am not sure if amount of code that has to be add to a dialog to implement all the changes needed is justifiable.
Consider SDI application and CFormView as a base class for view be it with or without document/view architecture support.
Such an application with main frame that is not resizable will resemble dialog providing with all functionality and support for command routing, toolbar docking and more for free, without adding any additional code to support it.
JohnCz
|
|
|
|
|
Hello Will,
Here is atutorial[^] about how to add a toolbar to a dialog.
I think that the procedure may be the same for DialogBar.
But you should know that this thing doesn't make it dockable ( as I remember). So this might not be the solution to your problem.
|
|
|
|
|
Hello everybody
I am trying to inject a dll in a certain process but everytime I do It the injected process does not respond.
I have debuged the program step by step and I don't get any invalid handles or leaks of memoriy.
The funny thing is that when I enumerate all the modules from a process and I create a remote thread to free a library from a process it works just fine.
Also when I try to inject a certain library in my own process it works just fine
Here Is the code I use:
<br />
int WINAPI InjectLib(DWORD process_id, char *lib_name)<br />
{<br />
<br />
PTHREAD_START_ROUTINE pfnRemote =(PTHREAD_START_ROUTINE)<br />
GetProcAddress(GetModuleHandle("Kernel32"), "LoadLibraryA");<br />
if(pfnRemote ==NULL)<br />
return -1;<br />
HANDLE hProcess =OpenProcess(PROCESS_ALL_ACCESS, FALSE, process_id);<br />
if(hProcess ==NULL)<br />
{<br />
<br />
return -1;<br />
}<br />
<br />
int mem_size =strlen(lib_name)+1;<br />
void *premote_mem =VirtualAllocEx(hProcess, NULL, mem_size, MEM_COMMIT, PAGE_READWRITE);<br />
if(premote_mem ==NULL)<br />
{<br />
CloseHandle(hProcess);<br />
return -1;<br />
}<br />
<br />
int ret =WriteProcessMemory(hProcess, premote_mem, lib_name, mem_size,NULL);<br />
if(ret ==STATUS_ACCESS_VIOLATION || ret ==false)<br />
{<br />
<br />
VirtualFreeEx(hProcess, premote_mem, 0, MEM_RELEASE);<br />
CloseHandle(hProcess); <br />
return -1;<br />
}<br />
<br />
<br />
HANDLE hThread =CreateRemoteThread(hProcess, NULL, 0, <br />
pfnRemote, premote_mem, 0, NULL);<br />
<br />
if(hThread ==NULL)<br />
{<br />
VirtualFreeEx(hProcess, premote_mem, 0, MEM_RELEASE);<br />
CloseHandle(hProcess);<br />
return -1;<br />
}<br />
<br />
<br />
WaitForSingleObject(hThread, INFINITE);<br />
<br />
VirtualFreeEx(hProcess, premote_mem, 0, MEM_RELEASE);<br />
CloseHandle(hProcess);<br />
CloseHandle(hThread);<br />
<br />
return 0;<br />
}
Can someone tell me what am I missing.
gabby
|
|
|
|
|
im going to burn my program to a cd, and i need it to run as soon as the cd is in the drive.
|
|
|
|
|