|
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I've really no idea as to what you are talking about but if I were to hazard a guess, are you wanting to create a different file each iteration of the loop?
"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 everyone, I got a question about disabling context menu of the web browser and I've searched MSDN, this forum and goole. But seems most of the are either not Dialog Based (most of them use CHtmlView) or not quite same as what I see in my project.
I am using Visual Studio 2005 and Here is my steps of creating the application:
I use MFC application and choose dialog based. Then, in the dialog editor, I add Microsoft Web Browser into the toolbox, and then drag it into the dialog. After that, I right click on that control and choose Add Variable and leave everything default and give it a variable name "myBrowser". Then it automatically creates a explorer.h and explorer.cpp. The explorer.h contains a class declearation of "class CExplorer1 : public CWnd". Then I get stuck at this point. I've tried to declear a message map in explorer.h and find ON_WM_CONTEXTMENU() but seems doesn't work.
From the search of the internet, it seems that I need to implemente IDocHostUIHandler and there I can overload ShowContextMenu() and return S_OK to disable it. But with most of the information I got, seems most of them are for CHtmlView but not CWnd. So, I'd like to ask what I should do to disable the context menu of a Dialog Based Web Browser which inherit CWnd (or my approach is wrong?) and with Visual Studio 2005? (coz I see most of the information are VC++6 and I can't find the same thing in VS2005).
I am new to MFC and these kinds of browser things so my question maybe a stuipd question....
Thanks for any help.
modified on Thursday, July 2, 2009 7:32 PM
|
|
|
|
|
|
thanks, I've found that article too, but I am working with C++...
|
|
|
|
|
Well, a quick Google shows this article[^] - you'll need to fix up the HTML formatting a bit, but it loks like all the code's there.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
how can i convert below code from vbscript to c++
strComputer = "."
Set colGroups = GetObject("WinNT://" & strComputer & "")
colGroups.Filter = Array("group")
For Each objGroup In colGroups
'Wscript.Echo objGroup.Name
if objGroup.Name ="Administrators" then
For Each objUser in objGroup.Members
Wscript.Echo vbTab & objUser.Name
Next
end if
Next
“You will never be a leader unless you first learn to follow and be led.”
–Tiorio
"Coming together is a beginning, staying together is progress, and working together is success." Henry Ford
|
|
|
|
|
Mogaambo wrote: how can i convert
What do you mean? Are you looking for a tool that will do it or what? Most of the people here know how to write C++ code and that is why they might be able to do the work. What can you do and what do you want from the people in this forum?
|
|
|
|
|
How can i enumerate users
// adminGroup.cpp : Defines the entry point for the console application.
//
#pragma comment(lib,"Netapi32.lib")
#include <windows.h>
#include < LMCONS.H>
#include <lm.h>
#include <lmaccess.h>
#define MAX_PREFERRED_LENGTH ((DWORD) -1)
#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
NET_API_STATUS ret = 0 ;
LPCWSTR servername = NULL;
LPCWSTR groupname = L"Administrators";
LPBYTE buffer = NULL;
DWORD entriesRead;
DWORD totalEntries;
DWORD resumeHandle =0;
typedef struct _LOCALGROUP_MEMBERS_INFO_1 {
PSID lgrmi1_sid;
SID_NAME_USE lgrmi1_sidusage;
LPWSTR lgrmi1_name;
}LOCALGROUP_MEMBERS_INFO_1, *PLOCALGROUP_MEMBERS_INFO_1, *LPLOCALGROUP_MEMBERS_INFO_1;
//function call
ret=NetLocalGroupGetMembers (NULL, groupname, 1, &buffer, MAX_PREFERRED_LENGTH, &entriesRead, &totalEntries, &resumeHandle);
for(int i = 0;i< entriesRead ;i++)
{
//here i wan to enumerate but how
}
int n=0;
return 0;
}
“You will never be a leader unless you first learn to follow and be led.”
–Tiorio
"Coming together is a beginning, staying together is progress, and working together is success." Henry Ford
|
|
|
|
|
I've never used that API but based on the documentation my first guess would be that if entriesRead is more than 1 the buffer will contain an array of them so you would iterate through the array, something like:
PLOCALGROUP_MEMBERS_INFO_1 pData = (PLOCALGROUP_MEMBERS_INFO_1)buffer;
for(int i = 0;i< entriesRead ;i++, pData++)
{
pData->lgrmi1_sid;
}
Of course I would have to verify that by debugging since I've never worked with it.
BTW: Don't forget to free the buffer
"bufptr [out]
Pointer to the address that receives the return information structure. The format of this data depends on the value of the level parameter. This buffer is allocated by the system and must be freed using the NetApiBufferFree function. Note that you must free the buffer even if the function fails with ERROR_MORE_DATA."
|
|
|
|
|
Here what i get after a lot of googling or say binging
LPLOCALGROUP_MEMBERS_INFO_1 pstMembersInfo = 0;
DWORD entriesread = 0;
DWORD totalentries = 0;
if( 0 != NetLocalGroupGetMembers( NULL, _T("Administrators"), 1, (LPBYTE*)
&pstMembersInfo,MAX_PREFERRED_LENGTH,
&entriesread, &totalentries, 0 ))
{
AfxMessageBox( _T("NetLocalGroupGetMembers failed !"));
return ;
}
for( DWORD dwIdx =0; dwIdx < entriesread; dwIdx ++ )
{
AfxMessageBox( pstMembersInfo[dwIdx].lgrmi1_name );
}
NetApiBufferFree( pstMembersInfo );
“You will never be a leader unless you first learn to follow and be led.”
–Tiorio
"Coming together is a beginning, staying together is progress, and working together is success." Henry Ford
|
|
|
|
|
That's pretty much equivalent to Mike's - it's just the casting's done slightly differently.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
cout<< pData->lgrmi1_name <<std::endl; //how can i get name here as it is printing only address like below
printf("%S\n", pData->lgrmi1_name );;
“You will never be a leader unless you first learn to follow and be led.”
–Tiorio
"Coming together is a beginning, staying together is progress, and working together is success." Henry Ford
|
|
|
|
|
Mogaambo wrote: cout<< pData->lgrmi1_name <<std::endl; how="" can="" i="" get="" name="" here="" as="" it="" is="" printing="" only="" address="" like="" below<="" blockquote="">
Have you tried wcout ?
"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
|
|
|
|
|
Thanks to all for helping me a lot, actually i am c# programmer and i dont know all these jargons.
Thks alot
“You will never be a leader unless you first learn to follow and be led.”
–Tiorio
"Coming together is a beginning, staying together is progress, and working together is success." Henry Ford
|
|
|
|
|
// adminGroup.cpp : Defines the entry point for the console application.
//
#pragma comment(lib,"Netapi32.lib")
#include <stdio.h>
#include <windows.h>
#include < LMCONS.H>
#include <Lm.h>
#include <Lmaccess.h>
#define MAX_PREFERRED_LENGTH ((DWORD) -1)
#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
// NET_API_STATUS ret = 0 ;
//LPCWSTR servername = NULL;
//LPCWSTR groupname = L"Administrators";
LPBYTE buffer = NULL;
//DWORD entriesRead;
//DWORD totalEntries;
//DWORD resumeHandle =0;
//
//typedef struct _LOCALGROUP_MEMBERS_INFO_1 {
// PSID lgrmi1_sid;
// SID_NAME_USE lgrmi1_sidusage;
// LPWSTR lgrmi1_name;
//}LOCALGROUP_MEMBERS_INFO_1, *PLOCALGROUP_MEMBERS_INFO_1, *LPLOCALGROUP_MEMBERS_INFO_1;
////function call
//ret=NetLocalGroupGetMembers (NULL, groupname, 1, &buffer, MAX_PREFERRED_LENGTH, &entriesRead, &totalEntries, &resumeHandle);
//LPLOCALGROUP_MEMBERS_INFO_1 pstMembersInfo = 0;
//for( DWORD dwIdx =0; dwIdx < entriesRead; dwIdx ++ )
//{
// //std::cout<< pstMembersInfo[dwIdx].lgrmi1_name ;
//}
//int n=0;
LPLOCALGROUP_MEMBERS_INFO_1 pstMembersInfo = 0;
DWORD entriesread = 0;
DWORD totalentries = 0;
LPWSTR FromFile2=NULL;
if( 0 != NetLocalGroupGetMembers( NULL, _T("Administrators"), 1, (LPBYTE*)
&buffer,MAX_PREFERRED_LENGTH,
&entriesread, &totalentries, 0 ))
{
//AfxMessageBox( _T("NetLocalGroupGetMembers failed !"));
// return ;
}
PLOCALGROUP_MEMBERS_INFO_1 pData = (PLOCALGROUP_MEMBERS_INFO_1)buffer;
for( DWORD dwIdx =0; dwIdx < entriesread; dwIdx ++ , pData++)
{
//printf("%S\n", pstMembersInfo[dwIdx].lgrmi1_name );;
//lstrcpy(FromFile2,pstMembersInfo[dwIdx].lgrmi1_name);
//std::cout<<(std::string) pstMembersInfo[dwIdx].lgrmi1_name <<std::endl;
wcout<< pData->lgrmi1_name <<std::endl;
//printf("%S\n", pData->lgrmi1_name );;
}
NetApiBufferFree( buffer );
return 0;
}
“You will never be a leader unless you first learn to follow and be led.”
–Tiorio
"Coming together is a beginning, staying together is progress, and working together is success." Henry Ford
|
|
|
|
|
Essentially, I'm reading some names from a text file, and I need to allocate the array at runtime. I'm missing something regarding the allocation of each individual name. After I copy the first name into the array slot, it fills up every spot in the array with the first value. After the loop finishes I have an array with [count] copies of the initial value I read from the file.
I'm using the StreamReader class in other places in the program so that's why I'm marshaling the string to a char*. Maybe not the ideal solution, but I believe the problem is separate from that.
char **temp=NULL;
my_malloc((void**)&temp,count*sizeof(char*));
StreamReader^ din = File::OpenText(fileName);
String^ str;
while ((str = din->ReadLine()) != nullptr)
{
char* x = (char*)System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi(str).ToPointer();
my_malloc((void**)&temp[count],strlen(x)*sizeof(char)+1);
strcpy(temp[count],x);
System::Runtime::InteropServices::Marshal::FreeHGlobal((IntPtr)x);
count++;
}
The my_malloc function is just a wrapper around free() and malloc().
Thanks for the help.
|
|
|
|
|
FYI
int my_malloc(void **param_adr, int param_size)
{
my_free(param_adr);
if ((*param_adr = malloc(param_size)) == NULL)
{
return -1;
}
memset(*param_adr,0,param_size);
return 0;
}
void my_free(void **param_adr)
{
if (*param_adr != NULL)
{
free(*param_adr);
*param_adr = NULL;
}
return;
}
|
|
|
|
|
You're mixing managed and unmanaged code in a very strange way.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
I know. This was the quick and dirty solution, but i'm open to alternatives.
|
|
|
|
|
How about using an <a href="http://msdn.microsoft.com/en-us/library/ts4c4dw6(VS.80).aspx">array</a><<a href="http://msdn.microsoft.com/en-us/library/system.string(VS.80).aspx">String</a>^>^ (i.e. a C++/CLI array of C++/CLI strings) instead of standard C types?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Well, I need the array in that format because I'm working with another proprietary API that works only with standard C types.
|
|
|
|
|
jlgeris wrote: temp[count]
When you allocated temp, you allocated temp[0] to temp[count-1] - temp[count] is undefined. Either use a different index variable or reset count to 0
jlgeris wrote: strlen(x)*sizeof(char)+1
As sizeof(char)==1, it makes no difference, but you really wanted (strlen(x)+1)*sizeof(char)
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hello,
my program takes in a large file(s) of byte code and writes it into thousands of smaller files.
The program gives an MFC42D.DLL: 0xC00000005 Access Violation when it reaches the first of two lines of code below.
<pre> siteAndChannelIDStr.Format("C:\\Network Data\\Unclassified Events\\Last Extracted\\%s\\#%d\\", siteNamesArray[listBoxIndex], OCUIDfromEALFile);
CreateDirectory(siteAndChannelIDStr, NULL);
The CString object and directory are successfully created during the previous iterations, but oddly fails this time round.
I have followed the program execution using the debugger and it falls down at "if" statement in the "Advanced direct buffer access" bit in MFC\SRC\STRCORE.cpp
<code> if (GetData()->nRefs > 1 || nMinBufLength > GetData()->nAllocLength)
I have tried setting siteAndChannelIDStr = ""; after use
And changing the Format function to one described on the microsoft website <a href="http://support.microsoft.com/kb/127038"></a>
And tried using CString Arrays for the siteNamesArray
But no luck!
Has anyone come across this type of problem before?
I have tried the program out on 3 different files, but it fails at the same line (although prog had passed this line for each previous hundreds of iterations)
It fails after subfile 4977/10893 in file1
after subfile 4901/8135 in file2
after subfile 384/13321 in file3
Any help would be greatly appreciated!
I can provide more information if necessary. I cannot put up source code as it is for my work.
Thanks,
Colm
|
|
|
|
|
The error implies GetData() is returning zero - why is that happening?
Are you running out of memory possibly?
What are the parameter values going into the function?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|