|
OK, seriously though: Read the guidelines and edit your post to have more information and make sure your query is specific, at least to some degree.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Hello All ,
My following Code is in cpp and use COM interfaces, My complile and build with 0 errors and 0 warnings .But at run it gives exception .In code line
hr=serviceManager->AddScanPackageService(BSTR("Offline SyncService"),BSTR("c:\\wsusscan.cab"),0,&service);
when this line exicute value of hr is E_INVALIDARG.
plz help my code is as folloing .
/////////////////////////////////////////////////////////////////////
{
IUpdateSession * session = 0;
IUpdateServiceManager * serviceManager = 0;
IUpdateService * service = 0;
IUpdateSearcher * searcher = 0;
ISearchResult * searchResult = 0;
IUpdateCollection *collection=0;
IUpdate *update=0;
HRESULT hr;
CoInitialize(NULL);
hr = CoCreateInstance(CLSID_UpdateServiceManager, 0, CLSCTX_ALL,
IID_IUpdateServiceManager,(LPVOID *)&serviceManager);
hr=CoCreateInstance(CLSID_UpdateSession,0,CLSCTX_ALL,IID_IUpdateSession,
(LPVOID *)&session);
////////////////////////////////////////////
hr=serviceManager->AddScanPackageService(BSTR("Offline Sync Service"),BSTR("c:\\wsusscan.cab"),0,&service);
//////////////////////////////////////////////////////////
hr=session->CreateUpdateSearcher(&searcher);
ServerSelection ss={ ssOthers } ;
BSTR str=0;
hr=searcher->put_ServerSelection(ss);
hr=service->get_ServiceID(&str);
hr=searcher->put_ServiceID(str);
hr=searcher->Search(L"IsInstalled=0",&searchResult );
hr=searchResult->get_Updates(&collection);
LONG count;
hr=collection->get_Count(&count);
for(LONG i=0;i<count;i++)
{
collection->get_Item(i,&update);
update->get_Title(&str);
printf("%s",(char *)str);
}
}
///////////////////////////////////////////////////////////////////////
Thanks for reading this
question/ replying answer.
|
|
|
|
|
I suspect your problem is that you can't just create BSTR s by casting normal strings to BSTR .
You need to a) use SysAllocString[^] to create the BSTR, b) convert the string from ASCII to OLE format (personally, I'd use the ATL conversion functions[^] as they're dead easy to use) and c) use SysFreeString[^] to release the string once you've finished with it.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
|
Hi,
I need to design an application accessing database system.
I need to design it like a server/mutiple client model in c++.
Can i get any article dealing with the database client/server model.
Thanks
|
|
|
|
|
krishnan.s wrote: Can i get any article dealing with the database client/server model.
Here's one[^].
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
hi all,
I had to include dll with my exe, but my problem is if i keep those dll in my install folder than my project does not work fine. To remove this i have put those dll in new folder inside my installed folder but now my project is not loading those dlls and showing warning
warning LNK4199: /DELAYLOAD:...\test_Folder\abc.dll ignored; no imports found from ...\test_Folder\abc.dll
|
|
|
|
|
You can use SetDllDirectory API to add the new folder to the DLL search path.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
where i can use this?
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
Call this when your EXE is initializing.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
I have dialog based application
PLease can u explain me with example.
thanks.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
I'm assuming you are loading the DLL using LoadLibrary .
So, before calling LoadLibrary , you must call SetDllDirectory("...\\test_folder") where the parameter is the path of the folder where you have put your DLLs.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
How are you using the DLL? Are you using the companion .lib file to load functions from the DLL or are you using LoadLibrary() and GetProcAddress() combo?
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
i m trying like this.
CString FilePath;
CString FolderPath;
TCHAR lpFileName[MAX_PATH+1];
GetModuleFileName(NULL, lpFileName, MAX_PATH);
FilePath = lpFileName;
int nLastIndex = FilePath.ReverseFind('\\');
if (nLastIndex!=-1)
{
FolderPath = FilePath.Left(nLastIndex);
} else
{
FolderPath = _T("\\");
}
CString dll_path=FolderPath;
dll_path=(dll_path+_T("\\test_folder"));
BOOL tt=SetDllDirectory(dll_path);
LoadLibrary(dll_path+"\\Rapi.dll");
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
Are you sure SetDllDirectory() and LoadLibrary() are succeeding? You check the return values and use GetLastError() to find what went wrong if one of these functions fail.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
I have finished one application which can support xp.but today i tested it on vista,it failed.
in it,thoses registry control fuctions,windows services control fuctions, some bitmap fuctions and some Gdi function fails.
Are there so many differences between those two os?
How can i deal with this?
Thanks in advance.
|
|
|
|
|
tyr2000 wrote: Are there so many differences between those two os?
Yes
tyr2000 wrote: How can i deal with this?
Maybe this[^] might help you, or some of the articles here[^].
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi
I'm converting an existing C++ MFC project in VS2008 to Unicode. The project had previously been upgraded to VS2008 from VS2005 and is running successfully as MBCS built by VS2008. I have also successfully tested a small (new) MFC Unicode app in C++.
I set the Project Properties to "Use Unicode ..." instead of MBCS and did a rebuild. UNICODE and _UNICODE are defined in the Preprocessor directives due to 'Use Unicode ...' in the project properties. When I build I get a lot of errors related to the definition of szFaceName in CHARFORMAT2. The errors are related to the definition of CHARFORMAT szFaceName as 'char' rather than WCHAR. Looking at the definition of CHARFORMAT2 in Richedit.h it has:
#ifdef UNICODE
#define CHARFORMAT2 CHARFORMAT2W
#else
#define CHARFORMAT2 CHARFORMAT2A
#endif
and the CHARFORMAT2A line is the one highlighted - effectively saying that UNICODE is NOT defined.
I am at a loss to understand why UNICODE is undefined in Richedit.h and how to fix it. I have tried defining UNICODE and _UNICODE in stdafx.h without any success.
I'd be grateful for any help with this - its driving me crackers.
Thanks in anticipation
|
|
|
|
|
Selumbei wrote: did a rebuild.
I presume that included deleting and rebuilding your pre-compiled header (.pch) file? That's where the definition of CHARFORMAT2 probably is.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi
I made sure that my project .pch file was gone and tried again without success. However there is a second project in the solution (on which my project is dependent). When I made sure the second project's .pch file was deleted it solved the issue.
So your suggestion was spot on - thanks
Now all I have to do is go through and correct all of the 'real' errors caused by previous developers not using the transmutable macros etc
Thanks again.
|
|
|
|
|
Hi all,
I need to launch a process as the user “Administrator” while running as “SYSTEM”. This is for a Windows XP Embedded application that launches another application, but the new application has to run under the “Administrator” account. It pops up an error message box when executed as “SYSTEM”. (Yes, the "Administrator" XPe component is installed.) Does anyone have any example code that does this or something very similar?
Thanks!
Peni
|
|
|
|
|
You could use the CreateProcessWithLogonW API to do this.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
That's the first thing I tried. It doesn't work. I can't recall exactly what GetLastError() returned, but I know it didn't reveal anything obvious, which is why I was hoping for some example code.
|
|
|
|
|
I am having some problems with the code I am writing.. here is the error message I'm getting:
error C2664: 'getFirst' : cannot convert parameter 1 from 'char (*)[100]' to 'char *'
And here is the code that is involved..
#include <iostream>
#include <cstdlib>
using namespace std;
bool getFirst(char *);
bool getLast(char *);
void main()
{
char firstName[100];
char lastName[100];
bool validFName;
bool validLName;
int first;
int last;
int length;
do
{
cout << "Enter your first name in lowercase letters: ";
validFName = getFirst(&firstName);
if (!validFName) cout << "Invalid entry. Try again...\n";
} while (!validFName);
cout << "\n";
do
{
cout << "Enter your last name in lowercase letters: ";
validLName = getLast(&lastName);
if (!validLName) cout << "Invalid entry. Try again...\n";
} while (!validLName);
cout << "\nYour full name is " << firstName << " " << lastName << "\n";
first = strlen(firstName);
last = strlen(lastName);
length = (first + last);
cout << "\nYour full name has " << length << " characters\n";
}
bool getFirst(char *first)
{
int iF,lenF;
char bufFirst[100];
bool validFirst = true;
cin.getline(bufFirst,100);
lenF = strlen(bufFirst);
iF = 0;
while (validFirst && iF < lenF)
{
if ((bufFirst[iF] < 'a') || (bufFirst[iF] > 'z'))
validFirst = false;
iF++;
}
return validFirst;
}
bool getLast(char *last)
{
int iL,lenL;
char bufLast[100];
bool validLast = true;
cin.getline(bufLast,100);
lenL = strlen(bufLast);
iL = 0;
while (validLast && iL < lenL)
{
if ((bufLast[iL] < 'a') || (bufLast[iL] > 'z'))
validLast = false;
iL++;
}
return validLast;
}
I cannot figure out how to get the correct output.. It displays crazy characters and says that my string length is 330 characters long..
Any help with this please??
|
|
|
|
|
Make the following changes.
validFName = getFirst(firstName);
validLName = getLast(lastName);
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|